-->
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.  [ 9 posts ] 
Author Message
 Post subject: Incompatible argument to function error.
PostPosted: Thu Apr 13, 2006 10:55 pm 
Newbie

Joined: Thu Mar 25, 2004 9:15 am
Posts: 6
Hi, I am trying out Hibernate EJB3. I have no clue what the error I have is. I would thank a million for anyone who can shed any light. This is the error I have.


1) testUserSave(com.test.persistence.TuserTest)java.lang.VerifyError: (class: org/hibernate/ejb/AbstractEntityManagerImpl, method: throwPersistenceException signature: (Lorg/hibernate/HibernateException;)V) Incompatible argument to function
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:37)
at org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:32)
at com.test.persistence.TuserTest.testUserSave(TuserTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)




TuserTest.java:65 is this line


entityManager = entityManagerFactory.createEntityManager();


When I do this

entityManager = entityManagerFactory.createEntityManager(null);

This is what I got

There was 1 error:
1) testUserSave(com.test.persistence.TuserTest)java.lang.AbstractMethodError: org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(Ljavax/persistence/PersistenceContextType;)Ljavax/persistence/EntityManager;
at com.test.persistence.TuserTest.testUserSave(TuserTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


I am new to Hibernate EJB3. So it very much possible on the way I use Hinernate, I guess. I have heard from other developers that it is solid. So I would appreciate if anyone can point out what I should do to get over this. The version I use is

Hibernate Core 3.2.CR1

Hibernate Annotations 3.1 beta 9

Hibernate EntityManager 3.1 beta 7


This is the persistence.xml I used.


<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">
<persistence-unit name="test" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.test.persistence.Tuser</class>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="jdbc.url" value="jdbc:mysql://localhost:3306/test"/>
<property name="jdbc.driver" value="com.mysql.jdbc.Driver"/>
<property name="jdbc.user" value="user"/>
<property name="jdbc.password" value="password"/>
</properties>
</persistence-unit>
</persistence>

Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 14, 2006 4:00 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Follow the examples.
Get your EM the same way they do.


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Fri Apr 14, 2006 9:08 am 
Newbie

Joined: Thu Mar 25, 2004 9:15 am
Posts: 6
Thanks alesj. Can you elaborate? I think you are seeing what I do not. I did follow the examples and got the result. I am new to Hibernate and don't really know where to look when things go wrong. Thanks again.


bc2002


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 9:10 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Looks like you have some incompatible versions in your classpath or some weird JDK.
Are you sure you only have HEM beta7 HA beta9 (no older version) and the corresponding ejb3-persistence.jar?
Which VM are you using?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 10:38 am 
Newbie

Joined: Thu Mar 25, 2004 9:15 am
Posts: 6
Thank you for your reply. I run jdk1.5.0_06, hibernate-annotations-3.1beta9, hibernate-entitymanager-3.1beta7 and the latest hibernate core. I deleted the libraries, reload them and rerun the test. However this is what I got:


1) testUserSave(com.test.persistence.TuserTest)java.lang.AbstractMethodError: org.hibernate.ejb.EntityManagerFactoryImpl.createEntityManager(Ljavax/persistence/PersistenceContextType;)Ljavax/persistence/EntityManager;
at com.test.persistence.TuserTest.testUserSave(TuserTest.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


I am now even more confused. I included all the jars and those in the lib from those packages as well. Thank you if you can shed any light.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 11:17 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
TuserTest use the old EMF API (ie pre beta7).

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 4:38 pm 
Newbie

Joined: Thu Mar 25, 2004 9:15 am
Posts: 6
Thank you Emmanuel. I redownload all of the packages from Hibernate.org. I reload the libraries and rerun the test. This is what I got:


1) testUserSave(com.test.persistence.TuserTest)javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.ejb.AbstractEntityManagerImpl.flush(AbstractEntityManagerImpl.java:268)
at com.test.persistence.TuserTest.testUserSave(TuserTest.java:69)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


I think I learned something. I appreciate your help. For the current error, I am not sure if transaction was mentioned any where in the doc I read. Do we need to get transaction going to save objects? If yes, how do we do that? I didn't see anything on that in the doc.


Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 5:11 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
That's actually in the javadoc :-)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 17, 2006 6:26 pm 
Newbie

Joined: Thu Mar 25, 2004 9:15 am
Posts: 6
Thank you. I went back and read the doc and found it. I still can not get it working but I think I will slowly figure things out first. Thanks again.


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