-->
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.  [ 3 posts ] 
Author Message
 Post subject: Making a client-side JPA connection
PostPosted: Tue Sep 16, 2008 4:58 am 
Newbie

Joined: Tue Sep 16, 2008 4:52 am
Posts: 4
For testing purpose I am trying to make a JPA connection to our database.
I get an error saying:
Code:
Unable to configure EntityManagerFactory

with no further explanation!

I think I have tried everything in my persistence file and now finally I give up.

My persistence.xml (only the persistence-unit):
Code:
<persistence-unit name="Test" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <class>dme.dm.device.Operation</class>
    <class>dme.dm.device.Action</class>
    <properties>
        <property name="hibernate.connection.driver_class"
                  value="com.mysql.jdbc.Driver"/>
        <property name="hibernate.connection.username"
                  value="jb"/>
        <property name="hibernate.connection.password"
                  value="123"/>
        <property name="hibernate.connection.url"
                  value="jdbc:mysql://127.0.0.1/dm"/>
        <property name="hibernate.dialect"
                  value="org.hibernate.dialect.MySQLDialect"/>
        <property name="hibernate.hbm2ddl.auto"
                  value="update"/>
    </properties>
</persistence-unit>

And I make the call like this:
Code:
public class OperationTest {
    private EntityManager entityManager;

    @Before
    public void setUp() {
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("Test");
        entityManager = emf.createEntityManager();
    }
}

When I run this code I get the exception:
Code:
javax.persistence.PersistenceException: [PersistenceUnit: Test] Unable to configure EntityManagerFactory
   at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:265)
   at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:125)


Does anyone have an idea of what could be wrong?

Regards,
Thomas


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 16, 2008 4:15 pm 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Quote:
.. with no further explanation!


really? I suppose you could give us more from the stacktraces. Indeed one cannot see what's going on if we have only these few lines of the stacktrace.

Alternatively, debug into the Hibernate code - if you haven' t the source code, download it and my it available in you favourite IDE - sometimes this is very useful.

_________________
Carlo
-----------------------------------------------------------
please don't forget to rate if this post helped you


Top
 Profile  
 
 Post subject: explanation follows
PostPosted: Wed Sep 17, 2008 5:40 am 
Newbie

Joined: Tue Sep 16, 2008 4:52 am
Posts: 4
carlolf your right, there is a further explanation.

Looking deeper into the stacktrace I found this one:
java.lang.NoSuchMethodException:
Code:
org.hibernate.validator.ClassValidator.<init>(...)


I found out that I had jboss libs in my classpath with the same class, but obviously another version. Removing jboss from the classpath made everything spin like a cat.

Funny how many problems one can solve just presenting the problem to others :)

Thanks,
Thomas


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