4 Replies Latest reply: Jun 15, 2012 3:39 AM by Bland RSS

    Glassfish can't find JAX-WS handler classes

    asarkar
      Hi,
      Created a JAX-WS Stateless EJB3 Endpoint, configured JAX-WS handlers using a handler chain XML, deployed on Glassfish 3.1.2. Glassfish won't find any of the 3 handler classes. I've verified and reverified that the handler XML uses the correct package and class name. The first two of three handlers are part of the project while the third one is in a jar in the lib, so obviously they are all on the class path.
      Any help is greatly appreciated. Google searches showed that people had similar issue before but no one seemed to have found a solution (or if they did they did not post it back).

      Also posted [http://www.java.net/forum/topic/glassfish/metro-and-jaxb/glassfish-cant-find-jax-ws-handler-classes]
      [#|2012-04-03T21:59:11.769-0400|SEVERE|glassfish3.1.2|javax.enterprise.webservices.org.glassfish.webservices|_ThreadID=16;_ThreadName=Thread-3;|Unable to load handler class edu.certification.abhijitsarkar.ocewsd.jaxws.ejb.webservice.handler.ProgrammaticAuthenticationHandler
                     
      java.lang.ClassNotFoundException: edu.certification.abhijitsarkar.ocewsd.jaxws.ejb.webservice.handler.ProgrammaticAuthenticationHandler
                     
           at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1509)
           at org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
           at java.lang.Class.forName0(Native Method)
           at java.lang.Class.forName(Class.java:247)
           at org.glassfish.webservices.WsUtil.processConfiguredHandlers(WsUtil.java:2141)
           at org.glassfish.webservices.WsUtil.configureJAXWSServiceHandlers(WsUtil.java:2193)
           at org.glassfish.webservices.EjbRuntimeEndpointInfo.prepareInvocation(EjbRuntimeEndpointInfo.java:266)
           at org.glassfish.webservices.EjbRuntimeEndpointInfo.initRuntimeInfo(EjbRuntimeEndpointInfo.java:343)
           at org.glassfish.webservices.WebServiceEjbEndpointRegistry.registerEndpoint(WebServiceEjbEndpointRegistry.java:129)
           at com.sun.ejb.containers.BaseContainer.initializeHome(BaseContainer.java:1181)
           at com.sun.ejb.containers.StatelessSessionContainer.initializeHome(StatelessSessionContainer.java:202)
           at com.sun.ejb.containers.ContainerFactoryImpl.createContainer(ContainerFactoryImpl.java:167)
           at org.glassfish.ejb.startup.EjbApplication.loadContainers(EjbApplication.java:230)
           at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:299)
           at org.glassfish.ejb.startup.EjbDeployer.load(EjbDeployer.java:105)
           at org.glassfish.internal.data.ModuleInfo.load(ModuleInfo.java:186)
           at org.glassfish.internal.data.ApplicationInfo.load(ApplicationInfo.java:264)
           at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:460)
           at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
           at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:389)
           at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:348)
           at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:363)
           at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1085)
           at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:95)
           at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1291)
           at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1259)
           at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:461)
           at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:212)
           at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:179)
           at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
           at com.sun.enterprise.v3.services.impl.ContainerMapper$Hk2DispatcherCallable.call(ContainerMapper.java:354)
           at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
           at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:849)
           at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:746)
           at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1045)
           at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:228)
           at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
           at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
           at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
           at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
           at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
           at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
           at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
           at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
           at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
           at java.lang.Thread.run(Thread.java:680)
      Endpoint:
      @Stateless
      @WebService(name="Time", serviceName="TimeService", portName="TimeServicePort")
      @HandlerChain(file = "/handler-chain.xml")
      @DeclareRoles({ "guest", "user" })
      public class TimeService {
      // code, probably irrelevant to the issue
      }
      handler-chain.xml:
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <javaee:handler-chains xmlns:javaee="http://java.sun.com/xml/ns/javaee"
           xmlns:xsd="http://www.w3.org/2001/XMLSchema">
           <javaee:handler-chain>
                <javaee:handler>
                     <javaee:handler-class>edu.certification.abhijitsarkar.ocewsd.jaxws.ejb.webservice.handler.HttpBasicAuthenticationHandler
                     </javaee:handler-class>
                </javaee:handler>
                <javaee:handler>
                     <javaee:handler-class>edu.certification.abhijitsarkar.ocewsd.jaxws.ejb.webservice.handler.ProgrammaticAuthenticationHandler
                     </javaee:handler-class>
                </javaee:handler>
                <javaee:handler>
                     <javaee:handler-class>edu.certification.abhijitsarkar.ocewsd.jaxws.utility.handler.SOAPRequestHandler
                     </javaee:handler-class>
                </javaee:handler>
           </javaee:handler-chain>
      </javaee:handler-chains>
        • 1. Re: Glassfish can't find JAX-WS handler classes
          Bland
          Did you find an answer to this question? I am running into the exact same problem...

          Thanks.
          • 2. Re: Glassfish can't find JAX-WS handler classes
            Bland
            Ok, I found the answer... it is actually a classic bug. The code that is loading the handler is located in WsUtil. Here is a link to version 3.1.1 of that code, although I am running 3.1.2.

            http://grepcode.com/file/repo1.maven.org/maven2/org.glassfish.webservices/jsr109-impl/3.1.1/org/glassfish/webservices/WsUtil.java/

            The method and line that blows up is org.glassfish.webservices.WsUtil.processConfiguredHandlers(WsUtil.java:2141). On that line (in version 3.1.2 - remember the link above is 3.1.1), there is a call to "Class.forName". It turns out that it is passing the exact UNTRIMMED name that is found in the generated JAX-WS handler-chain XML file (it was generated from wsimport in my case).

            In my JAXWS customization file, I had placed the handler name "prettily" on its own line, with a carriage return like so:

            (leading whitespace here - but these forums don't show whitespace)<javaee:handler-class>myHandler
            (leading whitespace here - but these forums don't show whitespace)</javaee:handler-class>

            That extra whitespace is NOT BEING TRIMMED in the code responsible for parsing the file. That is the problem, plain and simple. I fixed that:

            <javaee:handler-class>myHandler</javaee:handler-class>

            ... and the problem went away.

            To confirm this, I looked in the logs of the Glassfish server at all the times it complained it could not load class "myHandler", and found it was actually complaining about "myHandler " (i.e. with many spaces).

            Hope this helps someone.

            Edited by: Bland on Jun 14, 2012 2:41 PM

            Edited by: Bland on Jun 14, 2012 2:43 PM

            Edited by: Bland on Jun 14, 2012 2:44 PM
            • 3. Re: Glassfish can't find JAX-WS handler classes
              gimbal2
              Really nice job figuring that out, but it won't really help anyone unless the bug gets reported to the glassfish jira (if it isn't already there).
              • 4. Re: Glassfish can't find JAX-WS handler classes
                Bland
                Done.

                http://java.net/jira/browse/GLASSFISH-18807