xwss
  1. xwss
  2. XWSS-45

Jetty container throws IllegalAccessException

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: www
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      45

      Description

      Deploying metro jars on Jetty container throws IllegalAccessException.

      This exception is happening because class
      org.mortbay.jetty.servlet.ServletHandler$Context is package local.
      Method returned via context.getClass().getMethod(...) can't be used outside of
      package.

      Dec 14, 2008 8:06:08 AM
      com.sun.xml.ws.transport.http.servlet.WSServletContextListener contextInitialized
      SEVERE: WSSERVLET11: failed to parse runtime descriptor:
      com.sun.xml.wss.impl.XWSSecurityRuntimeException: java.
      lang.IllegalAccessException: Class com.sun.xml.wss.impl.misc.ReflectionUtil can
      not access a member of class org.mortbay.jetty.servlet.ServletHandler$Context
      with modifiers "public"
      com.sun.xml.wss.impl.XWSSecurityRuntimeException:
      java.lang.IllegalAccessException: Class com.sun.xml.wss.impl.misc.ReflectionUtil
      can not access a member of class
      org.mortbay.jetty.servlet.ServletHandler$Context with modifiers "public"
      at com.sun.xml.wss.impl.misc.ReflectionUtil.invoke(ReflectionUtil.java:65)
      at com.sun.xml.wss.impl.misc.ReflectionUtil.invoke(ReflectionUtil.java:44)
      at
      com.sun.xml.wss.impl.misc.SecurityUtil.loadFromContext(SecurityUtil.java:574)
      at
      com.sun.xml.ws.assembler.TubelineAssemblyController$SecurityTubeAppender.isSecurityConfigPresent(TubelineAssemblyController.java:564)
      at
      com.sun.xml.ws.assembler.TubelineAssemblyController$SecurityTubeAppender.appendTube(TubelineAssemblyController.java:388)
      at
      com.sun.xml.ws.assembler.TubelineAssemblerFactoryImpl$WsitTubelineAssembler.createServer(TubelineAssemblerFactoryImpl.java:101)
      at com.sun.xml.ws.server.WSEndpointImpl.<init>(WSEndpointImpl.java:152)
      at
      com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:217)
      at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:467)
      at
      com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parseAdapters(DeploymentDescriptorParser.java:253)
      at
      com.sun.xml.ws.transport.http.DeploymentDescriptorParser.parse(DeploymentDescriptorParser.java:147)
      at
      com.sun.xml.ws.transport.http.servlet.WSServletContextListener.contextInitialized(WSServletContextListener.java:108)
      at
      org.mortbay.jetty.servlet.WebApplicationContext.doStart(WebApplicationContext.java:495)
      at
      org.mortbay.j2ee.J2EEWebApplicationContext.doStart(J2EEWebApplicationContext.java:78)
      at
      org.jboss.jetty.JBossWebApplicationContext.doStart(JBossWebApplicationContext.java:79)
      at org.mortbay.util.Container.start(Container.java:72)
      at org.jboss.jetty.Jetty.deploy(Jetty.java:322)
      at org.jboss.jetty.JettyService.performDeploy(JettyService.java:207)
      at
      org.jboss.jetty.JettyService$JettyDeployer.performDeploy(JettyService.java:414)
      at org.jboss.web.AbstractWebDeployer.start(AbstractWebDeployer.java:371)
      at org.jboss.web.WebModule.startModule(WebModule.java:83)
      at org.jboss.web.WebModule.startService(WebModule.java:61)
      .....
      ....
      ...

        Activity

        Hide
        manishkg added a comment -

        One possible solution for this problem is to force the method (invoked via
        reflection) to be accessible. Adding the following method in ReflectionUtil
        should solve the problem.

        public static Method getForcedAccessibleMethod(Class<?> clazz,
        String methodName, Class<?>... parameterTypes) {
        Method method;
        try

        { method = clazz.getMethod(methodName, parameterTypes); }

        catch (SecurityException e)

        { throw new CannotAccessMethodException("Cannot access method '" + methodName + "' in class '" + clazz.getName() + "' for security reasons", e); }

        catch (NoSuchMethodException e)

        { throw new CannotAccessMethodException("The method '" + methodName + "' in class '" + clazz.getName() + "' does not exist", e); }

        if (!method.isAccessible())

        { method.setAccessible(true); }

        return method;
        }

        We need to change following line in ReflectionUtil.invoke()

        final Method method = target.getClass().getMethod(methodName, parameterTypes);

        by

        final Method method = getForcedAccessibleMethod(target.getClass(), methodName,
        parameterTypes);

        Show
        manishkg added a comment - One possible solution for this problem is to force the method (invoked via reflection) to be accessible. Adding the following method in ReflectionUtil should solve the problem. public static Method getForcedAccessibleMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) { Method method; try { method = clazz.getMethod(methodName, parameterTypes); } catch (SecurityException e) { throw new CannotAccessMethodException("Cannot access method '" + methodName + "' in class '" + clazz.getName() + "' for security reasons", e); } catch (NoSuchMethodException e) { throw new CannotAccessMethodException("The method '" + methodName + "' in class '" + clazz.getName() + "' does not exist", e); } if (!method.isAccessible()) { method.setAccessible(true); } return method; } We need to change following line in ReflectionUtil.invoke() final Method method = target.getClass().getMethod(methodName, parameterTypes); by final Method method = getForcedAccessibleMethod(target.getClass(), methodName, parameterTypes);
        Hide
        kumarjayanti added a comment -

        I have made a potential fix. Can you please try latest build from :

        http://hudson.sfbay/view/Tango/job/wsit-javanet/3790/

        and let me know if it solves the problem.

        Show
        kumarjayanti added a comment - I have made a potential fix. Can you please try latest build from : http://hudson.sfbay/view/Tango/job/wsit-javanet/3790/ and let me know if it solves the problem.

          People

          • Assignee:
            xwss-issues
            Reporter:
            manishkg
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: