[jboss-user] [EJB 3.0] - Re: $Proxy200 error & Invalid (i.e. remote) invocation of lo
ezanih
do-not-reply at jboss.com
Wed Jan 7 23:53:50 EST 2009
Ok, you are right :-) ...JNDI now returns a remote namespace:
JMX Console's JNDI View:
| +- BiddingTestEAR (class: org.jnp.interfaces.NamingContext)
| | +- BiddingTestBeanLocal (class: org.jnp.interfaces.NamingContext)
| | | +- local (proxy: $Proxy107 implements interface my.com.eperolehan.ejb.BiddingTestBeanLocalLocal,interface org.jboss.ejb3.JBossProxy)
| | +- BiddingTestBean (class: org.jnp.interfaces.NamingContext)
| | | +- remote (proxy: $Proxy102 implements interface my.com.eperolehan.ejb.BiddingTestBeanRemote,interface org.jboss.ejb3.JBossProxy)
|
However, I am now getting this rather simple 2-liner error :
| java.lang.NullPointerException
| at BidClient.main(BidClient.java:95)
|
and the code pointed to is this :
| em.getTransaction().begin();
|
I've moved all the em.getTransaction().begin(), em.persist(bidder) and em.getTransaction().commit() calls out of the EJB3 and into the client because originally putting them in the EJB3 was giving me this error :
Console:
| 10:43:46,984 ERROR [STDERR] java.lang.IllegalStateException: Illegal to call this method from injected, managed EntityManager
|
It seems that whenever I use the code below, I get the above error:
| @PersistenceContext(unitName="BiddingTest")
| private static EntityManager em;
|
So I changed from injection to this :
| private static EntityManagerFactory emf;
| private static EntityManager em;
|
| emf = Persistence.createEntityManagerFactory("BiddingTest");
| em = emf.createEntityManager();
|
Then I got this error which I believe, from the forums, is due to incompatibilities from the Hibernation Compatibility Matrix :
| Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.cfg.AnnotationConfiguration.setProperty(Ljava/lang/String;Ljava/lang/String;)Lorg/hibernate/cfg/AnnotationConfiguration;
|
However, I made sure I was compatible by using the latest Hibernate downloads and including the jars as well as the supporting and required jars found in the lib of that Hibernate product.
Here is what I've added to the classpath:
antlr-2.7.6.jar
commons-collections-3.1.jar
commons-logging-1.1.1.jar
concurrent.jar
dom4j-1.6.1.jar
ejb3-persistence.jar
hibernate-annotations.jar
hibernate-commons-annotations.jar
hibernate-core.jar
hibernate-entitymanager.jar
javassist-3.4.GA.jar
jboss-common-client.jar
jboss-j2ee.jar
jboss-transaction-client.jar
jbossall-client.jar
jbosssx-client.jar
jnp-client.jar
jnpserver.jar
jta-1.1.jar
log4j.jar
slf4j-api-1.5.2.jar
slf4j-jdk14-1.5.2.jar
My Hibernate versions:
- Hibernate Distribution 3.3.1.GA
- Hibernate EntityManager 3.4.0.GA
- Hibernate Annotations 3.4.0.GA
Ugh...still no progress, but I would like to ask you a few questions also:-
(1) Should the EntityManagerFactory be created only once (since it is a factory) and where is the best place to put its creation? Should we make the creation a singleton and how?
(2) Should the EntityManager be created in the EJB or in the java client or servlet or jsp ?
(3) Where do I place all the "em.getTransaction().begin(), em.persist(bidder) and em.getTransaction().commit()" commands? In the client/servlet/jsp or in the EJB?
Thank you so much in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200232#4200232
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200232
More information about the jboss-user
mailing list