[jboss-user] [EJB 3.0] - $Proxy200 error & Invalid (i.e. remote) invocation of local

ezanih do-not-reply at jboss.com
Wed Jan 7 05:39:35 EST 2009


Hi there

I have a Java client and a HTTP servlet accessing a stateless EJB3 which accesses a wrapper datasource to persist an entity to my OracleXE database.

I am using JBoss 4.2.2.GA and Eclipse Ganymede and JDK 5.0_14.

When I tried to access the wrapper datasource directly from a standalone Java client through this initial context code,

Access wrapper ds from client:

  | Properties p = new Properties();
  | p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
  | p.put("java.naming.provider.url", "jnp://localhost:1099");
  | p.put("java.naming.factory.url.pkgs", "org.jboss.naming.client");
  | 
  | InitialContext ic = new InitialContext(p);
  | javax.sql.DataSource db = (javax.sql.DataSource) ic.lookup("java:OracleXE1_DS");
  | 

I get a naming context 'XXX not bound' exception. I finally found out that this was because my Java client is in a separate JVM from the wrapper datasource running inside my JBoss server's JVM and so, I  will not be able to use the java namespace (as above).

So I modified my Eclipse project(s) to use a stateless EJB3, the logic being, that the EJB and the wrapper datasource will be managed inside the JBoss container and so share the same container's JVM.

In my EJB3, I have both a remote and a local interface. No problems deploying the bean and I checked my JMX console and found the following entries :-

JMX JNDI View:

  | +- BiddingTestEAR (class: org.jnp.interfaces.NamingContext)
  |   |   +- BiddingTestBeanLocal (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- local (proxy: $Proxy105 implements interface my.com.eperolehan.ejb.BiddingTestBeanLocalLocal,interface org.jboss.ejb3.JBossProxy)
  |   |   +- BiddingTestBean (class: org.jnp.interfaces.NamingContext)
  |   |   |   +- local (proxy: $Proxy101 implements interface my.com.eperolehan.ejb.BiddingTestBeanRemote,interface org.jboss.ejb3.JBossProxy)
  | 

However when I try to do a context initiation first using the remote interface then using the local interface, both of them failed. I tried accessing from a standalone Java client and from a default.jsp page.

LOCAL BEAN INTERFACE

Context initiation code snippet:

  | BiddingTestBeanLocal bidder = (BiddingTestBeanLocal) ctx.lookup("BiddingTestEAR/BiddingTestBeanLocal/local");
  | 

Error console for the jsp:

  | 17:26:13,296 INFO  [TomcatDeployer] deploy, ctxPath=/BiddingWeb, warUrl=.../tmp/deploy/tmp34742BiddingTestEAR.ear-contents/BiddingWeb-exp.war/
  | 17:26:13,421 INFO  [EARDeployer] Started J2EE application: file:/C:/Program Files/jboss-4.2.2.GA/server/default/deploy/BiddingTestEAR.ear
  | 17:26:22,875 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
  | java.lang.ClassCastException: $Proxy200
  | 


Error console for the standalone client:

  | java.lang.ClassCastException: $Proxy0
  | 	at BidClient.main(BidClient.java:83)
  | Exception in thread "main" java.lang.NullPointerException
  | 	at BidClient.main(BidClient.java:100)
  | 


REMOTE BEAN INTERFACE

Context initiation code snippet:

  | Properties p = new Properties();
  | p.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
  | p.put("java.naming.provider.url", "jnp://localhost:1099");
  | p.put("java.naming.factory.url.pkgs", "org.jboss.naming.client");
  | 	           
  | InitialContext ctx = new InitialContext(p);
  | BiddingTestBeanRemote  bidder= (BiddingTestBeanRemote) ctx.lookup("BiddingTestEAR/BiddingTestBean/local");
  | 

Error console for the default.jsp:

  | javax.ejb.EJBException: java.lang.IllegalStateException: Illegal to call this method from injected, managed EntityManager
  | 

Error console for the standalone client:

  | - Container jboss.j2ee:ear=BiddingTestEAR.ear,jar=BiddingTestEJB.jar,name=BiddingTestBean,service=EJB3,VMID=413b70d7e6d9776b:377efe3:11eb05d9788:-7fff is not yet available
  | javax.ejb.EJBException: Invalid (i.e. remote) invocation of local interface (null container)
  | 	at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:80)
  | 	at $Proxy0.saveBidder(Unknown Source)
  | 	at BidClient.main(BidClient.java:88)
  | Exception in thread "main" java.lang.NullPointerException
  | 	at BidClient.main(BidClient.java:100)
  | 
  | 


and yes, I am using PersistenceContext to inject the persistence unit into the EntityManager like so:


  | @PersistenceContext(unitName="BiddingTest")
  | private static EntityManager em;
  | 


The declaration for my EJB3 implementation is:


  | @Stateless
  | public class BiddingTestBean implements BiddingTestBeanRemote {
  | 

and I have also changed it to 


  | @Stateless
  | public class BiddingTestBean implements BiddingTestBeanLocal {
  | 


What seems to be the problem?


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200021#4200021

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200021



More information about the jboss-user mailing list