Hi,
I am receiving the following exception when I try and access an EJB from a
custom service (MBean):
javax.naming.CommunicationException [Root exception is
java.lang.ClassNotFoundException: skinkers.ejb.log.LogServicesHome]
I have tried placing the classes for the ejb in the lib/ext directory and
this fixes the problems, but the auto-deploy no longer works for the the
ejb.
Scanning the Jboss-user lists I came across someone with exactly the same
problem (reference email is at bottom). The problem is I can't seem to
implement the solution.
> You have to place the ejb interfaces and associated classes into a
> jar and load it with a URLClassLoader created by your mbean to isolate
> the mbean's use of the ejb from the deployer so that redeployment works.
Ok, I have created the jar with the interfaces and associated classes.
Use the URLClassLoader to load the jar - here is my code:
ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
try {
// ClassLoader Stuff
URL urlList[] = { new File("/opt/jboss-tomcat/jboss/mbean/shared.jar").toURL() };
ClassLoader newCl = new URLClassLoader(urlList,oldCl);
Thread.currentThread().setContextClassLoader(newCl);
// EJB Stuff
InitialContext jndiContext = new InitialContext();
Object ref = jndiContext.lookup(JNDI_LOGSERVICES_EJB);
LogServicesHome logServicesHome = (LogServicesHome)
javax.rmi.PortableRemoteObject.narrow(ref, LogServicesHome.class);
LogServices logServices = logServicesHome.create();
logServices.uploadLogsToMessageServer();
} catch (Exception e) {
e.printStackTrace();
} finally {
Thread.currentTread().setContextClassLoader(oldCl);
}
The problem is now I get the following Error
java.lang.NoClassDefFoundError: skinkers.ejb.log.LogServicesHome
This error is being thrown on the PortableRemoteObject.narrow line.
Calling a loadClass("skinkers.ejb.log.LogServicesHome") on the new
ClassLoader seems to work fine and doesn't throw any exceptions. So it
seems the class can actually be found.
I am using Linux kernal 2.4, JDK 1.3.1, Jboss 2.4.
Any ideas on what I am doing wrong??
Thanks in advance
Tristan.
On Sun, 24 Jun 2001, Scott M Stark wrote:
> You have to place the ejb interfaces and associated classes into a
> jar and load it with a URLClassLoader created by your mbean to isolate
> the mbean's use of the ejb from the deployer so that redeployment works.
>
> ----- Original Message -----
> From: "Victor M." <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, June 24, 2001 12:02 AM
> Subject: [JBoss-user] Accessing EJBs from a custom service.
>
>
> > Hello,
> >
> > I need to add a custom service (MBean). This MBean must be able to access
> > (instanciate) the EJBs which are hosted on JBoss server itself.
> > My MBean service starts correctly, but when attempting to instanciate an EJB
> > (the example "interest" bean) it fails with exception:
> >
> > javax.naming.CommunicationException. Root exception is [Default]
> > java.lang.ClassNotFoundException: com.web_tomorrow.interest.InterestHome
> > [Default] at javax.management.loading.MLet.findClass(MLet.java:800
> >
> >
> > Instanciating a bean from a "normal" Java client works perfectly.
> > Also, when I add the interest EJB to JBOSS_CLASSPATH in run.bat, the bean
> > can be accessed from the service. However, in this case, the server must be
> > restarted when I deploy new beans and want them to be accessible from the
> > service.(no "hot deploy").
> >
> > My questions are:
> > 1) Is it possible to access the hosted EJBs from a service (MBean)
> > without putting it explicitly on the classpath and losing "hot deploy"?
> > 2) If yes, how should I do it?
> >
> > Any help is greatly appreciated.
> > Thank you,
> >
> > Victor.
> >
>
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
>
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user