-->
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.  [ 7 posts ] 
Author Message
 Post subject: Exploded jar file not a directory
PostPosted: Tue Nov 29, 2005 2:16 pm 
Newbie

Joined: Thu Nov 24, 2005 8:48 am
Posts: 10
Hello,

I am trying to use <jar-file> tag in persistence.xml file to instruct EntityManagerFactory to include the classes from this library. I use Tomcat. Unfortunately I cannot manage it to work.

I use this syntax:
<jar-file>core.jar</jar-file>

core.jar is my library and it is located in web/WEB-INF/lib.

This is what JarVisitor says:
Code:
19:10:29,728 DEBUG JarVisitor:178 - Searching mapped entities in jar/par: file:core.jar
19:10:29,729  WARN ExplodedJarVisitor:30 - Exploded jar file not a directory (ignored): file:core.jar


Here is the content of the jar file:
Code:
$ jar tf core.jar
META-INF/
META-INF/MANIFEST.MF
cz/
cz/startnet/
cz/startnet/logic/
cz/startnet/logic/settings/
cz/startnet/logic/settings/SettingsItem.class
cz/startnet/logic/settings/SettingsItemValue.class
cz/startnet/logic/settings/SettingsModule.class


What am I doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 10:35 pm 
Newbie

Joined: Thu Nov 24, 2005 8:48 am
Posts: 10
So I have debugged the hibernate entity manager code and have found two things:

1) The only way I can be sure the file will be loaded is to provide full path to the file (this is IMHO not portable to other systems) because in my case relative path begins at /opt/tomcat5.5/shared/lib which is definitely not the path of the context I work in. It would be greate if hibernate could search also the classpath of current context when running in Tomcat.

2) In JarVisitor.getVisitor() there is no checking whether the specified file exists which is very confusing. Simple check like 'file.exists()' would be very helpful for debugging why things don't work.
Code:
   public static final JarVisitor getVisitor(String jarPath, Filter[] filters) throws IllegalArgumentException {
      File file = new File( jarPath );
      if ( file.isFile() ) {
         return new InputStreamZippedJarVisitor( jarPath, filters );
      }
      else {
         return new ExplodedJarVisitor( jarPath, filters );
      }
   }


I wanted to check the latest code from cvs whether it is already solved but I cannot find any info about cvs access to the hibernate sources.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 6:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Open a JIRA issue for the debugging enhancement.
<jar-file> is considered portable in an EJB3 container, not outside. There is no reasong why this jar would be in the CP as per the WAR spec.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 7:51 am 
Newbie

Joined: Thu Nov 24, 2005 8:48 am
Posts: 10
So what would be the correct way to include jar file? In my case when developing I have the path:
Code:
/home/user/src/project/build/web/WEB-INF/lib/core.jar

When the project will be deployed on a production server, it might be in:
Code:
/var/lib/tomcat-5/default/webapps/project/WEB-INF/lib/core.jar

or
Code:
/opt/tomcat5.5/webapps/servlets-examples/WEB-INF/lib/core.jar

or
Code:
C:\somepath\...

on Windows.

So in my case the core.jar file is placed in /context/WEB-INF/lib/core.jar but hibernate searches relative path from /opt/tomcat5.5/shared/lib.

I cannot specify absolute path to the core.jar file because it won't work in all these possible environments. If I specify relative path, it won't work either. The only thing I know is where the file is placed in my context but I don't know how to specify in the persistence.xml that EMF should search the directory WEB-INF/lib in my context and not /opt/tomcat5.5/shared/lib.

Quote:
<jar-file> is considered portable in an EJB3 container, not outside.


Could you please explain me how can I set portable path to the jar file in my case? I am very new to java, hibernate and Tomcat so I might be missing something important that prevents me from understanding it.

Thank you for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 1:07 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
tomcat is not an EJB3 container, so don't expect to find a good way to set jar-file

You can try JBoss EJB3 Embeddable to embed an EJB3 container inside Tomcat however.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 2:38 pm 
Newbie

Joined: Thu Nov 24, 2005 8:48 am
Posts: 10
Now I understand. Thank you.


Top
 Profile  
 
 Post subject: jar-file
PostPosted: Tue Jan 17, 2006 1:13 am 
Newbie

Joined: Tue Jan 17, 2006 1:10 am
Posts: 1
I am also interested in using external jar files without the need to specify the full path. I am running a swing app from a webstart connection. Is there a good way to do this, without repackaging the classes into my par? Can I place the jar file into my par archive somewhere?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.