我是Java EE和Arquillian的新手。如果我想将我的简单项目部署到嵌入式glassfish 4.1.1服务器中,我会遇到问题。我可以成功通过部署,但我无法访问我实现的方法。我收到错误代码500,而我期望200。
我的部署:
public class AuthTest
{
@Deployment(testable = false)
public static WebArchive createDeployment()
{
System.out.println("\nin createDeployment");
// File[] libs = Maven.resolver().loadPomFromFile("pom.xml").importRuntimeAndTestDependencies().asFile();
WebArchive archive = ShrinkWrap.create(WebArchive.class, "ArquillianHepInterface.war")
.addClasses(AuthEndpoint.class)
.addPackage(Database.class.getPackage())
.addPackage(DeviceAccessDBEntry.class.getPackage())
.addPackage(WebsiteAccessDBEntry.class.getPackage())
.addPackage(DeviceInfo.class.getPackage())
.addPackage(LoginInfo.class.getPackage())
.addPackage(ResponseBoolean.class.getPackage())
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsWebInfResource(new File("src/main/webapp", "WEB-INF/web.xml"))
.addAsWebInfResource(new File("src/main/webapp", "WEB-INF/glassfish-web.xml"))
.addAsResource("META-INF/persistence.xml")
// .addAsLibraries(libs)
;
System.out.println("\nende createDeployment");
return archive;
}
@ArquillianResource
protected URL contextPath;
@Test
public void registerUUIDTest()
{
DeviceInfo newUser = new DeviceInfo();
newUser.setDate("2014-12-12");
newUser.setUuid("xyz");
Response i = expect().statusCode(200).when().given().
contentType("application/json").body(newUser)
.post(this.contextPath + "AUTHENTICATION/CREATEMOBILELOGIN")
;
}
我的AuthEndpoint类:
@Path("/AUTHENTICATION")
public class AuthEndpoint
{
@Inject
private DatabaseInterface database;
@POST
@Produces({ "application/json" })
@Consumes({ "application/json" })
@Path("CREATEMOBILELOGIN")
public LoginInfo createMobileLogin(DeviceInfo info)
{
System.out.println("RICHTIGES FILE");
System.err.println();
LoginInfo response = null;
if (info != null && info.getUuid() != null)
{
String password = this.database.registerDevice(info.getUuid());
if (password != null)
{
response = new LoginInfo();
response.setPw(password);
response.setUuid(info.getUuid());
}
}
return response;
}
}
我得到: 严重:WebModule [/ ArquillianHepInterface] StandardWrapper.Throwable
为什么会这样?我不明白我的问题在哪里...... 当我使用glassfish 4.1.1时我觉得我有问题......?我想简单地通过Arquillian TestClass调用AuthEndpoint类中的Methods来验证是否已经创建了一个......
的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>Arquillian Rest Demo</display-name>
<servlet>
<display-name>JAX-RS REST Servlet</display-name>
<servlet-name>REST-Servlet</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>REST-Servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
的glassfish-web.xml中:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" "http://glassfish.org/dtds/glassfish-web-app_3_0-1.dtd">
<glassfish-web-app>
<context-root>/ArquillianHepInterface</context-root>
<class-loader delegate="true" />
</glassfish-web-app>
我的beans.xml文件为空。
AuthEndpoint使用的方法是我在maven依赖项中编译和添加的另一个maven项目... 我很感激任何帮助...