2009-05-28 7 views
0

Ich arbeite an einer Webanwendung, die einen eigenständigen ehcache-Server verwendet, um bestimmte Daten zwischenzuspeichern. Der Zugriff auf den ehcache-Server erfolgt über REST (im Gegensatz zu SOAP).Ausnahme beim Aufruf von Ehcache-Server in Embedded Jetty über Cargo: WebApplicationProviderImpl konnte nicht instanziiert werden

Zu funktionalen Testzwecken muss ich eine eingebettete Instanz des ehcache-Servers ausführen. Das Echcache-Server-Projekt selbst erledigt dies für eigene Funktionstests mit dem Cargo Maven2-Plugin. Ich habe versucht, dasselbe in der pom.xml meiner Anwendung zu tun, aber das Cargo-Plugin besteht darauf, den WAR meiner eigenen Webanwendung zu implementieren, selbst wenn ich es stattdessen für die Verwendung von ehcaches WAR konfiguriere.

Daher versuche ich, die Cargo Container API direkt zu verwenden, um die Bereitstellung und Container Instanziierung durchzuführen. Hier ist der relevante Code:

String localRepositoryPath = "/home/zoltan/.m2/repository"; 
String jettyHomeDirectory = "/tmp/cargoJettyHome"; 

LocalConfiguration configuration = new Jetty6xEmbeddedStandaloneLocalConfiguration(jettyHomeDirectory); 
Deployable war = new WAR(localRepositoryPath + "/net/sf/ehcache/ehcache-server/0.7/ehcache-server-0.7.war"); 
configuration.addDeployable(war); 

EmbeddedLocalContainer container = new Jetty6xEmbeddedLocalContainer(configuration); 
container.start(); 

Die Jetty Container beginnen, und ehcache selbst scheint teilweise zu starten, basierend auf verschiedene Nachrichten, die die gleichen wie schauen, was erzeugt wird, wenn der Standalone-Server starten. Allerdings schlägt der RESTful Web-Dienst zu starten, mit folgenden Ausnahme:

com.sun.jersey.spi.service.ServiceConfigurationError: com.sun.jersey.spi.container.WebApplicationProvider: The class com.sun.jersey.impl.container.WebApplicationProviderImpl implementing provider interface com.sun.jersey.spi.container.WebApplicationProvider could not be instantiated: null 
    at com.sun.jersey.spi.service.ServiceFinder.fail(ServiceFinder.java:346) 
    at com.sun.jersey.spi.service.ServiceFinder.access$600(ServiceFinder.java:144) 
    at com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:638) 
    at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:61) 
    at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:570) 
    at com.sun.jersey.spi.container.servlet.ServletContainer.load(ServletContainer.java:538) 
    at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:207) 
    at org.mortbay.jetty.servlet.ServletHolder.initServlet(ServletHolder.java:433) 
    at org.mortbay.jetty.servlet.ServletHolder.doStart(ServletHolder.java:256) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.servlet.ServletHandler.initialize(ServletHandler.java:616) 
    at org.mortbay.jetty.servlet.Context.startContext(Context.java:140) 
    at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1220) 
    at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:513) 
    at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:448) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
    at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130) 
    at org.mortbay.jetty.Server.doStart(Server.java:222) 
    at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:39) 
    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:597) 
    at org.codehaus.cargo.container.jetty.internal.JettyExecutorThread.run(JettyExecutorThread.java:68) 
Caused by: java.lang.ClassCastException 
    at java.lang.Class.cast(Class.java:2990) 
    at com.sun.jersey.spi.service.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:596) 
    ... 26 more 

Hier sind die entsprechenden Abhängigkeiten von meinem pom.xml:

<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-server</artifactId> 
    <version>1.0</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-client</artifactId> 
    <version>1.0</version> 
</dependency> 
<dependency> 
    <groupId>com.sun.jersey</groupId> 
    <artifactId>jersey-spring</artifactId> 
    <version>1.0</version> 
    <scope>test</scope> 
    <exclusions> 
    <exclusion> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-core</artifactId> 
    </exclusion> 
    <exclusion> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-beans</artifactId> 
    </exclusion> 
    <exclusion> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-aop</artifactId> 
    </exclusion> 
    <exclusion> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
    </exclusion> 
    <exclusion> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context-support</artifactId> 
    </exclusion> 
    <exclusion> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-web</artifactId> 
    </exclusion> 
    </exclusions> 
</dependency> 
<dependency> 
    <groupId>org.mortbay.jetty</groupId> 
    <artifactId>jetty-servlet-tester</artifactId> 
    <version>6.1.11</version> 
    <scope>test</scope> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.cargo</groupId> 
    <artifactId>cargo-core-api-container</artifactId> 
    <version>1.0</version> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.cargo</groupId> 
    <artifactId>cargo-core-api-generic</artifactId> 
    <version>1.0</version> 
</dependency> 
<dependency> 
    <groupId>org.codehaus.cargo</groupId> 
    <artifactId>cargo-core-container-jetty</artifactId> 
    <version>1.0</version> 
</dependency> 
<dependency> 
    <groupId>net.sf.ehcache</groupId> 
    <artifactId>ehcache-server</artifactId> 
    <version>0.7</version> 
    <type>war</type> 
</dependency> 

Wer weiß, was diese Ausnahme verursachen könnte? Vielleicht verwende ich nicht übereinstimmende Versionen von Anlegesteg und Jersey? Muss ich irgendwie einen WebApplicationProviderImpl registrieren? Irgendwelche Ideen würden sehr geschätzt werden.

Antwort

0

Ich habe keine Lösung dafür: stattdessen verwenden meine Funktionstests einen eigenständigen ehcache Server.

Jemand auf der ehcache-Mailingliste schlug an alternative approach vor.