Jakarta ee 使用arquillian测试RESTWeb服务
我们想使用arquillian测试我们的RESTAPI 我们使用玻璃鱼来生产阿基利安鱼 我们已经对我们公开的一些JMS队列进行了arquillian测试,而且效果很好,所以我们至少有一些基础知识。 当我们开始使用该设置进行REST测试时,在发送REST URL的第一个HTTP GET时,出现了异常:Jakarta ee 使用arquillian测试RESTWeb服务,jakarta-ee,jboss-arquillian,glassfish-embedded,Jakarta Ee,Jboss Arquillian,Glassfish Embedded,我们想使用arquillian测试我们的RESTAPI 我们使用玻璃鱼来生产阿基利安鱼 我们已经对我们公开的一些JMS队列进行了arquillian测试,而且效果很好,所以我们至少有一些基础知识。 当我们开始使用该设置进行REST测试时,在发送REST URL的第一个HTTP GET时,出现了异常: com.sun.jersey.api.container.ContainerException:不存在WebApplication提供程序。 以下是我们的包覆面提取设置: public stat
com.sun.jersey.api.container.ContainerException:不存在WebApplication提供程序。
以下是我们的包覆面提取设置:
public static WebArchive createTestArchive() {
return ShrinkWrap.create(WebArchive.class, "test.war") // Create jar
.addPackages(true, "<our packages, plus some dependencies>") //, "com.ocpsoft.pretty")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") // b
.setWebXML("WEB-INF/web.xml")
.addAsWebInfResource("WEB-INF/faces-config.xml")
//.addAsWebInfResource(new StringAsset("<faces-config version=\"2.0\"/>"), "faces-config.xml")
.addAsResource("META-INF/test-persistence.xml", "META-INF/persistence.xml");
}
[……]
(但忽略该警告似乎是安全的,请参阅此警告及其链接到的错误:)
然后是错误:
SEVERE: WebModule[/test]StandardWrapper.Throwable
com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:306)
好的,在Gab评论的帮助下(如果没有这个提示,我永远不会成功!),我解决了这个问题。 这个评论让我把注意力集中在软件包的版本上,我意识到我们用于生产的glassfish 3.1.2使用jersey 1.11,而glassfish embedded 3.1.1使用jersey 1.8,我们现在用于测试(因为在撰写本文时还没有3.1.2) 因此,我在pom.xml的测试部分添加了以下依赖项:
<!-- glassfish 3.1 ships with jersey 1.8, hence the version here. -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.8</version>
</dependency>
泽西岛
泽西服务器
1.8
假如
com.sun.jersey.contribs
泽西多部分
1.8
泽西岛
泽西json
1.8
在pom.xml的主要部分中,我将依赖项留给了jersey,指向jersey 1.11
现在问题解决了
我希望我们能得到一个更好的错误消息,为这样的问题 你用什么样的阿奎利安容器(我想是玻璃鱼容器吧)?如果嵌入,它是否与目标服务器的版本完全相同?
Caused by: java.lang.ClassNotFoundException: org.osgi.framework.ServiceException
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
SEVERE: WebModule[/test]StandardWrapper.Throwable
com.sun.jersey.api.container.ContainerException: No WebApplication provider is present
at com.sun.jersey.spi.container.WebApplicationFactory.createWebApplication(WebApplicationFactory.java:69)
at com.sun.jersey.spi.container.servlet.ServletContainer.create(ServletContainer.java:391)
at com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent.create(ServletContainer.java:306)
<!-- glassfish 3.1 ships with jersey 1.8, hence the version here. -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.8</version>
</dependency>