Reputation: 41
type here
I am trying to build REST API, I have created the web application project using maven and included jersey dependencies in pom.xml file. Also I have included web.xml file and weblogic.xml file in web-inf folder. when deployed and execute the URL path index.jsp is working fine. but other URL is not working it show the Not found. Unable to find what is wrong.
Web.xml file
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
<display-name>Rest service</display-name>
<servlet>
<servlet-name>Jersey Web Application</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.vno.testaddress</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/webapi/*</url-pattern>
</servlet-mapping>
</web-app>
weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
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_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">
<wls:weblogic-version>14.1.1.0</wls:weblogic-version>
<wls:context-root>/address</wls:context-root>
<wls:container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.glassfish.jersey.*</wls:package-name>
<wls:package-name>io.swagger.core.*</wls:package-name>
<wls:package-name>io.swagger.parser.*</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
</wls:weblogic-web-app>
Java code:
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
/**
* Hello world!
*
*/
@Path("myresource")
public class Testaddress
{
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getIt() {
return "Hello world!";
}
}
Error:
I am trying to use this url :http://192.168.77.10:7001/testaddress-0.0.1-SNAPSHOT/webapi/myresource and expecting the result as "Hello World!" but it shows not found.
Upvotes: 0
Views: 924
Reputation: 135
I see 2 potential issues:
Let me know
Upvotes: 0