Reputation: 321
I have developed a Rest-full WS which runs successfully on tomcat.
The application deploys succesfully in Weblogic 12.2.1 without any exceptions. However, on hitting the URI, I face "HTTP method GET is not supported by this URL Rest-full WS" in response.
This happens for POST methods as well and while generating wadl also.
Below is the Rest WS implemation class
@POST
@Path("/activateService")
@Consumes({MediaType.APPLICATION_XML})
@Produces({MediaType.APPLICATION_XML})
public Response crunchifyREST**(JsonObject model**, @Context
HttpServletRequest request) {
}
@GET
@Path("/verify")
@Produces(MediaType.TEXT_PLAIN)
public Response verifyRESTService(InputStream incomingData) {
String result = "GMPPMediatorTIMService Successfully started..";
// return HTTP response 200 in case of success
return Response.status(200).entity(result).build();
}
web.xml :-
<servlet>
<servlet-name>FacadeHandsetTimpay</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.trivnet.mediator.tim.services</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacadeHandsetTimpay</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I am using URI as :- http://localhost:8070/FacadeHandsetTimpay/api/getLastTimPayTransactions
I checked below links , however I could find any help HTTP method GET is not supported by this URL. (Java rest api with jersey)
Upvotes: 1
Views: 1362
Reputation: 321
I got the solution . 12.2.1, WebLogic Server Jersey 1.x server-side APIs are no longer supported. You should use the corresponding standard JAX-RS 2.0 or Jersey 2.x APIs instead. The Jersey 1.x client API is deprecated. It is recommended that you update your RESTful client applications to use the JAX-RS 2.0 client APIs at your earliest convenience.
So , remove these dependencies:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0-m12</version>
And use these dependencies:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.17</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.17</version>
</dependency>
And also change web.xml as follows:-
<servlet>
<servlet-name>FacadeHandsetTimpay</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.trivnet.mediator.tim.services</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacadeHandsetTimpay</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
Source:- https://docs.oracle.com/middleware/12212/wls/RESTF/intro-restful-service.htm#RESTF109
Upvotes: 2