I am trying to use Hibernate with a piece of server software called SmartFoxServer. It has it's own runtime environment, so I have little control over how that is set up. But when trying to use Hibernate EntityManager with it, I need to place the persistence.xml in a META-INF folder under the root folder (SFS2X). The problem is that the Ejb3Configuration.java file scans through all the files under that root, examining each .class file, I presume to see if it has annotations. This occurs around line 350-375 in the Ejb3Configuration.java file, (I'm using the 4.2.6 branch of Hibernate from GitHub)
There is a particular .class file that is part of SmartfoxServer hidden in a subfolder that causes this scanner to crash. I can't remove this file, as it is needed for SmartfoxServer. Is there anyway to stop hibernate from doing this recursive search? or way I can configure my environment to stop this? I've been reading through the EntityManager source code, but can't figure out if there is a way to stop it searching, although when it starts loading scanners from configuration, I kinda get lost.
Thanks for any help.
Here's the relevant part of the log file:
Code:
10:21:45,341 TRACE [main] ejb.Ejb3Configuration - Analyzing persistence.xml: file:/Applications/SmartFoxServer_2X/SFS2X/META-INF/persistence.xml
10:21:45,624 TRACE [main] packaging.PersistenceXmlLoader - Validate with persistence_2_0.xsd schema on file file:/Applications/SmartFoxServer_2X/SFS2X/META-INF/persistence.xml
10:21:45,632 TRACE [main] packaging.PersistenceXmlLoader - Persistent Unit name from persistence.xml: aetherlightPersistence
10:21:45,634 TRACE [main] ejb.Ejb3Configuration - PersistenceMetadata(version=2.0) [
name: aetherlightPersistence
jtaDataSource: null
nonJtaDataSource: null
transactionType: RESOURCE_LOCAL
provider: org.hibernate.ejb.HibernatePersistence
useQuotedIdentifiers: false
classes[
com.aetherlight.model.User com.aetherlight.model ]
packages[
]
mappingFiles[
]
jarFiles[
]
hbmfiles: 0
properties[
c3p0.maxIdleTime: 7200
hibernate.connection.driver_class: com.mysql.jdbc.Driver
c3p0.min_size: 5
connection.provider_class: org.hibernate.connection.C3P0ConnectionProvider
hibernate.dialect: org.hibernate.dialect.MySQLDialect
c3p0.timeout: 1800
hibernate.connection.username: root
c3p0.max_size: 20
hibernate.hbm2ddl.auto: validate
hibernate.connection.url: jdbc:mysql://localhost/aetherlight
hibernate.show_sql: true
hibernate.connection.password: secret
c3p0.max_statements: 50
c3p0.idleConnectionTestPeriod: 100
]]
10:21:45,636 TRACE [main] packaging.JarVisitorFactory - JAR URL from URL Entry: file:/Applications/SmartFoxServer_2X/SFS2X/META-INF/persistence.xml >> file:/Applications/SmartFoxServer_2X/SFS2X/
10:21:45,670 DEBUG [main] packaging.AbstractJarVisitor - Searching mapped entities in jar/par: file:/Applications/SmartFoxServer_2X/SFS2X/
10:21:45,680 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.jconsole.console$py
10:21:45,718 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.jconsole.history$py
10:21:45,720 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.jconsole.introspect$py
10:21:45,723 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.jconsole.jintrospect$py
10:21:45,726 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.jconsole.popup$py
10:21:45,730 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.jconsole.tip$py
10:21:45,734 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.__future__$py
10:21:45,747 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.code$py
10:21:45,749 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.codecs$py
10:21:45,752 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.codeop$py
10:21:45,754 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.copy_reg$py
10:21:45,755 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.datetime$py
10:21:45,769 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.encodings.__init__$py
10:21:45,770 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.encodings.aliases$py
10:21:45,774 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.encodings.utf_8$py
10:21:45,776 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.inspect$py
10:21:45,778 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.javaos$py
10:21:45,781 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.javapath$py
10:21:45,795 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.linecache$py
10:21:45,799 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.random$py
10:21:45,802 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.re$py
10:21:45,802 DEBUG [main] packaging.AbstractJarVisitor - Filtering: lib.Lib.reindex$py
10:21:45,804 ERROR [main] managers.SFSExtensionManager - javax.persistence.PersistenceException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: javax.persistence.PersistenceException
Message: Unable to configure EntityManagerFactory
Description: Extension initialization failed.
+--- --- ---+
Stack Trace:
+--- --- ---+
org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:387)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:58)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
com.aetherlight.extensions.AetherlightExtension.init(AetherlightExtension.java:29)
com.smartfoxserver.v2.entities.managers.SFSExtensionManager.createExtension(SFSExtensionManager.java:302)
com.smartfoxserver.v2.entities.managers.SFSZoneManager.createZone(SFSZoneManager.java:428)
com.smartfoxserver.v2.entities.managers.SFSZoneManager.initializeZones(SFSZoneManager.java:240)
com.smartfoxserver.v2.SmartFoxServer.start(SmartFoxServer.java:234)
com.smartfoxserver.v2.Main.main(Main.java:31)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
10:21:45,804 INFO [main] managers.SFSZoneManager -
Another SmartfoxServer user had the same issue and manager to get this stack-trace (I can't seem to get the full one):
Code:
Caused by: javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:384)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47)
at com.softstar.sfs2x.extensions.database.JPAUtilFactory$Builder.<init>(JPAUtilFactory.java:18)
at com.softstar.sfs2x.extensions.database.JPAUtil.<clinit>(JPAUtil.java:11)
... 6 more
Caused by: java.lang.RuntimeException: Error while reading file:/E:/SmartFoxServer/SmartFoxServer2X/SFS2X/
at org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(NativeScanner.java:129)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:484)
at org.hibernate.ejb.Ejb3Configuration.addMetadataFromScan(Ejb3Configuration.java:474)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:360)
... 11 more
Caused by: java.io.IOException: bad magic number: b5f1001c
at javassist.bytecode.ClassFile.read(ClassFile.java:761)
at javassist.bytecode.ClassFile.<init>(ClassFile.java:109)
at org.hibernate.ejb.packaging.AbstractJarVisitor.checkAnnotationMatching(AbstractJarVisitor.java:245)
at org.hibernate.ejb.packaging.AbstractJarVisitor.executeJavaElementFilter(AbstractJarVisitor.java:211)
at org.hibernate.ejb.packaging.AbstractJarVisitor.addElement(AbstractJarVisitor.java:172)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:125)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:133)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.getClassNamesInTree(ExplodedJarVisitor.java:133)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.doProcessElements(ExplodedJarVisitor.java:91)
at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:148)
at org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(NativeScanner.java:126)
... 14 more