-->
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.  [ 5 posts ] 
Author Message
 Post subject: Using EntityManager in J2SE
PostPosted: Wed Aug 24, 2005 3:11 am 
Newbie

Joined: Wed Aug 24, 2005 3:03 am
Posts: 3
Hi there,

I want to test my EJB3 SSB pojo's with JUnit (outside the container). I used this in the setUp() method:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("MoneyTrack");

See stacktrace below for the exception

I have a META-INF/persistence.xml in the classpath

Any idea?

[b]Version:[/b]
Hibernate EM 3.1 beta 2

[b]Full stack trace of any exception that occurs:[/b]
javax.persistence.PersistenceException: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:199)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
at nl.mlnd.mt.services.impl.AccountServicesTest.<init>(AccountServicesTest.java:25)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at junit.framework.TestSuite.createTest(TestSuite.java:131)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
at junit.framework.TestSuite.<init>(TestSuite.java:75)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:399)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1768)
at org.hibernate.ejb.packaging.JarVisitor.unqualify(JarVisitor.java:56)
at org.hibernate.ejb.packaging.ExplodedJarVisitor.<init>(ExplodedJarVisitor.java:19)
at org.hibernate.ejb.packaging.JarVisitor.getVisitor(JarVisitor.java:29)
at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:171)
... 14 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 24, 2005 5:23 am 
Newbie

Joined: Wed Aug 24, 2005 3:03 am
Posts: 3
I already found it. Its a problem in the org.hibernate.ejb.packaging.JarVisitor.unqualify() method. It doesn't work with exploded jars...


(the javadoc states its a weak algorithm ;-))


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 24, 2005 5:29 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Well it's weak but not that weak.
What is the context.
You directory does not follow the jar naming pattern? ie. foobar.jar ?

I made exploded jar for J2EE initially, and they explode them in a directory having the exact name of the jar (suffix included).

I guess I can improve that

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 24, 2005 5:56 am 
Newbie

Joined: Wed Aug 24, 2005 3:03 am
Posts: 3
Ok, everything works fine when my folder has the .jar extension.

Thanx.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 8:27 am 
Newbie

Joined: Fri Sep 02, 2005 2:55 pm
Posts: 3
Hi, i am having the same problem. Can you please tell me wich directory should have the jar extension.


Thanks very much.


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