使用jersey error com.sun.jersey.api.core.ScanningResourceConfig init INFO:找不到提供程序类

时间:2013-10-17 05:31:09

标签: java web-services rest jersey

我不知道我的问题是什么,我是创建网络服务的初学者,任何人都可以解释我的错误。

我使用本教程链接http://www.youtube.com/watch?v=qts3ysQYQ1E

Oct 17, 2013 3:46:14 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre7/bin/client;C:/Program Files/Java/jre7/bin;C:/Program Files/Java/jre7/lib/i386;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\VisualSVN\bin;C:\Program Files\TortoiseSVN\bin;C:\Program Files\GtkSharp\2.12\bin;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Windows Kits\8.0\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;E:\JAVA PROJECT\eclipse;;.
Oct 17, 2013 3:46:14 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:EmployeeService' did not find a matching property.
Oct 17, 2013 3:46:14 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Oct 17, 2013 3:46:14 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Oct 17, 2013 3:46:14 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1065 ms
Oct 17, 2013 3:46:15 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Oct 17, 2013 3:46:15 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.12
Oct 17, 2013 3:46:17 PM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
  com.rest.employee.model
Oct 17, 2013 3:46:17 PM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
  class com.rest.employee.model.EmployeeService
Oct 17, 2013 3:46:17 PM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
Oct 17, 2013 3:46:17 PM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.17.1 02/28/2013 12:47 PM'
Oct 17, 2013 3:46:17 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Oct 17, 2013 3:46:17 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Oct 17, 2013 3:46:17 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2905 ms
  

这是我的班级EmployeeService

@Path("/emp")
public class EmployeeService {

    @GET
    @Path("/get{empID}")
    @Produces(MediaType.APPLICATION_XML)
    public Employee getEmployee(@PathParam("empID") String empID)
    {
        Employee employee= new com.rest.employee.model.Employee();
        employee.setEmpID(empID);
        employee.setName("Alvin");
        employee.setEmail("test@pmti.biz");
        return employee;
    }

    @POST
    @Path("/create")
    @Consumes(MediaType.APPLICATION_XML)
    @Produces(MediaType.APPLICATION_XML)
    public Employee CreateEmployee(Employee employee)
    {       
        //add logic
        return employee;
    }

    @PUT
    @Path("/update")
    @Consumes(MediaType.APPLICATION_XML)
    @Produces(MediaType.APPLICATION_XML)
    public Employee UpdateEmployee(Employee employee)
    {       
        employee.setName(employee.getName() + " Updated");
        return employee;
    }

    @DELETE
    @Path("/delete/{empID}")
    public Response deleteEmployee(@PathParam("empID") int empID) throws URISyntaxException
    {
        return Response.status(200).entity("Employee with" + empID + " is Deleted Successcully").build();

    }
}
  

员工类

@XmlAccessorType(XmlAccessType.NONE)
@XmlRootElement(name="employee")
public class Employee {
    public String empID;
    public String name;
    public String email;
    @XmlElement(required=true)
    public String getEmpID() {
        return empID;
    }
    public void setEmpID(String empID) {
        this.empID = empID;
    }

    @XmlElement(required=true)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }

    @XmlElement(required=true)
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }


}

1 个答案:

答案 0 :(得分:-1)

Jersey在类中使用@Provider注释标识REST资源(或服务)。也许你的REST服务类都没有这个注释。