4 Replies Latest reply on Apr 16, 2007 7:08 PM by bytor99999

    Doing a lookup for ProfileService

      So we have a cactus test that is running an object that gets an InitialContext, and does a lookup for ProfileService. But it gives a classcast exception when casting to ProfileService. It appears the object in the JNDI tree is of type AOPProxy.

      I had tried a test of deploying an EJB that also does a lookup and had to include a number of jar files to get past that, but in the end it has a ClassDefNotFoundError looking for a SecurityContext class.

      <error message="AOPProxy$0" type="org.apache.cactus.internal.client.ServletExceptionWrapper">
      java.lang.ClassCastException: AOPProxy$0
       at org.jboss.on.plugins.jboss.ProfileJBossServerComponent.initialize(ProfileJBossServerComponent.java:70)
       at org.jboss.on.plugins.jboss.JBossServerTest.testInitialize(JBossServerTest.java:32)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at org.apache.cactus.internal.AbstractCactusTestCase.runBareServer(AbstractCactusTestCase.java:153)
       at org.apache.cactus.internal.server.AbstractWebTestCaller.doTest(AbstractWebTestCaller.java:119)
       at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody0(AbstractWebTestController.java:93)
       at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest_aroundBody1$advice(AbstractWebTestController.java:224)
       at org.apache.cactus.internal.server.AbstractWebTestController.handleRequest(AbstractWebTestController.java)
       at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody2(ServletTestRedirector.java:101)
       at org.apache.cactus.server.ServletTestRedirector.doPost_aroundBody3$advice(ServletTestRedirector.java:224)
       at org.apache.cactus.server.ServletTestRedirector.doPost(ServletTestRedirector.java)
       at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody0(ServletTestRedirector.java:72)
       at org.apache.cactus.server.ServletTestRedirector.doGet_aroundBody1$advice(ServletTestRedirector.java:224)
       at org.apache.cactus.server.ServletTestRedirector.doGet(ServletTestRedirector.java)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:231)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:174)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:86)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:238)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:595)
      




      Here is the code

       InitialContext initialContext = null;
       try
       {
       initialContext = new InitialContext();
       }
       catch (NamingException e)
       {
       e.printStackTrace();
       }
      
       try
       {
       profileService = (ProfileService)initialContext.lookup("ProfileService");
       }
       catch (NamingException e)
       {
       e.printStackTrace();
       }
      


      Here is the exception I got in my EJB test

      Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/security/SecurityContext
       at org.jboss.aspects.security.SecurityClientInterceptor.invoke(SecurityClientInterceptor.java:47)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.remoting.IsLocalInterceptor.invoke(IsLocalInterceptor.java:72)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
       at org.jboss.ejb3.stateless.StatelessRemoteProxy.invoke(StatelessRemoteProxy.java:103)
       at $Proxy0.testProfileService(Unknown Source)
       at org.jboss.ejb.MainTestClass.main(MainTestClass.java:20)
       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:90)
      


      I am guessing that there is some security behind getting the ProfileService, which makes sense since we wouldn't want any Joe Programmer/Hacker creating an app that deletes all the deployments in an App Server.

      But what do you need to include in your apps to get the ProfileService.

      Thanks

      Mark Spritzler

        • 1. Re: Doing a lookup for ProfileService
          starksm64

          This is on trunk or the Beta2? The SecurityClientInterceptor should not have a reference to the SecurityContext in Beta2 so I'm guessing its trunk. I can't even build trunk currently due to the repository.jboss.com move.

          In terms of the CCE, you need to dump out the CodeSource for the ProfileService.class in your app and all of the interfaces from the proxy you obtain on lookup. Typically there are multiple sources of an interface to see this problem.

          • 2. Re: Doing a lookup for ProfileService

            I built trunk on Friday.

            Actually, I get it both on trunk and beta2.

            So for an app to access the ProfileService, are there a particular set of jars that need to be included? If so, which ones?


            Mark

            • 3. Re: Doing a lookup for ProfileService

              I found the jboss-managed and jboss-server jars in our war file's lib dir. I am removing it now and retesting.

              Mark

              • 4. Re: Doing a lookup for ProfileService

                Yep, thanks Scott, it was multiple of the same class being loaded. It wasn't my fault, really. :)

                Darn Maven pom copying those jars to the build dir. Changed the pom to provided for those jars.

                Mark