JBoss 7.1でRESTプロジェクトを作成しました。 私はあなたに必要なクラスを与える:JBoss 7.1で実行中のRest Projectでエラーが発生しました
User.java
@XmlRootElement(name = "user")
public class User implements Serializable {
private static final long serialVersionUID = 1L;
private int id;
private String name;
private String profession;
public User(){}
public User(int id, String name, String profession){
this.id = id;
this.name = name;
this.profession = profession;
}
public int getId() {
return id;
}
@XmlElement
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
@XmlElement
public void setName(String name) {
this.name = name;
}
public String getProfession() {
return profession;
}
@XmlElement
public void setProfession(String profession) {
this.profession = profession;
}
}
ListBean.java
@ManagedBean
@ViewScoped
public class ListBean {
private static Client client;
private static String REST_SERVICE_URL = "http://localhost:8080/UserManagement/rest/UserService/users";
private static final String SUCCESS_RESULT="<result>success</result>";
private static final String PASS = "pass";
private static final String FAIL = "fail";
private List<User> users;
private transient DataModel<User> model;
private User user;
private int id;
private String name;
private String profession;
private void init(){
this.client = ClientBuilder.newClient();
}
@PostConstruct
public void initialize()
{
ListBean tester = new ListBean();
tester.init();
GenericType<List<User>> list = new GenericType<List<User>>() {};
users = client.target(REST_SERVICE_URL)
.request(MediaType.APPLICATION_XML)
.get(list);
String result = PASS;
if(users.isEmpty()){
result = FAIL;
}
List<User> lus = new ArrayList<User>();
for(User u : users){
lus.add(u);
}
user = new User();
}
}
UserService.java
@Path("/UserService")
public class UserService
{
UserDao userDao = new UserDao();
private static final String SUCCESS_RESULT="<result>success</result>";
private static final String FAILURE_RESULT="<result>failure</result>";
@GET
@Path("/users")
@Produces(MediaType.APPLICATION_XML)
public List<User> getUsers(){
return userDao.getAllUsers();
}
}
それを実行した後、例外怒鳴るが表示されます。
20:49:39,045 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "sqljdbc4.jar"
20:49:39,050 INFO [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015876: Starting deployment of "UserManagement.war"
20:49:40,026 WARN [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Tomcat6InjectionProvider:org.apache.catalina.util.DefaultAnnotationProcessor' for service type 'com.sun.faces.spi.injectionprovider'
20:49:40,028 WARN [org.jboss.as.server.deployment] (MSC service thread 1-2) JBAS015893: Encountered invalid class name 'com.sun.faces.vendor.Jetty6InjectionProvider:org.mortbay.jetty.plus.annotation.InjectionCollection' for service type 'com.sun.faces.spi.injectionprovider'
20:49:40,241 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC00001: Failed to start service jboss.deployment.unit."UserManagement.war".POST_MODULE: org.jboss.msc.service.StartException in service jboss.deployment.unit."UserManagement.war".POST_MODULE: Failed to process phase POST_MODULE of deployment "UserManagement.war"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [rt.jar:1.7.0_55]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [rt.jar:1.7.0_55]
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_55]
Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS011232: Only one JAX-RS Application Class allowed. org.glassfish.jersey.server.ResourceConfig$WrappingResourceConfig org.glassfish.jersey.server.ResourceConfig$RuntimeConfig org.glassfish.jersey.server.ResourceConfig
at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scan(JaxrsScanningProcessor.java:209)
at org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:105)
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
... 5 more
このプロジェクトは、Tomcat6と7の両方でうまく動作しますが、JBossの7.1は問題を抱えています。
このエラーを生成したコードを含めることはできますか? –
まずフルログを確認します。私はほぼ100%確信していますmore – Kukeltje
このエラーは、JSFに関連していないので、タグを削除しました。 「タイトル」以外にも、それは休憩に関係していません。 [ask]を読んで質問を改善してください。現在の状態で – Kukeltje