0 Replies Latest reply on Apr 7, 2005 2:36 PM by drakonis

    Got a lot of exceptions when i tried my own

    drakonis

      Have the simplest example, a stateless bean TestBean:

      public class TestBean implements SessionBean {
       public void ejbCreate() throws CreateException {
       }
      
       public void setSessionContext(SessionContext sessionContext) throws EJBException {
       }
      
       public void ejbRemove() throws EJBException {
       }
      
       public void ejbActivate() throws EJBException {
       }
      
       public void ejbPassivate() throws EJBException {
       }
      
       public void sayHello()
       {
       System.err.println("Hello AOP world");
       }
      }
      


      All this gets packet into TestEjb.jar which explored looks like this
      META-INF which contains only EJB related descriptors but no jboss-aop.xml
      com/balamaci/proiect
      -TestHome.class
      -TestBean.class
      -RemoteTest.class
      -SimpleInterceptor.class

      The SimpleInterceptor class contains:
      public class SimpleInterceptor {
       public String getName() {
       return "SimpleInterceptor";
       }
      
       public Object invoke(Invocation invocation) throws Throwable
       {
       try
       {
       System.err.println("<<< Entering SimpleInterceptor");
       System.out.println("<<< Entering SimpleInterceptor");
       return invocation.invokeNext();
       }
       finally
       {
       System.err.println(">>> Leaving SimpleInterceptor");
       }
       }
      }
      

      got the client that just does
       try
       {
       Properties env = new Properties();
       env.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
       env.setProperty(Context.PROVIDER_URL, "localhost:1099");
       env.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
       Object obj = ctx.lookup("TestEJB");
       TestHome home = (TestHome) javax.rmi.PortableRemoteObject.narrow(obj,TestHome.class);
       RemoteTest test=home.create();
       test.sayHello();
       }
       catch(Exception e)
       {
       e.printStackTrace();
       }
      
      

      After starting a default instance of jboss i copy the jboss-aop.xml in the deploy directory. The jboss-aop.xml looks like this
      <?xml version="1.0"?>
      <aop>
       <bind pointcut="execution(public void com.balamaci.proiect.TestBean->sayHello())">
       <interceptor class="com.balamaci.proiect.SimpleInterceptor"/>
       </bind>
      </aop>
      

      After that i copy the TestEjb.jar in the deploy directory and after it says it's been deployed, i run the client.
      The ugly part is that instead of printing something nice it gets all of this:


      java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
      java.rmi.ServerError: Unexpected Error; nested exception is:
      java.lang.ExceptionInInitializerError
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:325)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:247)
      at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:223)
      at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:126)
      at org.jboss.invocation.jrmp.server.JRMPInvoker_Stub.invoke(Unknown Source)
      at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:118)
      at org.jboss.invocation.InvokerInterceptor.invokeInvoker(InvokerInterceptor.java:163)
      at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:103)
      at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
      at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
      at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
      at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:91)
      at $Proxy1.sayHello(Unknown Source)
      at com.balamaci.ejb.client.main(client.java:56)
      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:585)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
      Caused by: java.rmi.ServerError: Unexpected Error; nested exception is:
      java.lang.ExceptionInInitializerError
      at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:399)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:196)
      at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
      at org.jboss.ejb.Container.invoke(Container.java:870)
      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:585)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
      at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
      at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
      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:585)
      at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
      at sun.rmi.transport.Transport$1.run(Transport.java:153)
      at java.security.AccessController.doPrivileged(Native Method)
      at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
      at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      at java.lang.Thread.run(Thread.java:595)
      Caused by: java.lang.ExceptionInInitializerError
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
      at java.lang.Class.newInstance0(Class.java:350)
      at java.lang.Class.newInstance(Class.java:303)
      at org.jboss.ejb.Container.createBeanClassInstance(Container.java:585)
      at org.jboss.ejb.plugins.AbstractInstancePool.get(AbstractInstancePool.java:146)
      at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:80)
      at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:51)
      at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
      at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:105)
      at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:146)
      at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
      at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
      ... 25 more
      Caused by: java.lang.ClassCastException: com.balamaci.proiect.SimpleInterceptor
      at org.jboss.aop.advice.ScopedInterceptorFactory.create(ScopedInterceptorFactory.java:41)
      at org.jboss.aop.Advisor.createInterceptorChain(Advisor.java:494)
      at org.jboss.aop.Advisor.resolveMethodPointcut(Advisor.java:535)
      at org.jboss.aop.ClassAdvisor.createInterceptorChains(ClassAdvisor.java:454)
      at org.jboss.aop.ClassAdvisor$1.run(ClassAdvisor.java:237)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.jboss.aop.ClassAdvisor.attachClass(ClassAdvisor.java:209)
      at org.jboss.aop.AspectManager.getAdvisor(AspectManager.java:321)
      at com.balamaci.proiect.TestBean.(TestBean.java)
      ... 41 more


      The injboss example works fine though.
      Did someone else encounter this problem? Am i taking the wrong steps to deployment?
      Thanks!