Discussion:
[jboss-user] [EJB3] - Re: lookup for remote bean - failure (only from eclipse)
JN JNC
2013-01-23 09:31:04 UTC
Permalink
JN JNC [https://community.jboss.org/people/jnjnc] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/793718#793718

--------------------------------------------------------------
Hi,

I got exactly same issue when running same kind of remote EJB lookup from a unit test or from a simple java client with classpath corretcly setup to include JBOSS_HOME/client/jbossall-client.jar.






##
  10:24:11,528 INFO [ServerImpl] Starting JBoss (Microcontainer)...
10:24:11,528 INFO [ServerImpl] Release ID: JBoss [The Oracle] 5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)


**public** **static** **void** main(String[] args) **throws** NamingException {

Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.URL_PKG_PREFIXES, "org.jboss.naming.client");
properties.put(Context.PROVIDER_URL, "localhost:1099");
context = new InitialContext(properties);
Object bean = context.lookup("my-app-ear-name/myBean/remote");

}

Exception in thread "main" javax.naming.NamingException: Could not dereference object [Root exception is java.lang.RuntimeException: ...
        at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1504)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:822)
        at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
        at javax.naming.InitialContext.lookup(InitialContext.java:392)
....
Caused by: java.lang.RuntimeException: Exception while trying to locate proxy factory in JNDI, at key ProxyFactory/....
        at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getProxyFactoryFromJNDI(ProxyObjectFactory.java:
        at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:157)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at org.jnp.interfaces.NamingContext.getObjectInstance(NamingContext.java:1479)
        at org.jnp.interfaces.NamingContext.getObjectInstanceWrapFailure(NamingContext.java:1496)
        ... 4 more
Caused by: javax.naming.NameNotFoundException: ProxyFactory not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
        at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
        at org.jnp.server.NamingServer.lookup(NamingServer.java:396)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

A wrong classpath setup would give

Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [
aces.NamingContextFactory]
        at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:657)
        at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
        at javax.naming.InitialContext.init(InitialContext.java:223)
        at javax.naming.InitialContext.<init>(InitialContext.java:197)
        at com.temenos.tafj.tools.jmsinjector.EJBRemoteInvoker.main(EJBRemoteInvoker.java:23)
Caused by: java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory

Do you have any suggestion ?

Thanks and regards.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/793718#793718]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Wolfgang Knauf
2013-01-25 16:07:33 UTC
Permalink
Wolfgang Knauf [https://community.jboss.org/people/WolfgangKnauf] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/794336#794336

--------------------------------------------------------------
Hi,

as far as I know, the "PROVIDER_URL" should be "jnp://localhost:1099" for JBoss 5.

The rest should work.

Did you check what is bound in JNDI using JNDIView? https://community.jboss.org/docs/DOC-9583 https://community.jboss.org/wiki/DisplayTheJDNITreeWithTheJMXConsole

If this does not help, please provide more details about your application.

Best regards

Wolfgang
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/794336#794336]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
JN JNC
2013-01-25 16:47:16 UTC
Permalink
JN JNC [https://community.jboss.org/people/jnjnc] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/794349#794349

--------------------------------------------------------------
Hi,

Thanks for your answer.

You  are right I did a wrong copy of my provider URL, but it's not the issue.
My EJB seems to be found as if I make a mistake in the name in the lookup I will get a "NameNotFoundException: bean not bound".

This is a simple ear file containing 2 jars file one containing EJB calling business code and other one containing MDB to receive message and call the EJBs.
It works fine in JBoss 5.1, I can make it work when accessing the application through my web client application or when sending a message to the MDB within my unit test after a lookup to the connection factory and destination queue.

Note that this EJB I'm lookup test is working fine with Jboss 4.2.3 and related client libraries (same ear file except header in jboss.xml in my jar files).

I'm really wondering about a configuration that I could have miss to do a remote invocation with JBoss 5.1 client libraries.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/794349#794349]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Wolfgang Knauf
2013-01-27 19:36:08 UTC
Permalink
Wolfgang Knauf [https://community.jboss.org/people/WolfgangKnauf] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/794472#794472

--------------------------------------------------------------
Hi,

I see that you posted the question also here: https://community.jboss.org/message/531485#531485 https://community.jboss.org/message/531485

There are two things that come to my mind:
1) some wrong jboss client JAR, which is not matching the server version, is referenced
2) you wrote that you have two jar files, one with EJBs and the other with MDBs. Both are bundled in an EAR file, are they? Maybe this causes trouble. Could you try to combine those two files?

And maybe it is a strange configuration issue. So post as many details (code/config snippets) as possible.

I found another thread with the same error message. Maybe the logging hints in this thread help further: https://community.jboss.org/message/410897#410897 https://community.jboss.org/message/410897

Best regards

Wolfgang
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/794472#794472]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
JN JNC
2013-07-10 09:43:58 UTC
Permalink
JN JNC [https://community.jboss.org/people/jnjnc] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/827279#827279

--------------------------------------------------------------
Hi,

Sorry for the late, I did some more tests. I only have in my test classpath jbossall-client.jar coming from the server I used.

Here is my server log regarding my EJB deployment:

2013-07-10 09:19:01,940 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) Created KernelDeployment for: MY_JAR.jar
2013-07-10 09:19:01,941 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) installing bean: jboss.j2ee:ear=MY_EAR.ear,jar=MY_JAR.jar,name=CallAtProcessingBean,service=EJB3
2013-07-10 09:19:01,941 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)   with dependencies:
2013-07-10 09:19:01,941 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)   and demands:
2013-07-10 09:19:01,941 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           jboss.ejb:service=EJBTimerService
2013-07-10 09:19:01,942 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)   and supplies:
2013-07-10 09:19:01,942 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           jndi:MY_EAR/CallAtProcessingBean/local-com.mycomp.myorg.sb.OFSProcessingBeanLocal
2013-07-10 09:19:01,942 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           Class:com.mycomp.myorg.sb.OFSProcessingBeanRemote
2013-07-10 09:19:01,942 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           jndi:MY_EAR/CallAtProcessingBean/local
2013-07-10 09:19:01,942 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           Class:com.mycomp.myorg.sb.OFSProcessingBeanLocal
2013-07-10 09:19:01,943 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           jndi:MY_EAR/CallAtProcessingBean/remote
2013-07-10 09:19:01,943 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main)           jndi:MY_EAR/CallAtProcessingBean/remote-com.mycomp.myorg.sb.OFSProcessingBeanRemote
2013-07-10 09:19:01,943 INFO  [org.jboss.ejb3.deployers.JBossASKernel] (main) Added bean(jboss.j2ee:ear=MY_EAR.ear,jar=MY_JAR.jar,name=CallAtProcessingBean,service=EJB3) to KernelDeployment of: MY_JAR.jar

