users@glassfish.java.net

ClassNotFound JMX MBean calling remote session bean

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 Feb 2007 02:03:48 PST

Hello,

I'm having problem in the following situation:

My applicaiton consists of one EAR with one EJB, one WEB and one Application Client modules. There is a stateless EJB with remote business interface. When I call it's business method from Application Client it works fine. A piece of code in the client class looks as follows:

public static void main(String[] args) {
    try {
        TestHelloEJBRemote vRemoteBean =
            (TestHelloEJBRemote)
            (new InitialContext()).lookup(TestHelloEJBRemote.class.getName());
            try {
                System.out.println("Answer from Remote Bean: ["
                       + vRemoteBean.sayHello() + "]");
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println("Exception in business method\n"
                       + ex.getMessage() );
            }
        } catch (NamingException ex) {
            ex.printStackTrace();
            System.err.println("Naming Exception\n" + ex.getMessage() );
        }
}


Then I created a simple JMX MBean and packaged it into the same EJB module within EAR. Also I have a servlet, which registers the above MBean in it's init() method and deregisters it in destroy(). It works fine as well, I'm able to access MBean via JConsole.

Within MBean implementation class I have a method where I'm trying to lookup the remote interface of my session bean and call it's business method. Here is my code:

try {
    InitialContext vCtx = new InitialContext();
    TestHelloEJBRemote vRemoteBean = (TestHelloEJBRemote)
        vCtx.lookup(TestHelloEJBRemote.class.getName());
    try {
        vRet = vRemoteBean.sayHello();
        System.out.println("Answer from Remote Bean: [" + vRet + "]");
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println("Exception in business method\n" + ex.getMessage() );
    }
} catch (NamingException ex) {
    ex.printStackTrace();
    System.err.println("Naming Exception\n" + ex.getMessage() );
}

And I try to do it via JConsole. Here it fails with the stack trace attached below.

It seems that JNDI lookup succeeds, but the class couldn't be loaded.

Initially I had much more complicated application, but it didn't work as well and thus I had to build this simplyfied example. So, I could also post my source code if needed.

My glassfish version now is xxx, but with the version xxx, downloaded directly from Sun's download page I had absolutely the same problem.

I hope that this is not a bug, but unfortunately I'm not experienced in J2EE to investigate it further on my own. So, any help would be highly appreciated.

Regards
omec

---------------------------------
javax.naming.NamingException: ejb ref resolution error for remote business interfacetest.hello.TestHelloEJBRemote [Root exception is java.lang.ClassNotFoundException: test.hello.TestHelloEJBRemote]
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:348)
        at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:61)
        at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
        at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:320)
        at javax.naming.InitialContext.lookup(InitialContext.java:351)
        at test.hello.mbean.TestHello.sayHello(TestHello.java:36)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.jmx.mbeanserver.StandardMetaDataImpl.invoke(StandardMetaDataImpl.java:414)
        at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220)
        at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815)
        at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784)
        at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:77)
        at $Proxy1.invoke(Unknown Source)
        at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:297)
        at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1408)
        at javax.management.remote.rmi.RMIConnectionImpl.access$100(RMIConnectionImpl.java:81)
        at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1245)
        at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1341)
        at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:782)
        at sun.reflect.GeneratedMethodAccessor100.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
        at sun.rmi.transport.Transport$1.run(Transport.java:153)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
        at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
        at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
        at java.lang.Thread.run(Thread.java:595)
Caused by: java.lang.ClassNotFoundException: test.hello.TestHelloEJBRemote
        at com.sun.enterprise.util.ConnectorClassLoader.loadClass(ConnectorClassLoader.java:212)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at com.sun.ejb.EJBUtils.getBusinessIntfClassLoader(EJBUtils.java:566)
        at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:318)
        ... 34 more
----------------------
[Message sent by forum member 'omec' (omec)]

http://forums.java.net/jive/thread.jspa?messageID=202217