Hi

I'm presuming it's a GET request from a browser which is failing given a very 
involved Accept value, can you please
say what is the URI you're using ?

Thanks, Sergey

  ----- Original Message ----- 
  From: Emily Gu 
  To: [email protected] ; [EMAIL PROTECTED] 
  Sent: Friday, July 11, 2008 3:01 AM
  Subject: JAX-RS: CXF + Spring + Tomcat


  Thanks Sergey for your reply. My code works in standardalone mode but not 
when I try to access from Web. Can you see anything wrong?

  @Path("/employeeservice/")
  public class EmployeeService {
   long currentId = 33333;
   private Map<Long, Employee> empMap;
   private Map<Long, Project> prjMap;
   
   public EmployeeService() {
    empMap = EmployeeDAO.getEmployees();
    prjMap = EmployeeDAO.getProjects();
   }
   
   @ProduceMime("application/json")
   @GET
   @Path("/employees/{id}/")
   public Employee getEmployee(@PathParam("id") String id) {
    long _id = Long.parseLong(id);
    return empMap.get(_id);
   }
   
   @GET
   @Path("/employees/")
   public Employees getEmployees() {
    List<Employee> employees = EmployeeDAO.getEmployeeList();
    
    Employees emps = new Employees();
    emps.setEmployee(employees);
    
    return emps;
   }
   
   
   @PUT
      @Path("/employees/")
      @ConsumeMime("application/json")
   public Response updateEmployee (Employee employee) {
    System.out.println("----invoking updateEmployee, employee name is: " + 
employee.getFirstName() + " " + employee.getLastName());
           Employee emp = empMap.get(employee.getGid());
           Response res;
           
           if (emp != null) {
               empMap.put(employee.getGid(), employee);
               res = Response.ok(employee).build();
           } else {
               res = Response.notModified().build();
           }

    return res;
    
   }
   
   @POST
      @Path("/employees/")
   public Response addEmployee (Employee employee) {
    System.out.println("----invoking addEmployee, Employee name is: " + 
employee.getFirstName() + " " + employee.getLastName());
          employee.setGid(++currentId);

          empMap.put(employee.getGid(), employee);

          return Response.ok(employee).build();
   }
   
   @DELETE
      @Path("/employees/{id}/")
   public Response deleteEmployee (@PathParam("id") String id) {
    System.out.println("----invoking deleteEmployee, Employee id is: " + id);
           long idNumber = Long.parseLong(id);
           Employee emp = empMap.get(idNumber);

           Response res;
           if (emp != null) {
               res = Response.ok().build();
               empMap.remove(idNumber);
           } else {
               res = Response.notModified().build();
           }

           return res;
   }
   
   @Path("/projects/{pid}/")
   public Project getProject(@PathParam("pid") String pid) {
    System.out.println("----invoking getProject, Project id is: " + pid);
    long idNumber = Long.parseLong(pid);
       Project prj = prjMap.get(idNumber);
       return prj;
   }

  }





  ---------- Forwarded message ----------
  From: Sergey Beryozkin <[EMAIL PROTECTED]>
  Date: Jul 7, 2008 7:11 AM
  Subject: Re: CXF + Spring + Tomcat
  To: [email protected], [EMAIL PROTECTED]

  Hi

  It's likely that you may need to add a @Path("/") annotation to your
  com.cxf.rs.service.EmployeeService resource class.

  If you're using the code from  the latest trunk you'd likely get a
  different type of message (no root resource class is found) if @Path() were 
missing so
  in this case another possible reason for a failure is that you don't have a 
method with a @GET request.
  Cheers, Sergey

  P.S.
  By the way, it might make sense to start using a qualifier like JAX-RS in 
subjects due to th efact there's a learge community of JAX-WS CXF users so that 
users not interested in JAX-RS could filter such messages out - and it would 
help with getting some statistics as well...
  I'll update the docs... 



    Hi,

    I am using the JSR-311 example with Tomcat + Spring configration. When I am
    starting my Tomcat, the following error occured. Please help. Thanks in
    advance!

    Here is my bean.xml


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans";
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
     xmlns:jaxrs="http://cxf.apache.org/jaxrs";
     xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://cxf.apache.org/jaxrs
    http://cxf.apache.org/schemas/jaxrs.xsd";>

     <import resource="classpath:META-INF/cxf/cxf.xml" />
     <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml"
    />
     <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

     <jaxrs:server id="employeeSer" address="/">
      <jaxrs:serviceBeans>
        <bean class="com.cxf.rs.service.EmployeeService" />
      </jaxrs:serviceBeans>
     </jaxrs:server>

    </beans>

    In web.xml, I have:

    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>WEB-INF/beans.xml</param-value>
     </context-param>
     <listener>
      <listener-class>
        org.springframework.web.context.ContextLoaderListener
      </listener-class>
     </listener>

    Error:
    Jul 5, 2008 12:02:15 AM org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor
    handleMessage
    SEVERE: No operation found for path: /, contentType: */*, Accept
    contentType: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
    application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
    application/x-shockwave-flash, */*
    Jul 5, 2008 12:02:15 AM org.apache.cxf.phase.PhaseInterceptorChain
    doIntercept
    INFO: Interceptor has thrown exception, unwinding now
    org.apache.cxf.interceptor.Fault: .No operation matching request path / is
    found, ContentType : */*, Accept : image/gif, image/x-xbitmap, image/jpeg,
    image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint,
    application/msword, application/x-shockwave-flash, */*.
    at
    
org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:120)
    at

----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland

Reply via email to