Hello,
I'm trying to get information from my application, deployed on Glassfish v2.1, using custom Mbean.
On my application, I have an interface :
package com.polop.application;
import javax.ejb.Remote;
@Remote
public interface CoreApplicationRemote {
String getDescription();
}
and its corresponding implementation :
package com.polop.application;
import javax.ejb.Stateless;
@Stateless(mappedName="MyApplication")
public class CoreApplicationBean implements CoreApplicationRemote {
public String getDescription() {
return "This is my application";
}
}
My application deploys correctly on Glassfish.
If I execute the command : asadmin list-jndi-entities, I can see :
com.polop.application.CoreApplicationRemote : javax.naming.Reference
Under Eclipse, I created a java projet for my MBean :
the interface of my MBean :
package com.polop.utils;
public interface MyAppMgtMBean {
String getDescription();
}
and its implementation :
package com.polop.utils;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.polop.utils.CoreApplicationRemote;
public class MyAppMgt implements MyAppMgtMBean {
public String getDescription() {
try {
InitialContext ctx = new InitialContext();
return (CoreApplicationRemote) ctx.lookup("MyApplication");
} catch (NamingException e) {
return "Error !!!";
}
}
}
and same interface CoreApplicationRemote as in application, required to get result from lookup :
package com.polop.application;
public interface CoreApplicationRemote {
String getDescription();
}
If I add a Junit test method in MyAppMgt, that calls getDescription(), it works (i.e. lookup works fine and I get the description result).
Then I copy MyAppMgt, MyAppMgtMBean, CoreApplicationRemote in /glassfish/domains/domain1/applications/mbeans/ and exec command : asadmin create-mbean com.polop.utils.MyAppMgt
The command executes with success.
Then I launch Jconsole. I can see a new entry : user > com.polop.utils.MyAppMgt > com.polop.utils.MyAppMgt > server > Attributes : Description
But the value of Description is "Error !!!"
Then I looked in server.log of Glassfish and see :
javax.naming.NamingException: ejb ref resolution error for remote business interface com.polop.application.CoreApplicationRemote [Root exception is java.lang.ClassNotFoundException: com.polop.application.CoreApplicationRemote]
at com.sun.ejb.EJBUtils.lookupRemote30BusinessObject(EJBUtils.java:425)
at com.sun.ejb.containers.RemoteBusinessObjectFactory.getObjectInstance(RemoteBusinessObjectFactory.java:74)
at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
...
I tried to add following jars to /glassfish/domains/domain1/lib :
appserv-deployment-client.jar
appserv-ext.jar
appserv-rt.jar
javaee.jar
then Glassfish restart, MBean unregistred then registred but without more success.
I spend a lot of time on forums to search for similar problem but no solution found.
I bet for a classpath problem but not sure.
So if someone can help me...
Thanks in advance.
[Message sent by forum member 'bi30']
http://forums.java.net/jive/thread.jspa?messageID=396937