-->
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: Unable to configure EntityManagerFactory from runnable jar
PostPosted: Tue Mar 01, 2011 8:43 am 
Newbie

Joined: Tue Mar 01, 2011 8:10 am
Posts: 1
I'm developing a JPA-2.0 application using Hibernate3. It runs fine from eclipse, but if run it from a generated runnable jar, it gives a javax.persistence.PersistenceException: Unable to configure EntityManagerFactory:

Code:
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Caused by: javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:374)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
    at java.lang.String.substring(String.java:1937)
    at org.hibernate.ejb.packaging.JarVisitorFactory.getJarURLFromURLEntry(JarVisitorFactory.java:55)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:340)
    ... 12 more


If I unpack this same jar, and run the class directly, it works though:
Code:
java -cp .:<add list to all .jar files> MainClass

I cannot figure out what's wrong.


Top
 Profile  
 
 Post subject: Re: Unable to configure EntityManagerFactory from runnable jar
PostPosted: Mon Mar 21, 2011 7:04 am 
Newbie

Joined: Tue Nov 23, 2010 2:47 pm
Posts: 3
I found if you make a runnable jar but choose to have the libraries expanded alongside it (an option within the Eclipse export) then it does indeed work fine. I guess it's to do with not being able to find some resources - code built on the assumption that the jars aren't packed.


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.