-
1. Re: EJBDeployer Classloader
stephanenicoll Sep 18, 2003 2:08 AM (in response to joaocm)This question is not related to JMS, is it?
otherwise put your EJB Classe and your other class inside an EAR file and it will use the same classloader.
Regards,
Stephane -
2. Re: EJBDeployer Classloader
joaocm Sep 19, 2003 2:09 PM (in response to joaocm)The problem is that the class could not exists at the moment of my deployment.
Let me explain better the problem. Look at this snippet of code below:
String className = properties.getClassName();
ISomething something = (ISomething) Class.forName(className).newInstance();
something.doSomething();
The className variable is dynamic and could be changed in runtime and points even to a class that is defined outside my EAR or JAR.
This class in another JAR was loaded implementing the ISomething interface that was not loaded with the same classloader of my EAR or JAR that runs inside JBoss, so I have ClassCastException.
I have to use the same classloader for both ocasions... -
3. Re: EJBDeployer Classloader
adrian.brock Sep 19, 2003 5:54 PM (in response to joaocm)Just deploy ISomething in one place, e.g. put it in
a jar in server/default/lib
Regards,
Adrian -
4. Re: EJBDeployer Classloader
joaocm Sep 22, 2003 10:57 AM (in response to joaocm)Hi Adrian,
I had done that. The problem is that the classes that implements the ISometinhg aren't in the classpath initially, so I need to load the JAR (containng that classes) prior to execute a Class.forName().
I used the URLClassLoader to do this, and (of course) when I try to cast the class I got Class Cast Exception.
I need to load my JAR by the way of EJBDeployer classloader right ? My questiuon is , how can I do this ?
Other way is to create my own classloader and assign it to be the EJBdeployer classloader... What is better ? -
5. Re: EJBDeployer Classloader
adrian.brock Sep 22, 2003 2:45 PM (in response to joaocm)You can use the ClassPathExtension MBean to deploy a URL.
There is an example in the testsuite.
Regards,
Adrian -
6. Re: EJBDeployer Classloader
joaocm Sep 23, 2003 8:07 AM (in response to joaocm)Adrian,
I think that it will solve my problem, but I didn't found the MBean that you told (I'm using Jboss 3.04, but I tryed 3.2.1 too). Where is it ?
I haven't found the JBoss test that uses it too, if you point me to it I will be very grateful.
Thanks in advance ! -
7. Re: EJBDeployer Classloader
stephanenicoll Sep 23, 2003 8:22 AM (in response to joaocm)Check the CVS on sourceforge for testsuite
http://sf.net/projects/jboss
Regards,
Stephane -
8. Re: EJBDeployer Classloader
adrian.brock Sep 23, 2003 9:33 AM (in response to joaocm)
{url to some.jar}
Regards,
adrian -
9. Re: EJBDeployer Classloader
joaocm Sep 23, 2003 1:24 PM (in response to joaocm)Is there anyway to access it by RMIAdaptor ?
If I put the XML that you sent, I will be extending the classpath for a specified JAR, and I need to do this at runtime by code. -
10. Re: EJBDeployer Classloader
adrian.brock Sep 23, 2003 1:32 PM (in response to joaocm)The example in the testsuite does exactly that
getServer() returns an RMIAdaptor, an MBeanServer
will work just well (if you are not remote):
ObjectName extension;
public ClasspathExtensionUnitTestCase(String name)
{
super(name);
try
{
extension = new ObjectName("jboss.test:test=ClasspathTest,mbean=extension");
}
catch (Exception ignored)
{
}
}
public void testClasspathExtension() throws Exception
{
assertTrue("Shouldn't find the resource before deployment", findResource() == false);
getServer().createMBean("org.jboss.deployment.ClasspathExtension", extension);
try
{
getServer().setAttribute(extension, new Attribute("MetadataURL", getDeployURL("")));
getServer().invoke(extension, "create", new Object[0], new String[0]);
getServer().invoke(extension, "start", new Object[0], new String[0]);
assertTrue("Should find the resource after deployment", findResource());
}
finally
{
getServer().invoke(extension, "stop", new Object[0], new String[0]);
getServer().invoke(extension, "destroy", new Object[0], new String[0]);
getServer().unregisterMBean(extension);
}
assertTrue("Shouldn't find the resource after undeployment", findResource() == false);
}
Regards,
Adrian -
11. Re: EJBDeployer Classloader
joaocm Sep 23, 2003 1:37 PM (in response to joaocm)Adrian,
If I call the MainDeployer MBEAN passing the JAR URL as the parameter it will be in the classpath right ?
So what's the diference between do this or call the ClassPathExtension MBEAN ?
Thanks again,
Joao -
12. Re: EJBDeployer Classloader
adrian.brock Sep 23, 2003 4:39 PM (in response to joaocm)None if the jar does not contain any xml files in META-INF
or there are subdeployments.
Both add a URL to the classpath.
The MainDeployer first checks for deployment descriptors
and also looks for other deployments inside the jar/directory.
Regards,
Adrian