cxf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juan Jose Perez Consuegra <jper...@oc.mde.es>
Subject AccessControlException Error publishing REST service with Jetty server
Date Wed, 26 Sep 2012 12:26:25 GMT
I'm having a problem when running a Jetty server for publishing a web service. If I start the
server from a simple class with static void main method I have no problem:

package cserver.ws;

import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.spring.SpringBusFactory;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;

public class RestServer {

    static {
        // set the configuration file
        SpringBusFactory factory = new SpringBusFactory();
        Bus bus = factory.createBus("src/es/uned/scc/related/cserver/ws/server-bean.xml");
        BusFactory.setDefaultBus(bus);
    }

    protected RestServer() throws Exception {
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setResourceClasses(RLABSystemWSRest.class);
        sf.setResourceProvider(RLABSystemWSRest.class,
            new SingletonResourceProvider(new RLABSystemWSRest()));
        sf.setAddress("http://localhost:9000/");

        sf.create();
    }

    public static void main(String args[]) throws Exception {
        new RestServer();
        System.out.println("Server ready...");

    }
}

I can test all the method of the service with Junit or call them from a web browser without
any problem, but if I want to load this class from another one in order to embed the start
process like this:

package cserver.ws;

public class initRest {

      /**
      * @param args
      */
      public static void main(String[] args)  throws Exception {

                  new RestServer();


      }

}

an error raise like this:

sep 26, 2012 2:00:24 PM org.eclipse.jetty.server.HttpConnection handleRequest
Advertencia: /traceTest/HOLA
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.Thread.setContextClassLoader(Unknown Source)
      at org.apache.cxf.common.classloader.ClassLoaderUtils$1.run(ClassLoaderUtils.java:56)
      at org.apache.cxf.common.classloader.ClassLoaderUtils$1.run(ClassLoaderUtils.java:54)
      at java.security.AccessController.doPrivileged(Native Method)
      at org.apache.cxf.common.classloader.ClassLoaderUtils.setThreadContextClassloader(ClassLoaderUtils.java:53)
      at org.apache.cxf.common.classloader.ClassLoaderUtils$ClassLoaderHolder.reset(ClassLoaderUtils.java:49)
      at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(JettyHTTPDestination.java:314)
      at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(JettyHTTPHandler.java:72)
      at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
      at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:941)
      at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:188)
      at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:875)
      at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
      at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:250)
      at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
      at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
      at org.eclipse.jetty.server.Server.handle(Server.java:349)
      at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
      at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:919)
      at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:582)
      at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:218)
      at org.eclipse.jetty.server.BlockingHttpConnection.handle(BlockingHttpConnection.java:50)
      at org.eclipse.jetty.server.bio.SocketConnector$ConnectorEndPoint.run(SocketConnector.java:245)
      at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
      at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
      at java.lang.Thread.run(Unknown Source)

sep 26, 2012 2:00:47 PM org.eclipse.jetty.server.session.HashSessionManager scavenge
Advertencia: Problem scavenging sessions
java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "setContextClassLoader")
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.Thread.setContextClassLoader(Unknown Source)
      at org.eclipse.jetty.server.session.HashSessionManager.scavenge(HashSessionManager.java:293)
      at org.eclipse.jetty.server.session.HashSessionManager$2.run(HashSessionManager.java:269)
      at java.util.TimerThread.mainLoop(Unknown Source)
      at java.util.TimerThread.run(Unknown Source)

Exception in thread "HashSessionScavenger-0" java.security.AccessControlException: access
denied ("java.lang.RuntimePermission" "setContextClassLoader")
      at java.security.AccessControlContext.checkPermission(Unknown Source)
      at java.security.AccessController.checkPermission(Unknown Source)
      at java.lang.SecurityManager.checkPermission(Unknown Source)
      at java.lang.Thread.setContextClassLoader(Unknown Source)
      at org.eclipse.jetty.server.session.HashSessionManager.scavenge(HashSessionManager.java:321)
      at org.eclipse.jetty.server.session.HashSessionManager$2.run(HashSessionManager.java:269)
      at java.util.TimerThread.mainLoop(Unknown Source)
      at java.util.TimerThread.run(Unknown Source)

I'm really lost, I can't understand the problem, when I start the server the trace is the
same in both cases:

log4j:WARN No appenders could be found for logger (org.apache.cxf.bus.spring.BusApplicationContext).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
sep 26, 2012 2:00:12 PM org.apache.cxf.bus.spring.BusApplicationContext getConfigResources
Información: Loaded configuration file src/es/uned/scc/related/cserver/ws/server-bean.xml.
sep 26, 2012 2:00:17 PM org.apache.cxf.endpoint.ServerImpl initDestination
Información: Setting the server's publish address to be http://localhost:9000/
sep 26, 2012 2:00:17 PM org.eclipse.jetty.server.Server doStart
Información: jetty-7.5.4.v20111024
sep 26, 2012 2:00:17 PM org.eclipse.jetty.server.AbstractConnector doStart
Información: Started SocketConnector@0.0.0.0:9000 STARTING
sep 26, 2012 2:00:17 PM org.eclipse.jetty.server.handler.ContextHandler startContext
Información: started o.e.j.s.h.ContextHandler{,null}

can't find any difference

any idea????

thanks everybody,

Juanjo
Tte. Juan José Pérez Consuegra
Instituto Tecnológico "La Marañosa"
Área de Electrónica/Unidad de Robótica
Tlfno.: Mil. 820 2452   / Civil.  91 174 2452
jpercon@oc.mde.es<mailto:jpercon@oc.mde.es>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message