I get a HTTP Status 404 - Requested resource (/Fun/hello) is not available.
I am running Tomcat 7.0, Jersey 1.8, Java 1.6, Eclipse Helios 2.
I am working from a tutorial by Lars Vogel.
As far as I can tell, the resource is being loaded:
INFO: Root resource classes found:
class bighello.Hello
web.xml
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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">
<display-name>Fun</display-name>
<servlet>
<servlet-name>Jersey REST Service</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>bighello</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
Any ideas?
In the web.xml , you only map one URL pattern , which is /rest/* to call the servlet.
But now , your request URL is /Fun/hello , which does not match any URL patterns you defined in the web.xml , so it returns HTTP Status 404
In fact, refer to section 3.4 of your mentioned tutorial , you should test your REST service under: http://localhost:8080/de.vogella.jersey.first/rest/hello.
Related
Getting this error why trying to deploy the war in weblogic
Caused By: weblogic.management.DeploymentException: [HTTP:101170]The
servlet Web Rest Services is referenced in servlet-mapping /myrest/*
but not defined in web.xml.
at weblogic.servlet.internal.WebAppServletContext.verifyServletMappings(WebAppServletContext.java:1465)
at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:2809)
at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1661)
at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:822)
at weblogic.application.internal.ExtensibleModuleWrapper$StartStateChange.next(ExtensibleModuleWrapper.java:360)
my web.xml:
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>REST</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey Web Application</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>rest.apis</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Web Rest Services</servlet-name>
<url-pattern>/myrest/*</url-pattern>
</servlet-mapping>
</web-app>
If required I can paste the code of rest resources but not sure it matters.
What worries me, can there be issue with weblogic?
Note: Recently app server was upgraded to weblogic 12.1.2
<servlet-name --> Jersey Web Application != Web Rest Services
The <servlet-name> in the <servlet-mapping> should correspond to a <servlet-name> in a <servlet> definition. Hence the error
The servlet Web Rest Services is referenced in servlet-mapping /myrest/* but not defined in web.xml
Try this configuration for your web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" 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">
<display-name>NAME</display-name>
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>YOUR REST CLASS PACKAGE</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
</web-app>
And create an weblogic.xml file in the same folder (web-app\WEB-INF) like this:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app">
<library-ref>
<library-name>jax-rs</library-name>
<specification-version>2.0</specification-version>
<implementation-version>2.5.1</implementation-version>
<exact-match>false</exact-match>
</library-ref>
<container-descriptor>
<prefer-application-packages>
<package-name>org.glassfish.jersey.media.*</package-name>
<package-name>org.glassfish.jersey.client.*</package-name>
<package-name>org.glassfish.jersey.servlet.*</package-name>
<package-name>org.glassfish.jersey.jaxb.internal.*</package-name>
<package-name>com.sun.research.ws.wadl.*</package-name>
<package-name>org.glassfish.hk2.*</package-name>
<package-name>org.jvnet.hk2.*</package-name>
<package-name>jersey.repackaged.org.objectweb.asm.*</package-name>
<package-name>org.objectweb.asm.*</package-name>
<package-name>com.sun.ws.rs.ext.*</package-name>
<package-name>org.aopalliance.*</package-name>
<package-name>javax.annotation.*</package-name>
<package-name>javax.inject.*</package-name>
<package-name>javax.ws.rs.*</package-name>
<package-name>jersey.repackaged.com.google.common.*</package-name>
<package-name>javassist.*</package-name>
</prefer-application-packages>
</container-descriptor>
<context-root>YOUR_ROOT</context-root>
</weblogic-web-app>
Here is the snapshotI am trying to develop the Restful Web-service but whenever I am trying to tun my application on server it shows :
HTTP status 404 - /RESTfulWS/
type Status report
message /RESTfulWS/
description The requested resource is not available.
My web.xml file contains :
display-name RESTful display-name
<servlet>
<servlet-name>Jersey REST Service</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.student</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
I have a google app engine connected project (in eclipse juno) and it contains a simple servlet file but for some reason when I run the project ,the corresponding class file is not getting created inside WEB-INF/classes folder, in fact there is no classes folder inside WEB-INF. and hence I am unable to run the servlet.I will appreciate if someone could suggest some solution.
Below is my web.xml file->
<?xml version="1.0" encoding="utf-8" standalone="no"?><web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet>
<servlet-name>SystemServiceServlet</servlet-name>
<servlet-class>com.google.api.server.spi.SystemServiceServlet</servlet-class>
<init-param>
<param-name>services</param-name>
<param-value>com.queryname.DeviceInfoEndpoint,com.queryname.MessageEndpoint</param-value>
</init-param>
<servlet-name>QueryServiceServlet</servlet-name>
<servlet-class>com.queryname.QueryTest</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SystemServiceServlet</servlet-name>
<url-pattern>/_ah/spi/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>QueryServiceServlet</servlet-name>
<url-pattern>/Query/*</url-pattern>
</servlet-mapping>
</web-app>
I get the following exception-->
WARNING: Failed startup of context com.google.appengine.tools.development.DevAppEngineWebAppContext#684528a3{/,C:\Users\User8\workspace\QueryName-AppEngine\war}
java.lang.IllegalStateException: No such servlet: QueryServiceServlet
Regards,
Laura.
Move your <servlet-name> and <servlet-class> into their own <servlet> and see if this solves the problem. currently they are under the <servlet> element of the SystemServiceServlet.
I create Facebook JSP Application. I use Restful Java Client Web Services. And created .java file. in this file have Servlet. but can not deploy it into the hosting. I deployed follow
WEB-INF
-classes
-facebook
-socialnetworkingservice
-facebookresponse
......and many classes
-META-INF
-org
-my
-facebook
-client
FacebookClient$FacebookCallbackServlet.class
FacebookClient$FacebookLoginServlet.class
FacebookClient.class
-lib
..lib files
-web.xml
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" 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_2_5.xsd">
<servlet>
<servlet-name>FacebookClient$FacebookLoginServlet</servlet-name>
<servlet-class>org.my.facebook.client.FacebookClient$FacebookLoginServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>FacebookClient$FacebookCallbackServlet</servlet-name>
<servlet-class>org.my.facebook.client.FacebookClient$FacebookCallbackServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FacebookClient$FacebookLoginServlet</servlet-name>
<url-pattern>/FacebookLoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FacebookClient$FacebookCallbackServlet</servlet-name>
<url-pattern>/FacebookCallbackServlet/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
META-INf ( I think it is not important)
I compile localhost and have (MyFbFriend.war)
and I get this error
"Not Found
The requested URL /FacebookLoginServlet was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
Try
http://localhost:8080/MyFbFriend/FacebookLoginServlet/
The name of the War gives the Context of the App
I developed few web services using Eclipse and Jersey and Tomcat 7 as the server.
When running the project from Eclipse, everything works fine. However, when deploying the project WAR file directly to Tomcat (using it's manager), I'm getting 404 error when calling the service.
My WEB-INF\lib directory contains all jersey libs.
my web.xml:
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 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>myApp</display-name>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>myApp REST Service</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.myapp.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>myApp REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I believe I'm missing something on the Tomat configuration, but have no idea...
Any idea?
Ahanks,
Assaf
ok...
problem solved by taking the following two actions:
a. configuring the following entries of \tomcat\conf\server.xml, replacing the "localhost" attribute with the actual server name:
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
b. taking care of windows firewall, to allow inbound http:8080. I'm feeling a bit embarrassed - for some reason I thought setting the Amazon security rules was enough (-:
Thanks for your attention.
Assaf
Try This one ...
<servlet>
<servlet-name>jersey-serlvet</servlet-name>
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.hrms.admin.jersey.service</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey-serlvet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
Visit This one : Jersey