I don't know whether the mapping is correct or not, I supposed it is as it works when invoked from the server, but I could see from that trace that the sequence between local JNDI name and class name is "weird".

As I said as this test is working like a charm in 4.2, thus given the stacktrace:

Caused by: javax.naming.NameNotFoundException: ProxyFactory not bound
        at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)

I tried to replace the jnpclient.jar with former version with no luck.

Then given the stacktrace

Caused by: java.lang.RuntimeException: Exception while trying to locate proxy factory in JNDI, at key ProxyFactory/....
        at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getProxyFactoryFromJNDI(ProxyObjectFactory.java:
        at org.jboss.ejb3.proxy.impl.objectfactory.ProxyObjectFactory.getObjectInstance(ProxyObjectFactory.java:157)

I get rid of *jboss-ejb3-proxy-impl-client.jar* in my client libraries.

And my test is going a bit further, it's not failing anymore but second assert fails.

        Object object = initialContext.lookup("MY_EAR/CallAtProcessingBean/remote");
        assertNotNull(object);
        assertTrue(object instanceof OFSProcessingBeanRemote);

Here is a debug view of "object", thus it seems mapping is correct.

Reference Class Name: Proxy for: com.mycomp.myorg.sb.OFSProcessingBeanRemote
Type: ProxyFactoryKey
Content: ProxyFactory/MY_EAR/CallAtProcessingBean/MY_EAR/CallAtProcessingBean/remote
Type: EJB Container Name
Content: jboss.j2ee:ear=MY_EAR.ear,jar=MY_JAR.jar,name=CallAtProcessingBean,service=EJB3
Type: Proxy Factory is Local
Content: false
Type: Remote Business Interface
Content: com.mycomp.myorg.sb.OFSProcessingBeanRemote
Type: Remoting Host URL
Content: socket://127.0.0.1:3873/

If I try to do the cast to my type I got, which I guess is expected without the proxy jar.

java.lang.ClassCastException: javax.naming.Reference cannot be cast to com.mycomp.myorg.sb.CallAtProcessingBeanRemote

Any thought about that ?

Best regards,
Jean-Noel
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827279#827279]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Wolfgang Knauf
2013-07-11 20:21:56 UTC
Permalink
Wolfgang Knauf [https://community.jboss.org/people/WolfgangKnauf] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/827633#827633

--------------------------------------------------------------
Hi Jean-Noel,

sorry, I have no idea.

1) How do you start the simple app/unit test? Do you use Eclipse/Maven?

2) Is there any chance to post the EAR file?

3) could you test it with JBoss 7/8 (WildFly)?

Best regards

Wolfgang
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827633#827633]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
JN JNC
2013-07-12 10:39:05 UTC
Permalink
JN JNC [https://community.jboss.org/people/jnjnc] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/827710#827710

--------------------------------------------------------------
Thanks for your prompt answer Wolfgang.

Good news today, my test is working in 5.2. I didn't know that we were using this version.

The test is both failing in 5.1 within eclipse and from a maven build.

I will try to build a very simple ear file as soon as I have a chance.

But I think something must have been fixed between 5.1 and 5.2.

Best regards,
Jean-Noel
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827710#827710]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Wolfgang Knauf
2013-07-12 19:53:16 UTC
Permalink
Wolfgang Knauf [https://community.jboss.org/people/WolfgangKnauf] created the discussion

"Re: lookup for remote bean - failure (only from eclipse)"

To view the discussion, visit: https://community.jboss.org/message/827816#827816

--------------------------------------------------------------
Well, if it works now I don't think there is much need for further research ;-).

Best regards

Wolfgang
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/827816#827816]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]
Loading...