When starting the a servlet (from eclipse), I'm getting the following error:
It's tomcat 7 and the servlet is REST.
INFO: validateJarFile(C:\beezer\WebServerWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BeezerServer\WEB-INF\lib\geronimo-j2ee_1.4_spec-1.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
448 [localhost-startStop-1] ERROR org.apache.wink.server.internal.servlet.RestServlet - com.test.AddressBookApplication<br />
java.lang.ClassNotFoundException: com.test.AddressBookApplication<br />
at
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1711)<br/>
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1556)<br/>
at java.lang.Class.forName0(Native Method)<br/>
at java.lang.Class.forName(Class.java:169)<br/>
at org.apache.wink.server.internal.servlet.RestServlet.getApplication(RestServlet.java:144)<br/>
at org.apache.wink.server.internal.servlet.RestServlet.createRequestProcessor(RestServlet.java:105)<br/>
at org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:81)<br/>
at javax.servlet.GenericServlet.init(GenericServlet.java:160)<br/>
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)<br/>
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)<br/>
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)<br/>
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)<br/>
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)<br/>
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)<br/>
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)<br/>
at java.util.concurrent.FutureTask.run(FutureTask.java:138)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br/>
at java.lang.Thread.run(Thread.java:662)<br/>
Aug 30, 2012 7:49:41 PM org.apache.catalina.core.ApplicationContext log<br/>
INFO: Marking servlet JAX-RS Servlet as unavailable<br/>
Aug 30, 2012 7:49:41 PM org.apache.catalina.core.StandardContext loadOnStartup<br/>
SEVERE: Servlet /BeezerServer threw load() exception<br/>
javax.servlet.UnavailableException: com.test.AddressBookApplication<br/>
at org.apache.wink.server.internal.servlet.RestServlet.init(RestServlet.java:91)<br/>
at javax.servlet.GenericServlet.init(GenericServlet.java:160)<br/>
at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1266)<br/>
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1185)<br/>
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1080)<br/>
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)<br/>
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314)<br/>
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)<br/>
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)<br/>
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)<br/>
at java.util.concurrent.FutureTask.run(FutureTask.java:138)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)<br/>
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)<br/>
at java.lang.Thread.run(Thread.java:662)<br/>
Aug 30, 2012 7:49:41 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
My web.XML:
<?xml version="1.0" encoding="UTF-8"?><br/> <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<br/> http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>BeezerServer</display-name>
<servlet>
<description>JAX-RS Tools Generated - Do not modify</description>
<servlet-name>JAX-RS Servlet</servlet-name>
<servlet-class>org.apache.wink.server.internal.servlet.RestServlet</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.test.AddressBookApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>JAX-RS Servlet</servlet-name>
<url-pattern>/jaxrs/*</url-pattern>
</servlet-mapping>
Does anyone has a clew?
thanks!
First check that this class really exists. Check class name and package. Does it belong to the web project or dependent project?
If everything is OK, refresh project, then run Project/Clean, then clean and re-publish tomcat. If it does not work create server again (I mean in eclipse). If it still does not work go to C:\beezer\WebServerWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BeezerServer\WEB-INF\classes (the path is taken from your log) and check that the class file is there.
Good luck and welcome to the club of people that spend night fighting against the bugs in plugin of tomcat for eclipse...
Get rid of C:\beezer\WebServerWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\BeezerServer\WEB-INF\lib\geronimo-j2ee_1.4_spec-1.1.jar It contains the class Servlet.java, which should be provided by the AS itself. If you are using Maven, mark the dependency as provided (<scope>provided</scope>)
Btw. the jar is still needed for compilation, but not in runtime.
EDIT: Oh, now I've noticed, it is only INFO in the log. So it is not the source of the problem, the root cause is the ClassNotFound ex. Make sure the class is on the classpath.
Related
I am trying to introduce Jersey web service into a web application that has other web services (such as Apache CXF in it) in it. So I added Jersey servlet to my web.xml..
<servlet>
<servlet-name>jersey-servlet</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.freedomoss.crowdcontrol.api</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-servlet</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
During intiliazation this servlet gives the following error about conflicting URL templates...
INFO: Registering Spring bean, restApiService, of type com.mycompany.ws.RestApiService as a root resource class
Mar 12, 2015 11:07:42 PM com.sun.jersey.spi.spring.container.SpringComponentProviderFactory registerSpringBeans
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
SEVERE: Conflicting URI templates. The URI template / for root resource class com.mycompany.ws.RestApiService and the URI template / transform to the same regular expression (/.*)?
When I look in the code of this RestApiService, I see..
#Path("/")
#Service
public class RestApiService extends AbstractRestService {
Since this other web service is being used elsewhere in the application I cannot change the value of 'Path' although doing so does solve my problem
What else can I do? Can I somehow tell Jersey Servlet not to register this other web service "as a root resource class"?
My goal is to make Jersey work along with this other web service and not change the latter in any way.
When i am running my simple Java code for RESTful Web Services (JAX-RS), it throws 404 error. I have mapped it will in web.xml and have no compilation error. One suspecios message i am getting in my log is " INFO: No provider classes found. ", please suggest me to eliminate this problem.
Console Log -:
May 31, 2014 10:23:27 AM org.apache.catalina.startup.HostConfig checkResources
INFO: Reloading context [/rest]
May 31, 2014 10:23:27 AM com.sun.jersey.api.core.PackagesResourceConfig init
INFO: Scanning for root resource and provider classes in the packages:
stk5
May 31, 2014 10:23:27 AM com.sun.jersey.api.core.ScanningResourceConfig logClasses
INFO: Root resource classes found:
class stk5.ConversionService
May 31, 2014 10:23:27 AM com.sun.jersey.api.core.ScanningResourceConfig init
INFO: No provider classes found.
May 31, 2014 10:23:27 AM com.sun.jersey.server.impl.application.WebApplicationImpl _initiate
INFO: Initiating Jersey application, version 'Jersey: 1.18 11/22/2013 01:21 AM'
my ConversionService.java file -:
package stk5;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
#Path("ConversionService")
public class ConversionService{
#GET
#Path("/InchToFeet/{i}")
#Produces(MediaType.TEXT_XML)
public String convertInchToFeet(#PathParam("i") int i) {
int inch=i;
double feet = 0;
feet =(double) inch/12;
return "<InchToFeetService>"
+ "<Inch>" + inch + "</Inch>"
+ "<Feet>" + feet + "</Feet>"
+ "</InchToFeetService>";
}
#Path("/FeetToInch/{f}")
#GET
#Produces(MediaType.TEXT_XML)
public String convertFeetToInch(#PathParam("f") int f) {
int inch=0;
int feet = f;
inch = 12*feet;
return "<FeetToInchService>"
+ "<Feet>" + feet + "</Feet>"
+ "<Inch>" + inch + "</Inch>"
+ "</FeetToInchService>";
}
}
my Web.xml file -:
<?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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>restApp</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>stk5</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>
Instead of mentioning the URL pattern in web.xml I would recommend you to put this in your Service #Path.
You should so consider your context root, if you have not set it then by default it is your Deployment (war/ear/jar etc) name.
So modify your <url-pattern>/rest/*</url-pattern> to <url-pattern>/*</url-pattern>. Now your URL should look something like this
http://localhost:8080/[context root]/ConversionService/InchToFeet/2
What URL are you going to in order to test it? The context is /rest and your path is /InchToFeet/{i}, so are you going to /rest/InchToFeet/<num>?
Edit: I also noticed you have a #Path("ConversionService") on the class. That would make your URL /restConversionService/InchToFeet/<num>. You might want to precede the ConversionService with a slash to make it /rest/ConversionService/InchToFeet/<num>.
This question already has answers here:
java.lang.IllegalArgumentException: The servlets named [X] and [Y] are both mapped to the url-pattern [/url] which is not permitted
(7 answers)
Closed 7 years ago.
I am migrating an existing project from Tomcat 6 to 7. Upon startup I am encountering this logged error message:
Jul 02, 2013 2:38:39 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/padd/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/padd/WEB-INF/web.xml; lineNumber: 309; columnNumber: 21; Error at (309, 21) : The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
...
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: The servlets named [ArtefactServlet] and [saveArtefactServlet] are both mapped to the url-pattern [/saveRestoration] which is not permitted
Here the WEB-INF/web.xml line 309fff:
<servlet-mapping>
<servlet-name>saveArtefactServlet</servlet-name>
<url-pattern>/saveRestoration</url-pattern>
</servlet-mapping>
EDIT:
<servlet-mapping>
<servlet-name>ArtefactServlet</servlet-name>
<url-pattern>/saveRestoration</url-pattern>
</servlet-mapping>
Here tomcat's web.xml:
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<!-- The mappings for the JSP servlet -->
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
<url-pattern>*.jspx</url-pattern>
</servlet-mapping>
I tried to play around with the mapping, but couldn't make any progress. Hope you can help!
The error says :
The servlets named [ArtefactServlet] and [saveArtefactServlet] are
both mapped to the url-pattern [/saveRestoration] which is not
permitted
So tomcat doesn't know which servlet to be called when your url pattern is matched. Give different url patterns for these two servlets ArtefactServlet, saveArtefactServlet
java.lang.IllegalArgumentException: The servlets named...
I fetched this cause where I create new servlet in different package (name='syncro'). My servlet located in syncro.SynchronizeServlet
And when I add information about this servlet in deployment descriptor (web.xml) I catch error: IllegalArgumentException
Example of incorrect descriptor part:
<servlet>
<description></description>
<display-name>SynchronizeServlet</display-name>
<servlet-name>SynchronizeServlet</servlet-name>
<servlet-class>SynchronizeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>SynchronizeServlet</servlet-name>
<url-pattern>/SynchronizeServlet</url-pattern>
<url-pattern>/SynServlet</url-pattern>
</servlet-mapping>
When I add correct path for servlet - error disappeared. Correct desc below:
<servlet>
<description></description>
<display-name>syncro.SynchronizeServlet</display-name>
<servlet-name>syncro.SynchronizeServlet</servlet-name>
<servlet-class>syncro.SynchronizeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>syncro.SynchronizeServlet</servlet-name>
<url-pattern>/SynchronizeServlet</url-pattern>
<url-pattern>/SynServlet</url-pattern>
</servlet-mapping>
==> 73!
I created a small web application with resteasy 2.3.4 Final, and I deployed it to Tomcat 7.0.30. I got the following error message when tomcat starts:
...
INFO: JSF1048: PostConstruct/PreDestroy annotations present. ManagedBeans methods marked with these annotations will have said annotations processed.
Sep 11, 2012 9:28:08 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter org.jboss.resteasy.plugins.server.servlet.Filter30Dispatcher
java.lang.NoClassDefFoundError: javax/enterprise/context/spi/Contextual
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2404)
...
My web.xml is as follows:
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/services</param-value>
</context-param>
<context-param>
<param-name>resteasy.scan.resources</param-name>
<param-value>true</param-value>
</context-param>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
Problem solved by removing the resteasy-cdi-2.3.4.Final.jar.
that happen to me either but with tomcat 7.0.52 and resteasy-cdi-3.0.6.Final
i removed the resteasy-cdi-3.0.6.Final form the library package and it deployed well
Here is what I'm trying to do: we are switching over to using JAXB and Jersey for all our REST services and XML/JSON serialization needs.
So far, I have been able to get a simple test working where some beans are annotated, some test objects created and these are perfectly serialized to either XML or JSON and return to the client upon request. I mostly wrote this based on some of the examples around the Internet, where the an HTTPServer is created and started in the main method.
I am now trying to put this same example into a WAR file and deploy it to my local Tomcat server so I can test it in a more production-like environment. Seeing as I was not able to get it to work on Tomcat 5.5.27 following the instructions here I went ahead and upgraded to Tomcat 6.0. Same instructions, same outcome, a huge InvocationTargetException.
What exactly am I missing guys?
INFO: Scanning for root resource and provider classes in the paths:
/Library/Tomcat/Home/webapps/user/WEB-INF/lib
/Library/Tomcat/Home/webapps/user/WEB-INF/classes
Sep 9, 2009 7:22:32 PM com.sun.jersey.api.core.ClasspathResourceConfig init
INFO: Root resource classes found:
class example.HelloWorld
Sep 9, 2009 7:22:32 PM com.sun.jersey.api.core.ClasspathResourceConfig init
INFO: Provider classes found:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.sun.jersey.impl.application.WebApplicationImpl$DefaultComponentProvider.getInstance(WebApplicationImpl.java:437)
at com.sun.jersey.impl.application.ComponentProviderCache.getComponent(ComponentProviderCache.java:187)
at com.sun.jersey.impl.application.ComponentProviderCache.getProvidersAndServices(ComponentProviderCache.java:122)
at com.sun.jersey.impl.application.InjectableProviderFactory.configure(InjectableProviderFactory.java:113)
at com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:582)
at com.sun.jersey.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:487)
at com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:622)
at com.sun.jersey.spi.container.servlet.ServletContainer.load(ServletContainer.java:538)
at com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:197)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1173)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4149)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4458)
That's part of the ginormous spew in catalina.out.
Also, here is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5">
<servlet>
<servlet-name>ServletAdaptor</servlet-name>
<servlet-class>com.sun.jersey.impl.container.servlet.ServletAdaptor</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ServletAdaptor</servlet-name>
<url-pattern>/resources/*</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>
Any help with this would be greatly appreciated! Thanks in advance.
You have probably a conflict somewhere, check your jar files and see if there are no duplicate classes. Use Tattletale to locate the problem
**Caused by: java.lang.NoSuchMethodError: javax.ws.rs.ext.Providers.getContextResolver(Ljava/lang/Class;Ljavax/ws/rs/core/MediaType;)Ljavax/ws/rs/ext/ContextResolver;**
at com.sun.jersey.impl.provider.entity.AbstractJAXBProvider.<init>(AbstractJAXBProvider.java:81)
at com.sun.jersey.impl.provider.entity.AbstractRootElementProvider.<init>(AbstractRootElementProvider.java:67)
at com.sun.jersey.impl.provider.entity.XMLRootElementProvider.<init>(XMLRootElementProvider.java:66)
at com.sun.jersey.impl.provider.entity.XMLRootElementProvider$App.<init>(XMLRootElementProvider.java:72)
... 41 more