5 Replies Latest reply on Apr 1, 2004 5:28 PM by Scott Stark

    Writing my own Interceptor - cannot deploy

    David Copeland Newbie

      Java 1.4.2
      JBoss 3.2.3
      Linux (RH9)

      I'm writing an Interceptor. As a first step, I basically copied the LogInterceptor's implementation. I put the class in jboss' classpath (via run.conf). I put a reference to the classname in standardjboss.xml, right after the stanza reference LogInterceptor.

      When I start jboss I get massive ClassNotFoundExceptions

      Unexpected error during load of: DaveInterceptor, msg=org/jboss/ejb/plugins/AbstractInterceptor

      and then a huge stack trace.

      Now, this class is in one of the jars inside the server's lib directory. However, the Service class, which AbstractInterceptor implements was not. Going for brute force, I put all the jboss jars in the server's lib directory, and the results were the same.

      I must be missing something about how to deploy a custom interceptor. It is very confusing as my interceptor is basically a simplified version of one that IS being deployed properly (LogInterceptor).

      I have the jboss book and it has about 2 paragraphs on this and that's it. Searches on the web reveal nothing. I found 1 post here on this exact topic with no replies.

      Can anyone help?

        • 1. Re: Writing my own Interceptor - cannot deploy
          Juha Lindfors Master

          just put it into a jar and into the config/lib directory

          • 2. Re: Writing my own Interceptor - cannot deploy
            David Copeland Newbie

            Unless I totally misunderstood you, that didn't work. Here's what I did:

            put my class in a JAR file.
            Put that jar file in $JBOSS_HOME/server/default/lib (I'm using the defualt server)
            restart server

            I get the same error message.

            Then, I move the jar into $JBOSS_HOME/lib
            I then get the error:

            No classloader found for <<my class>>

            Seems that putting it in $JBOSS_HOME/server/default/lib is more correct, because it can at least begin to load my class. Recall, the class it seems unable to find is not my class, but org.jboss.ejb.plugins.AbstractInterceptor (or some class it implements)

            Is there anything I can do to get some debug information or an error message?

            • 3. Re: Writing my own Interceptor - cannot deploy
              Adrian Brock Master

              Post some details. e.g. the full stacktrace

              This is a "It does not work post", a single line error message without context is useless.

              My guess is that you've added the interceptor class to the classpath.
              What other changes have you made to the configuration?

              Regards,
              Adrian

              • 4. Re: Writing my own Interceptor - cannot deploy
                David Copeland Newbie

                OK, I didn't include the details hoping it was an obvious mistake. Stacktrace is below.

                server/default/standardjboss.xml contains the default stuff, except for the following stanza (to which I added one line):

                 <container-configuration>
                 <container-name>Standard Stateless SessionBean</container-name>
                 <call-logging>false</call-logging>
                 <invoker-proxy-binding-name>stateless-rmi-invoker</invoker-proxy-binding-name>
                 <container-interceptors>
                 <interceptor>org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor</interceptor>
                 <interceptor>org.jboss.ejb.plugins.LogInterceptor</interceptor>
                 <interceptor>org.jboss.ejb.plugins.SecurityInterceptor</interceptor>
                 <interceptor>DaveInterceptor</interceptor>
                 <!-- CMT -->
                 <interceptor transaction="Container">org.jboss.ejb.plugins.TxInterceptorCMT</interceptor>
                 <interceptor transaction="Container" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
                 <interceptor transaction="Container">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
                 <!-- BMT -->
                 <interceptor transaction="Bean">org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor</interceptor>
                 <interceptor transaction="Bean">org.jboss.ejb.plugins.TxInterceptorBMT</interceptor>
                 <interceptor transaction="Bean" metricsEnabled="true">org.jboss.ejb.plugins.MetricsInterceptor</interceptor>
                 <interceptor>org.jboss.resource.connectionmanager.CachedConnectionInterceptor</interceptor>
                 </container-interceptors>
                 <instance-pool>org.jboss.ejb.plugins.StatelessSessionInstancePool</instance-pool>
                 <instance-cache></instance-cache>
                 <persistence-manager></persistence-manager>
                 <container-pool-conf>
                 <MaximumSize>100</MaximumSize>
                 </container-pool-conf>
                 </container-configuration>
                

                All other stanzas are the same. My Interceptor's source looks like:

                
                import java.io.*;
                import java.rmi.*;
                import java.util.*;
                
                import javax.ejb.*;
                import javax.transaction.*;
                
                import org.jboss.ejb.*;
                import org.jboss.ejb.plugins.*;
                import org.jboss.invocation.*;
                import org.jboss.metadata.*;
                
                import org.jboss.tm.*;
                
                public class DaveInterceptor extends AbstractInterceptor
                {
                 public void create()
                 throws Exception
                 {
                 super.start();
                 }
                
                 public Object invoke(Invocation invocation)
                 throws Exception
                 {
                 String methodName;
                 if (invocation.getMethod() != null)
                 {
                 methodName = invocation.getMethod().getName();
                 }
                 else
                 {
                 methodName = "<no method>";
                 }
                 StringBuffer argsName = new StringBuffer();
                
                 Object []args = invocation.getArguments();
                 if (args != null)
                 {
                 argsName.append(" ");
                 for (int i=0;i<args.length;i++)
                 {
                 argsName.append(args[ i ].getClass().getName());
                 argsName.append(",");
                 }
                 argsName.setLength(argsName.length() - 1);
                 }
                 else
                 {
                 argsName.append("NOARGS");
                 }
                 log.error(methodName + " being called with " + argsName.toString());
                 Object returnValue = getNext().invoke(invocation);
                 log.error(methodName + " returning " + returnValue == null ? "null" : returnValue.getClass().getName());
                 return returnValue;
                 }
                }
                


                I have tried putting this in the run.conf JBOSS classpath. I also tried removing it from that and putting it in a jar file and putting that jarfile in the server/default/lib directory. Both had the same result (which is the stacktrace below). This exception occurs for every Session EJB that is being deployed. I am deploying all session ejbs inside one jar file which gets put into server/default/deploy. These exceptions occur during startup of JBoss.

                The only other configuration change I made was to add my Informix JDBC driver to the run.conf JBOSS classpath. Everything else is as it was when installed.

                Stacktrace:

                2004-03-16 17:09:39,526 INFO [org.jboss.ejb.EjbModule] Deploying AgencySession
                2004-03-16 17:09:39,540 WARN [org.jboss.ejb.EjbModule] Could not load the DaveInterceptor interceptor for this container
                java.lang.ClassNotFoundException: Unexpected error during load of: DaveInterceptor, msg=org/jboss/ejb/plugins/AbstractInterceptor
                 at org.jboss.mx.loading.UnifiedClassLoader3.loadClassImpl(UnifiedClassLoader3.java:206)
                 at org.jboss.mx.loading.UnifiedClassLoader3.loadClass(UnifiedClassLoader3.java:123)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                 at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:77)
                 at org.jboss.mx.loading.LoaderRepositoryClassLoader.loadClass(LoaderRepositoryClassLoader.java:78)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                 at org.jboss.util.loading.DelegatingClassLoader.loadClass(DelegatingClassLoader.java:77)
                 at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
                 at org.jboss.ejb.EjbModule.addInterceptors(EjbModule.java:811)
                 at org.jboss.ejb.EjbModule.initializeContainer(EjbModule.java:698)
                 at org.jboss.ejb.EjbModule.createStatelessSessionContainer(EjbModule.java:502)
                 at org.jboss.ejb.EjbModule.createContainer(EjbModule.java:457)
                 at org.jboss.ejb.EjbModule.createService(EjbModule.java:280)
                 at org.jboss.system.ServiceMBeanSupport.create(ServiceMBeanSupport.java:158)
                 at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:324)
                 at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                 at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                 at $Proxy14.create(Unknown Source)
                 at org.jboss.system.ServiceController.create(ServiceController.java:310)
                 at org.jboss.system.ServiceController.create(ServiceController.java:243)
                 at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:324)
                 at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                 at $Proxy12.create(Unknown Source)
                 at org.jboss.ejb.EJBDeployer.create(EJBDeployer.java:523)
                 at org.jboss.deployment.MainDeployer.create(MainDeployer.java:786)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:641)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                 at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:324)
                 at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                 at $Proxy6.deploy(Unknown Source)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:302)
                 at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:476)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:201)
                 at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:274)
                 at org.jboss.system.ServiceMBeanSupport.start(ServiceMBeanSupport.java:192)
                 at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:324)
                 at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                 at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:976)
                 at $Proxy0.start(Unknown Source)
                 at org.jboss.system.ServiceController.start(ServiceController.java:394)
                 at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
                 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                 at java.lang.reflect.Method.invoke(Method.java:324)
                 at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                 at $Proxy4.start(Unknown Source)
                 at org.jboss.deployment.SARDeployer.start(SARDeployer.java:226)
                 at org.jboss.deployment.MainDeployer.start(MainDeployer.java:832)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:642)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:605)
                 at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:589)
                 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:324)
                 at org.jboss.mx.capability.ReflectedMBeanDispatcher.invoke(ReflectedMBeanDispatcher.java:284)
                 at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:546)
                 at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:177)
                 at $Proxy5.deploy(Unknown Source)
                 at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:384)
                 at org.jboss.system.server.ServerImpl.start(ServerImpl.java:291)
                 at org.jboss.Main.boot(Main.java:150)
                 at org.jboss.Main$1.run(Main.java:395)
                 at java.lang.Thread.run(Thread.java:534)
                


                • 5. Re: Writing my own Interceptor - cannot deploy
                  Scott Stark Master

                  The jar with the interceptor cannot be on the system classpath. Almost never should classes used by jboss be on the system classpath. When deployed in the server/default/lib you must have still had it on the system classpath.