找不到 ArquillianServletRunner
ArquillianServletRunner not found
我还有另一个无法正常工作的 Arquillian 测试:
@RunWith(Arquillian.class)
public class SomeTest {
private static final String APPLICATION_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<application xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd\" version=\"6\">"
+ "<display-name>org.acme.project</display-name></application>";
@Deployment
public static Archive<?> createDeployment() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
ear.setApplicationXML(new StringAsset(APPLICATION_XML));
ear.addAsModules(Testable.archiveToTest(ShrinkWrap.create(WebArchive.class)));
return ear;
}
@Test
@Transactional
public void test() throws Exception {
System.out.println("SomeTest.test()");
}
}
这 class 是以下例外情况的全部内容:
java.lang.IllegalArgumentException: ArquillianServletRunner not found. Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer.
at org.jboss.arquillian.protocol.servlet.ServletUtil.determineBaseURI(ServletUtil.java:64)
at org.jboss.arquillian.protocol.servlet.ServletURIHandler.locateTestServlet(ServletURIHandler.java:60)
at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:84)
at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....
我看到了其他问题(例如 this one),但他们似乎都在使用 Glassfish,而我使用的是托管的 Wildfly 8.1。
尽管如此,由于 slf4j 已经进入我的依赖列表,我尝试了它的不同版本(1.5.10、1.6.6、1.7.13)。
与往常一样,服务器日志(或任何地方)中没有出现问题的迹象,只有 JUnit 运行ner(Eclipse 和 Maven)抱怨。与其他部署一起测试 运行 没问题。
怎么了?
对于所有遇到同样问题的人。这是它的工作原理(请参阅更改的评论):
private static final String APPLICATION_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<application xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd\" version=\"6\">" + "<display-name>org.acme.project</display-name>"
// the WAR must be added to the application.xml !
+ "<module><web><web-uri>test.war</web-uri><context-root>/test</context-root></web></module>"
+ "</application>";
@Deployment
public static Archive<?> createDeployment() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
ear.setApplicationXML(new StringAsset(APPLICATION_XML));
// to add the WAR to the application.xml, it must have a name
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war");
// the test class must be added manually for whatever reason
webArchive.addClass(SomeTest.class);
ear.addAsModules(Testable.archiveToTest(webArchive));
return ear;
}
我还有另一个无法正常工作的 Arquillian 测试:
@RunWith(Arquillian.class)
public class SomeTest {
private static final String APPLICATION_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<application xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd\" version=\"6\">"
+ "<display-name>org.acme.project</display-name></application>";
@Deployment
public static Archive<?> createDeployment() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
ear.setApplicationXML(new StringAsset(APPLICATION_XML));
ear.addAsModules(Testable.archiveToTest(ShrinkWrap.create(WebArchive.class)));
return ear;
}
@Test
@Transactional
public void test() throws Exception {
System.out.println("SomeTest.test()");
}
}
这 class 是以下例外情况的全部内容:
java.lang.IllegalArgumentException: ArquillianServletRunner not found. Could not determine ContextRoot from ProtocolMetadata, please contact DeployableContainer developer.
at org.jboss.arquillian.protocol.servlet.ServletUtil.determineBaseURI(ServletUtil.java:64)
at org.jboss.arquillian.protocol.servlet.ServletURIHandler.locateTestServlet(ServletURIHandler.java:60)
at org.jboss.arquillian.protocol.servlet.ServletMethodExecutor.invoke(ServletMethodExecutor.java:84)
at org.jboss.arquillian.container.test.impl.execution.RemoteTestExecuter.execute(RemoteTestExecuter.java:109)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
....
我看到了其他问题(例如 this one),但他们似乎都在使用 Glassfish,而我使用的是托管的 Wildfly 8.1。
尽管如此,由于 slf4j 已经进入我的依赖列表,我尝试了它的不同版本(1.5.10、1.6.6、1.7.13)。
与往常一样,服务器日志(或任何地方)中没有出现问题的迹象,只有 JUnit 运行ner(Eclipse 和 Maven)抱怨。与其他部署一起测试 运行 没问题。
怎么了?
对于所有遇到同样问题的人。这是它的工作原理(请参阅更改的评论):
private static final String APPLICATION_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<application xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd\" version=\"6\">" + "<display-name>org.acme.project</display-name>"
// the WAR must be added to the application.xml !
+ "<module><web><web-uri>test.war</web-uri><context-root>/test</context-root></web></module>"
+ "</application>";
@Deployment
public static Archive<?> createDeployment() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
ear.setApplicationXML(new StringAsset(APPLICATION_XML));
// to add the WAR to the application.xml, it must have a name
WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war");
// the test class must be added manually for whatever reason
webArchive.addClass(SomeTest.class);
ear.addAsModules(Testable.archiveToTest(webArchive));
return ear;
}