-->
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.  [ 2 posts ] 
Author Message
 Post subject: PersistenceException if bulding runnable .jar
PostPosted: Sat Jan 28, 2012 6:36 pm 
Newbie

Joined: Fri Dec 23, 2011 7:40 pm
Posts: 12
I have an app using Hibernate/JPA, that isn't quite working right.
When I build the executable .jar (From Eclipse), and have it extract all the required classes into the generated .jar - Hibernate works, but other things fail.
If I have it package all the required .jar files into the generated .jar - hibernate fails to initialize properly.
This is with Hibernate 4.0.0.
I turned on TRACE level logging, and have found the following:
During initialization, it seems to pick up the database:

Code:
935    [           main] DEBUG ibernate.ejb.Ejb3Configuration - Look up for persistence unit: EMailDB
937    [           main] TRACE ibernate.ejb.Ejb3Configuration - Analyzing persistence.xml: rsrc:META-INF/persistence.xml
1045   [           main] TRACE packaging.PersistenceXmlLoader - Validate with persistence_2_0.xsd schema on file rsrc:META-INF/persistence.xml
1058   [           main] TRACE packaging.PersistenceXmlLoader - Persistent Unit name from persistence.xml: EMailDB
1063   [           main] TRACE ibernate.ejb.Ejb3Configuration - PersistenceMetadata(version=2.0) [
        name: EMailDB
        jtaDataSource: null
        nonJtaDataSource: null
        transactionType: RESOURCE_LOCAL
        provider: org.hibernate.ejb.HibernatePersistence
        useQuotedIdentifiers: false
        classes[
                com.casadelgato.email.repository.jpa.JPAMessage         com.casadelgato.email.repository.jpa.JPAMessageBodies           com.casadelgato.email.re
pository.jpa.JPAFolder          com.casadelgato.email.repository.jpa.JPAAccount         com.casadelgato.email.repository.jpa.JPAMsgEntry                com.casa
delgato.email.repository.jpa.EntryID            com.casadelgato.email.repository.jpa.JPAMessageFilter           com.casadelgato.email.repository.jpa.JPAFilterGr
oup             com.casadelgato.email.repository.jpa.JPAEmailProperty           com.casadelgato.email.repository.jpa.JPAContact         com.casadelgato.email.re
pository.jpa.JPATag     ]
        packages[
        ]
        mappingFiles[
        ]
        jarFiles[
        ]
        hbmfiles: 0
        properties[
                hibernate.connection.username: sa
                hibernate.archive.autodetecion: class, hbm
                hibernate.dialect: org.hibernate.dialect.HSQLDialect
                hibernate.connection.url: jdbc:hsqldb:file://C:/Users/Cougar/Email\database
                hibernate.show_sql: false
                hibernate.connection.driver_class: org.hsqldb.jdbc.JDBCDriver
                hibernate.format_sql: true
        ]]
1113   [           main] DEBUG l.repository.jpa.JPARepository - Database Not Initialized Yet
1114   [           main] DEBUG l.repository.jpa.JPARepository - initDatabase
1117   [           main] DEBUG l.repository.jpa.JPARepository - Connection: jdbc:hsqldb:file://C:/Users/Cougar/Email\database
1119   [           main] DEBUG bernate.type.BasicTypeRegistry - Adding type registration boolean -> org.hibernate.type.BooleanType@42a9c09e
.. a whole bunch of type registrations happen here ...


Then, a short time later (still starting up), this happens:

Code:
1354   [           main] DEBUG ibernate.ejb.Ejb3Configuration - Look up for persistence unit: EMailDB
1356   [           main] TRACE ibernate.ejb.Ejb3Configuration - Analyzing persistence.xml: rsrc:META-INF/persistence.xml
1385   [           main] TRACE packaging.PersistenceXmlLoader - Validate with persistence_2_0.xsd schema on file rsrc:META-INF/persistence.xml
1389   [           main] TRACE packaging.PersistenceXmlLoader - Persistent Unit name from persistence.xml: EMailDB
1391   [           main] TRACE ibernate.ejb.Ejb3Configuration - PersistenceMetadata(version=2.0) [
        name: EMailDB
        jtaDataSource: null
        nonJtaDataSource: null
        transactionType: RESOURCE_LOCAL
        provider: org.hibernate.ejb.HibernatePersistence
        useQuotedIdentifiers: false
        classes[
                com.casadelgato.email.repository.jpa.JPAMessage         com.casadelgato.email.repository.jpa.JPAMessageBodies           com.casadelgato.email.re
pository.jpa.JPAFolder          com.casadelgato.email.repository.jpa.JPAAccount         com.casadelgato.email.repository.jpa.JPAMsgEntry                com.casa
delgato.email.repository.jpa.EntryID            com.casadelgato.email.repository.jpa.JPAMessageFilter           com.casadelgato.email.repository.jpa.JPAFilterGr
oup             com.casadelgato.email.repository.jpa.JPAEmailProperty           com.casadelgato.email.repository.jpa.JPAContact         com.casadelgato.email.re
pository.jpa.JPATag     ]
        packages[
        ]
        mappingFiles[
        ]
        jarFiles[
        ]
        hbmfiles: 0
        properties[
                hibernate.connection.username: sa
                hibernate.archive.autodetecion: class, hbm
                hibernate.dialect: org.hibernate.dialect.HSQLDialect
                hibernate.connection.url: jdbc:hsqldb:file://C:/Users/Cougar/Email\database
                hibernate.show_sql: false
                hibernate.connection.driver_class: org.hsqldb.jdbc.JDBCDriver
                hibernate.format_sql: true
        ]]
javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:385)
        at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:55)
        at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63)
        at com.casadelgato.email.repository.jpa.JPARepository.createEntityManager(JPARepository.java:124)
        at com.casadelgato.email.repository.jpa.JPARepository.initDatabase(JPARepository.java:179)
        at com.casadelgato.email.repository.jpa.JPARepository.open(JPARepository.java:161)
        at com.casadelgato.email.ObjectFactory.getRepository(ObjectFactory.java:20)
        at com.casadelgato.email.server.EmailServer.main(EmailServer.java:66)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(Unknown Source)
        at org.hibernate.ejb.packaging.JarVisitorFactory.getJarURLFromURLEntry(JarVisitorFactory.java:57)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:351)
        ... 12 more


And that IS the entire stack trace that it puts out.
Then it appears to do a whole bunch of Type Registrations again.
Then, the exact same error happens AGAIN.

And finally, the app just hangs.

Any ideas?


Top
 Profile  
 
 Post subject: Re: PersistenceException if bulding runnable .jar
PostPosted: Sat Jan 28, 2012 8:08 pm 
Newbie

Joined: Fri Dec 23, 2011 7:40 pm
Posts: 12
One more bit of info. That first time, where it looks like the database loaded?
It didn't. There was a stray catch that was eating the exception - which was the same as the following 2. Each is caused by some other part of the code attempting to load up the database.
Looking at the code in JarVisitorFactory, I would be that the "url.getFile()" is returning a file name of length 0.
This seems to have something to do with having the various hibernate .jar files, embedded in the application .jar file.
The META-INF/persistence.xml does get put in the application .jar.


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