Hi List!
I'm having problems with bundling hibernate and my ejb model in eclipse RCP application. I managed to solve all classloading problems but one, related to InputStreamZippedJarVisitor class.
Simplifying things I have:
hibernate plugin which registers itself for buddy classloading policy
dbmodel plugin which depends on hibernate and is a buddy of hibernate
application plugin which depends on hibernate and dbmodel and is a buddy of hibernate. This application plugin has hibernate.cfg.xml in self.
When I run this project from eclipse IDE, all is fine except the warning message in logs while creating EntityManager:
Code:
2006-10-20 09:07:23 org.hibernate.ejb.packaging.InputStreamZippedJarVisitor doProcessElements
WARNING: Unable to find file (ignored): bundleresource://101
java.io.FileNotFoundException: C:\Documents and Settings\mkostrze\sv-head2\com.pentacomp.dbmodel (Access denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at org.eclipse.osgi.framework.util.SecureAction.getFileInputStream(SecureAction.java:99)
at org.eclipse.osgi.baseadaptor.bundlefile.FileBundleEntry.getInputStream(FileBundleEntry.java:50)
at org.eclipse.osgi.framework.internal.core.BundleURLConnection.connect(BundleURLConnection.java:53)
at org.eclipse.osgi.framework.internal.core.BundleURLConnection.getInputStream(BundleURLConnection.java:99)
at java.net.URL.openStream(URL.java:1007)
at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:33)
at org.hibernate.ejb.packaging.JarVisitor.getMatchingEntries(JarVisitor.java:215)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromVisitor(Ejb3Configuration.java:253)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:229)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
at com.pentacomp.dicom.viewer.ViewerContstants.createEntityManager(ViewerContstants.java:170)
at com.pentacomp.dicom.viewer.DicomViewerMainFrame$InitRepositoriesTask.call(DicomViewerMainFrame.java:146)
I suppose hibernate tries to inspect the model jar for some reason, but in IDE this jar location is resolved to directory containing the plugin.
But things get worse when I export the project into java webstart application. I'm getting NullPointerException instead of warning in the same place. I investigated the source and the problem is here:
Code:
protected void doProcessElements() throws IOException {
JarInputStream jis;
try {
jis = new JarInputStream( jarUrl.openStream() );
}
catch (IOException ze) {
log.warn( "Unable to find file (ignored): " + jarUrl, ze );
return;
}
The jarUrl is a bundleresource:// url which resolves to DirZipBundleEntry which in turn returns null in getInputStream(). Thus JarInputStream thows NPE.
Here's what I've tried to solve this:
- configure the dbmodel to be unpacked or packed after install
- tried dbmodel with jar inside or with unpacked classes inside
- set hibernate.archive.autodetection to 'none'. (I did it passing parameters map to createEntityManager method)
- change the hibernate sources and replace IOException with Exception in doProcessElement method.
This one worked
I guess most likely I did something wrong to my deploy - any ideas please? But if not, perhaps such a change in code may make hibernate more robust (?)
Hibernate version: 3.2.0 GA
best regards,
Michal Kostrzewa