我想用Arquillian將具有Web服務外觀的企業應用程序部署到glassfish。我對這個主題不是很有經驗。使用Arquillian測試Web服務部署:上下文根爲空
我發送帶註釋的WebService和接口代碼。
WebService的執行情況:
@Stateless
@WebService(endpointInterface = "ena.access.ticketsservices.facade.ITicketsRoleMappingsFacade")
@DeclareRoles({ "User", "Guest", "ProjectAdmin", "Admin" })
public class TicketsRoleMappingsFacade implements ITicketsRoleMappingsFacade {
...
}
接口:
@WebService(name = "TicketsRoleMappingsFacade")
public interface ITicketsRoleMappingsFacade {
@WebMethod
@WebResult(name = "createProjectResult")
public Project createProject(@WebParam(name = "createproject") Project project);
}
和下面的XML文件是GlassFish的配置文件。
的application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application
version="6"
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">
<display-name>j2ee-ear</display-name>
<module>
<ejb>j2ee-ejb.jar</ejb>
</module>
<security-role>
<role-name>User</role-name>
</security-role>
<security-role>
<role-name>Guest</role-name>
</security-role>
<security-role>
<role-name>ProjectAdmin</role-name>
</security-role>
<security-role>
<role-name>Admin</role-name>
</security-role>
<library-directory>lib</library-directory>
</application>
與GlassFish的application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-application PUBLIC -//GlassFish.org//DTD GlassFish Application Server 3.1 Java EE Application 6.0//EN http://glassfish.org/dtds/glassfish-application_6_0-1.dtd>
<glassfish-application>
<security-role-mapping>
<role-name>User</role-name>
<group-name>User</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>Guest</role-name>
<group-name>Guest</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ProjectAdmin</role-name>
<group-name>ProjectAdmin</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>Admin</role-name>
<group-name>Admin</group-name>
</security-role-mapping>
<realm>someRealm</realm>
</glassfish-application>
與GlassFish ejb-jar.xml中
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-ejb-jar PUBLIC -//GlassFish.org//DTD GlassFish Application Server 3.1 EJB 3.1//EN http://glassfish.org/dtds/glassfish-ejb-jar_3_1-1.dtd>
<glassfish-ejb-jar>
<security-role-mapping>
<role-name>User</role-name>
<group-name>User</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>Guest</role-name>
<group-name>Guest</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>ProjectAdmin</role-name>
<group-name>ProjectAdmin</group-name>
</security-role-mapping>
<security-role-mapping>
<role-name>Admin</role-name>
<group-name>Admin</group-name>
</security-role-mapping>
<enterprise-beans>
<ejb>
<ejb-name>TicketsRoleMappingsFacade</ejb-name>
<webservice-endpoint>
<port-component-name>TicketsRoleMappingsFacade</port-component-name>
<port-component-uri>/TicketsRoleMappingsFacade</port-component-uri>
</webservice-endpoint>
</ejb>
</enterprise-beans>
</glassfish-ejb-jar>
當我建立耳朵文件,拆封和部署在日誌服務器日誌中獲得以下行,所以我認爲部署的一部分是成功的:
[#|2013-08-03T17:23:57.322+0200|INFO|glassfish3.1.1|javax.enterprise.webservices.org.glassfish.webservices|_ThreadID=17;_ThreadName=Thread-2;|WS00019: EJB Endpoint deployed j2ee-ear listening at address at http://localhost:9999/TicketsRoleMappingsFacadeService/TicketsRoleMappingsFacade|#]
但我也得到的Arquillian以下異常:
java.lang.IllegalArgumentException: contextRoot must not be null
at org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet.<init>(Servlet.java:48)
at org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientService.resolveWebModuleSubComponents(GlassFishClientService.java:357)
at org.jboss.arquillian.container.glassfish.clientutils.GlassFishClientService.doDeploy(GlassFishClientService.java:227)
at org.jboss.arquillian.container.glassfish.CommonGlassFishManager.deploy(CommonGlassFishManager.java:101)
at org.jboss.arquillian.container.glassfish.remote_3_1.GlassFishRestDeployableContainer.deploy(GlassFishRestDeployableContainer.java:71)
at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:161)
at org.jboss.arquillian.container.impl.client.container.ContainerDeployController$3.call(ContainerDeployController.java:128)
at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.executeOperation(ContainerDeployController.java:271)
at org.jboss.arquillian.container.impl.client.container.ContainerDeployController.deploy(ContainerDeployController.java:127)
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.jboss.arquillian.core.impl.ObserverImpl.invoke(ObserverImpl.java:94)
at org.jboss.arquillian.core.impl.EventContextImpl.invokeObservers(EventContextImpl.java:99)
at org.jboss.arquillian.core.impl.EventContextImpl.proceed(EventContextImpl.java:81)
at
....
我沒有這個測試設置任何.war文件我怎麼可以指定我的web服務的上下文根?
歡迎來到StackOverflow Cladio,你應該編輯你想提的評論和關於忽略你的最後部分。你相信你的改變可能會回答他的問題,這是值得回答的資格。意見是要求澄清。例如,如果您詢問「您是否嘗試刪除您的application.xml」,那麼它將更適合作爲評論。這隻需要幾個有用的答案或問題,然後才能發表評論。 –