-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: reference not found in a template
PostPosted: Fri Jun 13, 2008 10:33 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
Hibernate version: 3.2.1GA

Hello,

I write a template for the generic exporter, with a single file output.

Inside i use the differents references from the configuration:

Code:
${cfg.getProperty("hibernate.connection.driver_class")}
${cfg.getProperty("hibernate.connection.url")}
${cfg.getProperty("hibernate.connection.username")}


this work well, but when i want to use the password:

Code:
${cfg.getProperty("hibernate.connection.password")}


there is the following exception:

org.hibernate.tool.hbm2x.ExporterException: Error while processing Configuration with template springBeans.ftl
freemarker.core.InvalidReferenceException: Expression cfg.getProperty("hibernate.connection.password") is undefined on line 36, column 42 in springBeans.ftl.


Yet, all these properties are in my hibernate.cfg.xml:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.bytecode.use_reflection_optimizer">false</property>
        <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="hibernate.connection.url">jdbc:hsqldb:hsql://localhost/</property>
        <property name="hibernate.connection.username">sa</property>
        <property name="hibernate.connection.password">hello</property>
        <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
    </session-factory>
</hibernate-configuration>


Is there some security restriction or anything?

Thank you by advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 14, 2008 8:45 am 
Regular
Regular

Joined: Sun Apr 13, 2008 3:04 am
Posts: 71
Location: Bangalore
It may not be any security issue..The best way to eliminate such option is hard code password value instead of using ${cfg.getProperty("hibernate.connection.password")} and see if things work fine. Also, System.out of such value should tell you if reading happening poperly or not..(may help in finding out any spelling issues etc)

Regards,
Nagendra

_________________
Raja Nagendra Kumar,
C.T.O
http://www.tejasoft.com
TejaSoft - Specialists in Code Audit, Unit Testing and Merciless Re-factoring - Engineering Crisis Turnaround Experts


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 3:20 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
Thanks you for your attention.
I think we are missunderstood.

I use eclipse hibernate tool 3.2.1GA

I'm coding a template (a .ftl file) which is used to generate a file. And i want this file to be printed with the password value of the hibernate configuration.

So i write ${cfg.getProperty("hibernate.connection.password")} in the template. (like i do with other value like username and so on.


Quote:
to eliminate such option is hard code password value


I can't hardcode the password in the template, it will be used for many databases.

Quote:
System.out of such value should tell you if reading happening poperly or not..(may help in finding out any spelling issues etc)



I would say the exception is launch at the file generation time, and it say "this property doesn't exist". Otherwise i know it exist because i wrote it in the hbm.xml

Thank you and Sorry for the bad english.

Regards,
Slimane


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 6:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
does the other properties work fine ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 10:35 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
Yes, every prop work properly except the password.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 10:47 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sounds very weird then since I can't find any place in hibernate core or tools where this password should be stripped out.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 11:06 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
very curious, so i decided to externalize these information from generation, but it don't solve the original problem.

Thank you
Regards,
Slimane


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 11:22 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
fyi, I just tested this with:

${cfg.getProperty('hibernate.connection.password')

and that worked perfectly.

${cfg.getProperty('hibernate.connection.somethingthatdoesnotexist')

failed like you see.

So I cannot reproduce it.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 16, 2008 11:47 am 
Newbie

Joined: Fri Jun 13, 2008 10:17 am
Posts: 18
ok


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.