This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes NamingException: Could not dereference object  - EJB 3.0 workbook ex05-2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "NamingException: Could not dereference object  - EJB 3.0 workbook ex05-2" Watch "NamingException: Could not dereference object  - EJB 3.0 workbook ex05-2" New topic
Author

NamingException: Could not dereference object - EJB 3.0 workbook ex05-2

Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi Everyone,

I have stucked on workbook ex05_2 that makes comparison between using the same entity bean in TransactionPersistenceContext & ExtendedPersistenceContext. Anyhow, the following error occurred when trying to access either of these contexts:

javax.naming.NamingException: Could not dereference object [Root exception is java.lang.reflect.UndeclaredThrowableException]
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1150)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:705)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:587)
at javax.naming.InitialContext.lookup(InitialContext.java:392)
at client.Main.main(Main.java:33)
Caused by: java.lang.reflect.UndeclaredThrowableException
at $Proxy1.createProxy(Unknown Source)
at org.jboss.ejb3.JndiProxyFactory.getObjectInstance(JndiProxyFactory.java:52)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1125)
at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1142)
... 4 more

This message make sense considering the jndi listing as follows:

+- ExtendedPersistenceContextBean (class: org.jnp.interfaces.NamingContext)
| +- remote (class: java.lang.Object)
| +- remoteStatefulProxyFactory (proxy: $Proxy76 implements interface org.jboss.ejb3.ProxyFactory)
+- TravelAgentBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy81 implements interface travelagent.TravelAgentRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
+- TransactionPersistenceContextBean (class: org.jnp.interfaces.NamingContext)
| +- remote (class: java.lang.Object)
| +- remoteStatefulProxyFactory (proxy: $Proxy76 implements interface org.jboss.ejb3.ProxyFactory)

To call TravelAgentRemote interface, use jndiContext.lookup(" TravelAgentBean/remote"). However, it appears that
I would not get anything by calling either jndiContext.lookup(" TransactionPersistenceContextBean/remote") or jndiContext.lookup(" ExtendedPersistenceContextBean/remote") according to the above jndi table.

The client code are as follows:



This exercise does not work as delivered on the command prompt.

I am running Netbeans 5.5, JBoss 4.0.5GA & JDK1.6.0 on Windows XP platform.

The workbook is from EJB 3.0 by Bill Burke.

Any assistance would be greatly appreciated.

Thanks,

Henry
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi,

I managed to overcome this issue with the following syntax when using Sun System Java Application Server PE 9.0:



The Client output from Netbeans is:

no cabin should be null: null
Master Suite
1
1
3
Updating detached cabin instance with new bed count of 4
Finding cabin to see it has been updated with a merge() on server
new bed count is: 4
Set up transaction persistence context stateful bean
Cabin bed count will still be 4: 4
Set up extended persistence context stateful bean
Cabin bed count will be 5: 5

However, I still could not find a solution when running in JBoss AS 4.0.5.

Thanks,

Henry
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi All,

Could someone please help me with this issue on the JBoss platform?

I still could not identify what the problem for so many weeks.

Thanks,

Henry
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9912
    
158

You are having problems looking up the TransactionPersistenceContextBean/remote and the other bean on JBoss? Can you post the code for this bean? Especially the annotations on each of these beans.


[My Blog] [JavaRanch Journal]
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi Jaikiran,

Here are the codes as requested:













I did not have any problem running them using SJAS PE 9.0 by modifying the JNDI lookup to use "travelagent.TransactionPersistenceContextRemote" as opposed to "TransactionPersistenceContextBean/remote".

The Client code looks like this:





The main() method in amy1client runs first to setup the Cabin table prior to running amy2client.

Here is the detail on JMX-Console:

jboss.j2ee
jar=amy.jar,name=ExtendedPersistenceContextBean,service=EJB3
jar=amy.jar,name=TransactionPersistenceContextBean,service=EJB3
jar=amy.jar,name=TravelAgentBean,service=EJB3
module=amy.jar,service=EJB3

Jndi View
ExtendedPersistenceContextBean (class: org.jnp.interfaces.NamingContext)
| +- remote (class: java.lang.Object)
| +- remoteStatefulProxyFactory (proxy: $Proxy74 implements interface org.jboss.ejb3.ProxyFactory)
+- JBossClient (class: org.jnp.interfaces.NamingContext)
+- UILXAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
+- UIL2XAConnectionFactory[link -> XAConnectionFactory] (class: javax.naming.LinkRef)
+- queue (class: org.jnp.interfaces.NamingContext)
| +- A (class: org.jboss.mq.SpyQueue)
| +- testQueue (class: org.jboss.mq.SpyQueue)
| +- ex (class: org.jboss.mq.SpyQueue)
| +- DLQ (class: org.jboss.mq.SpyQueue)
| +- D (class: org.jboss.mq.SpyQueue)
| +- C (class: org.jboss.mq.SpyQueue)
| +- B (class: org.jboss.mq.SpyQueue)
+- topic (class: org.jnp.interfaces.NamingContext)
| +- testDurableTopic (class: org.jboss.mq.SpyTopic)
| +- testTopic (class: org.jboss.mq.SpyTopic)
| +- securedTopic (class: org.jboss.mq.SpyTopic)
+- amy2-Client (class: org.jnp.interfaces.NamingContext)
+- console (class: org.jnp.interfaces.NamingContext)
| +- PluginManager (proxy: $Proxy46 implements interface org.jboss.console.manager.PluginManagerMBean)
+- UIL2ConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
+- HiLoKeyGeneratorFactory (class: org.jboss.ejb.plugins.keygenerator.hilo.HiLoKeyGeneratorFactory)
+- TravelAgentBean (class: org.jnp.interfaces.NamingContext)
| +- remote (proxy: $Proxy88 implements interface travelagent.TravelAgentRemote,interface org.jboss.ejb3.JBossProxy,interface javax.ejb.EJBObject)
+- UILConnectionFactory[link -> ConnectionFactory] (class: javax.naming.LinkRef)
+- TransactionPersistenceContextBean (class: org.jnp.interfaces.NamingContext)
| +- remote (class: java.lang.Object)
| +- remoteStatefulProxyFactory (proxy: $Proxy74 implements interface org.jboss.ejb3.ProxyFactory)

I have been trying to setup these beans to run as local just to see whether it make any difference. However, it has been slow since I am still learning to ropes of EJB 3.0 Session Beans.

Thanks again,

Henry
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9912
    
158

I am running Netbeans 5.5, JBoss 4.0.5GA & JDK1.6.0 on Windows XP platform.


Hmmmm.... I shouldn't have ignored this earlier Looks like this is an issue with JDK1.6 with JBoss. Here's a similar issue. The solution for this appears to be to use JDK5 instead of JDK6
Jack Bush
Ranch Hand

Joined: Oct 20, 2006
Posts: 235
Hi Jaikiran,

The recommendation from http://jboss.com/index.html?module=bb&op=viewtopic&t=98072&view=previous was correct.

By only running the Client program (EJB3ex512-Client)using SDK 1.5 solved this issue.

All session beans and other clients are still using SDK 1.6 without a problem.

Thanks again,

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NamingException: Could not dereference object - EJB 3.0 workbook ex05-2
 
Similar Threads
Question: ejb-ref with ejb3.0 and jboss-4.2.0.GA
Stateful Bean Naming Exception
Problem with context.lookup
Hi, why am I getting this exception on console
EJB Remote vs Local deployment....difference???