无法在WildFly 11上上传部署

时间:2018-07-05 20:39:25

标签: java wildfly

最近几天,我遇到了一个使自己疯狂的问题。 我正在尝试在wildfly中部署Webapp,但出现以下错误:

  

无法上载部署:{“ WFLYCTL0080:服务失败” => {“ jboss.undertow.deployment.default-server.default-host./webapp” =>“ com.sun.jersey.api.container.ContainerException: ResourceConfig实例不包含任何根资源类。原因:com.sun.jersey.api.container.ContainerException:ResourceConfig实例不包含任何根资源类。“}}

这是我的课程

package com.stavros.ticketmanagement.rest;
import java.util.ArrayList;
import java.util.List;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import com.stavros.ticketmanagement.domain.Ticket;

@Path("/tickets")
public class TicketResource extends Application {   
@GET
@Produces("application/xml")
public List<Ticket> getAllTickets(){
List<Ticket> results= new ArrayList<Ticket>();
results.add(new Ticket(1, "TestName", "Test time", 100, 0));
results.add(new Ticket(2, "TestName2", "Test time2", 102, 0));
return results;
    }
}

这是我的web.xml

<web-app 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/web-app_2_5.xsd"
         version="2.5">

   <servlet>
      <servlet-name>Faces Servlet</servlet-name>
      <servlet-class>
      javax.faces.webapp.FacesServlet
       </servlet-class> 
   </servlet>

   <servlet-mapping>
      <servlet-name>Faces Servlet</servlet-name>
      <url-pattern>*.jsf</url-pattern>
   </servlet-mapping>

   <context-param>
      <param-name>javax.faces.PROJECT_STAGE</param-name>
      <param-value>Development</param-value>
   </context-param>


    <!-- Configuration for JAX-RS  -->
   <servlet>
      <servlet-name>Jersey Web Application</servlet-name>
      <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>

      <init-param>
         <param-name>com.sun.jersey.config.property.packages</param-name>
         <param-value>com.stavros.ticketmanagement.rest</param-value>
      </init-param>

      <load-on-startup>1</load-on-startup>          
   </servlet>

   <servlet-mapping>
      <servlet-name>Jersey Web Application</servlet-name>
      <url-pattern>/webservice/*</url-pattern>
   </servlet-mapping>

</web-app>

这是我在TicketResource中使用的Ticket类

//Domain class. A class that represents the actual real word object (in this case a ticket)
package com.stavros.ticketmanagement.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.xml.bind.annotation.XmlRootElement;

@Entity //Make the class usable from JPA (We store data to db with this class)
@XmlRootElement
public class Ticket implements java.io.Serializable {



    public Ticket() {
        //required by JPA but not used
        super();
    }


    @Id //Used from JPA as primary key
    @GeneratedValue(strategy=GenerationType.AUTO)
    private int ticketId;
    private String eventName;
    private String eventTime;
    private int price;
    private int isReserved;

    @OneToMany(cascade=CascadeType.MERGE) // in the events of an un-persistence obj being found in the Nnotes collection jpa is free to automatically call persist on that obj
    private Set<Note> notes; //this is used to keep a reference of the relative notes to each ticket. Its a collection (Set is better for DBs)Set: collection on obj with no particular order and no duplicate obj

//  @ManyToOne  //(cascade=CascadeType.PERSIST) // this should be manytoone
//  private Set<User> users;

    public Ticket(int ticketId, String eventName, String eventTime, int price, int isReserved) {
        super();
        this.notes = new HashSet<Note>();
        this.ticketId = ticketId;
        this.eventName = eventName;
        this.eventTime = eventTime;
        this.price = price;
        this.isReserved = isReserved;
    }


    public int getTicketId() {
        return ticketId;
    }

    public void setTicketId(int ticketId) {
        this.ticketId = ticketId;
    }

    public String getEventTime() {
        return eventTime;
    }

    public void setEventTime(String eventTime) {
        this.eventTime = eventTime;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getIsReserved() {
        return isReserved;
    }

    public void setIsReserved(int isReserved) {
        this.isReserved = isReserved;
    }

    public Set<Note> getNotes() {
        return notes;
    }

    public void setNotes(Set<Note> notes) {
        this.notes = notes;
    }

    public String getEventName() {
        return eventName;
    }


    //this is what the find*Ticket will return in TestHarness
    public String toString() {
        return "Ticket [ticketId=" + ticketId + ", eventName=" + eventName + ", eventTime=" + eventTime + ", price="+ price + ", isReserved=" + isReserved + "]";
    }

    //Regular methods, for example -10% to a ticket
    public void setEventName(String newEventName) {
        this.eventName = newEventName; //updates the eventName in the db
    }

    //bsn methods
    //add a note
    public void addNote(String newNoteText) {
        Note newNote=new Note(newNoteText);
        this.notes.add(newNote);
    }

    //add a user
//  public void addUser(int userId, String userName, String password, String email, int accessLevel) {
//      User newUser=new User(userId, userName, password, email, accessLevel);
//      this.users.add(newUser);
//  }



    public Set<Note> getAllNotes() {
        // TODO Auto-generated method stub
        return this.notes;
    }


}

我已经尝试了所有可能的解决方案。 web.xml中的路径正确。

这是我的图书馆的照片。

Project libs

非常感谢您的帮助。!

0 个答案:

没有答案