-->
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.  [ 3 posts ] 
Author Message
 Post subject: Including mappings from external jar
PostPosted: Tue Apr 26, 2005 10:11 am 
Newbie

Joined: Tue Apr 26, 2005 9:32 am
Posts: 2
Location: Copenhagen, Denmark
Hi all.

I hope you can help be resolve a problem with including mappings from one jar in another project.

I am using Hibernate v2.1.8 for a project consisting of two separate project strctures:
- one containing a framework with a number of classes persisted using hibernate and
- service structure which also persists a number of classes using hibernate and
relies on the mappings in the framework.

I have tried to include the mappings from the framework.jar by using the
Code:
  <mapping jar="framework.jar"/>

tag in the hibernate configuration of the service project. However it throws a NulPointerException inside Configuration.addJar(String) - the problem is cause by getResource("framework.jar") called on the context class loader returning null.

(I have also tried with both relative and full path to framework.jar - but nothing seems to work.)

I know for a fact that framework.jar is in the classpath as other parts of the service project can access classes in the framework.jar without problems.

If I use the following code when configuring the HibernateSessionFactory

Code:
final File jar = new File( "/home/user/lib/framework.jar" );
factory = new Configuration()
    .addJar( jar )
    .configure( "service.cfg.xml" )
    .buildSessionFactory();


it works fine, however specifying the full path to framework.jar is not acceptable :o(

/eiler


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 26, 2005 10:19 am 
Senior
Senior

Joined: Mon Apr 04, 2005 8:04 am
Posts: 128
Location: Manchester, NH USA
Since addJar(String) uses the classpath resource method to find the file, you need to specify the value relative to framework.jar's location on your classpath. If you're deploying a webapp and you have framework.jar in WEB-INF/classes, for example, you would specify Configuration.addJar("/formula.jar"). Makes sense?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 26, 2005 11:26 am 
Newbie

Joined: Tue Apr 26, 2005 9:32 am
Posts: 2
Location: Copenhagen, Denmark
pmularien wrote:
Since addJar(String) uses the classpath resource method to find the file, you need to specify the value relative to framework.jar's location on your classpath. If you're deploying a webapp and you have framework.jar in WEB-INF/classes, for example, you would specify Configuration.addJar("/formula.jar"). Makes sense?


That does not work, if I set my classpath to /home/user/lib/ (so framework.jar is on the classpath) I get a nullpoiinter exception from new Configuration().addJar( "/framework.jar" ) - again because the getContextClassLoader().getResource("/framework.jar") returns null. *sig*


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.