2014-12-22 2 views
0

어제부터 Jersey 1.18로 기본적인 RESTful 웹 서비스를 구축하려고했지만 어쨌든 Eclipse에서 직접 시도했을 때 Weblogic에 배포 할 수 없었습니다. 나중에 나는 eclipse에서 war 파일을 내보내고 Weblogic Console을 사용하여 성공적으로 배포했다. Eclipse에서 REST 서비스 (Jersey 1.18)를 직접 전개하기 위해 Eclipse 내에서 구성해야하는 것이 있습니까?REST Webservice with Weblogic12c + Jersey 1.18 + Eclipse Juno

자원 등급 : - - :

package com.ericsson.rest; 

import javax.ws.rs.Consumes; 
import javax.ws.rs.GET; 
import javax.ws.rs.PUT; 
import javax.ws.rs.Path; 
import javax.ws.rs.Produces; 


@Path("/TestResource") 
public class TestResource { 
    /** 
    * Default constructor. 
    */ 
    public TestResource() { 
     // TODO Auto-generated constructor stub 
    } 


    /** 
    * Retrieves representation of an instance of TestResource 
    * @return an instance of String 
    */ 
    @GET 
    @Produces("text/html") 
    public String resourceMethodGET() { 
     // TODO Auto-generated method stub 
     return "<html>Hello Roy</html>"; 
    } 

    /** 
    * PUT method for updating or creating an instance of TestResource 
    * @content content representation for the resource 
    * @return an HTTP response with content of the updated or created resource. 
    */ 
    @PUT 
    @Consumes("text/html") 
    public void resourceMethodPUT(String content) { 
     // TODO Auto-generated method stub 
     //throw new UnsupportedOperationException(); 
    } 
} 

응용 프로그램의 서브 클래스 : -

package rest.application.config; 

import java.util.Set; 
import javax.ws.rs.core.Application; 
import javax.ws.rs.ApplicationPath; 

@ApplicationPath("test") 
public class ApplicationConfig extends Application { 

    public Set<Class<?>> getClasses() { 
     return getRestClasses(); 
    } 

    //Auto-generated from RESTful web service wizard 
    private Set<Class<?>> getRestClasses() { 
     Set<Class<?>> resources = new java.util.HashSet<Class<?>>(); 

     resources.add(com.ericsson.rest.TestResource.class); 
     return resources;  
    } 
} 

배포 설명자 : -

<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> 
    <display-name>JAX_RS</display-name> 
    <servlet> 
     <servlet-name>RestServlet</servlet-name> 
     <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> 
     <init-param> 
      <param-name>javax.ws.rs.Application</param-name> 
      <param-value>rest.application.config.ApplicationConfig</param-value> 
     </init-param> 
    </servlet> 
    <servlet-mapping> 
     <servlet-name>RestServlet</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 
    <welcome-file-list> 
    <welcome-file>index.html</welcome-file> 
    <welcome-file>index.htm</welcome-file> 
    <welcome-file>index.jsp</welcome-file> 
    <welcome-file>default.html</welcome-file> 
    <welcome-file>default.htm</welcome-file> 
    <welcome-file>default.jsp</welcome-file> 
    </welcome-file-list> 
</web-app> 

아래의 소스 및 배포 설명입니다 리소스를 가져 오기위한 URL : -

http://localhost:7001/JAX_RS/test/TestResource 

미리 감사드립니다.

+0

수동 배포 중에 문제가없는 Eclipse에서 배포 할 때 어떤 오류가 있습니까? –

+0

netbeans 사용 :) –

답변