java.lang.NoClassDefFoundError
spiritualmechanic May 22, 2004 11:42 AMI'm not sure if this is an AOP issue or just a generic classloading issue, but I think I have my MBeans set up correctly.
Here's the error:
java.lang.NoClassDefFoundError at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:141) at org.jboss.resource.pool.JCPool.start(JCPool.java:65)
Which points to my MBean code:
public void start() throws Exception {
for (int i = 0; i < size; i++) {
v.add(Class.forName(poolType));
System.out.println("Added " + poolType);
}
used = new boolean[v.size()];
}And here's my jboss-service.xml:
<server> <classpath codebase="deploy" archives="jcaopool_java.jar" /> <mbean code="org.jboss.resource.pool.JCPool" name="jboss.jca:service=GenericPool"> <attribute name="PoolType">org.jboss.resource.pool.JavaClient</attribute> <attribute name="Size">4</attribute> </mbean> <depends>service=AspectDeployer</depends> </server>
Here's where the AOP comes in. I'm trying to intercept the construction of an object and return a JavaClient from my pooling MBean:
public class JavaClient {
/**
*
*/
public JavaClient() {
super();
}
public void close() {
}
}So here's my two Interceptors, first ConstructorInterceptor:
public Object invoke(Invocation invocation) throws Throwable {
try {
// Get JMX
MBeanServer server = MBeanServerLocator.locateJBoss();
ObjectName name = new ObjectName("jboss.jca:service=GenericPool");
String s = (String) server.getAttribute(name, "instance");
return s;
} finally {
System.out.println(">>> Leaving MethodInterceptor");
}
}And CloseInterceptor,
public Object invoke(Invocation invocation) throws Throwable {
try {
Object o = invocation.targetObject;
Object[] os = {o};
// Get JMX
MBeanServer server = MBeanServerLocator.locateJBoss();
ObjectName name = new ObjectName("jboss.jca:service=GenericPool");
String s = (String) server.invoke(name, "returnInstance", os, new String[] {Object.class.getName()});
return s;
} finally {
System.out.println(">>> Leaving CloseInterceptor");
}
}And finally my jboss-aop.xml:
<?xml version="1.0" encoding="UTF-8"?> <aop> <bind pointcut="execution(org.jboss.resource.pool.JavaClient->new())"> <interceptor class="org.jboss.resource.pool.ConstructorInterceptor"/> </bind> <bind pointcut="execution(public void org.jboss.resource.pool.JavaClient->close())"> <interceptor class="org.jboss.resource.pool.CloseInterceptor"/> </bind> </aop>
The thing is, the
points to the jar that has my already-AOPC'ed classes.
Is there something obvious I'm missing? Am I getting the deploy order wrong? I added the service=AspectDeployer to see if that was missing, but thinking about it, it shouldn't really matter if the deployer hasn't started if the classes are already pre-compiled.
Thanks for any ideas. I'm still using JB4DR2 and AOP beta1. Congrats on Beta2 as well. Very cool stuff!