java.lang.NoSuchFieldError: APPLICATION_CONTEXT_ID_PREFIX in Eclipse project [duplicate] - java

I am receiving this error on running my project and the result is 404 ultimately. The project is made on Spring framework.
I read a lot of posts and found that there is either a mix up of jars or extra jars. Following which I tried to organize my jars. The following list is what I have in my build path:
antlr-2.7.6.jar
asm.jar
asm-attrs.jar
cglib-2.2.jar
commons-beanutils-1.7.0.jar
commons-collections-3.1.jar
commons-digester-1.8.jar
commons-email-1.0.jar
commons-fileupload-1.1.1.jar
commons-io-1.2.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
displaytag-1.0-b3.jar
dom4j-1.6.1.jar
ehcache-1.1.jar
hibernate3.jar
hibernate-jpa-2.0-api-1.0.0.Final.jar
hibernate-validator-4.0.2.GA.jar
hsqldb.jar
itext-2.1.3.jar
javassist-3.12.0.GA.jar
jdom.jar
jstl-1.2.jar
jta-1.1.jar
log4j-1.2.14.jar
msbase.jar
mssqlserver4v65.jar
msutil.jar
mysql.jar
mysql-connector-java-5.1.15-bin.jar
ojdbc14.jar
persistence-api-1.0.jar
poi-3.0-alpha2.jar
servlet-2.3.jar
slf4j-api-1.6.6.jar
slf4j-log4j12-1.5.6.jar
slf4j-simple-1.6.6.jar
spring-asm-3.0.3.RELEASE.jar
spring-beans-3.0.3.RELEASE.jar
spring-context-3.0.3.RELEASE.jar
spring-core-3.0.3.RELEASE.jar
spring-expression-3.0.3.RELEASE.jar
spring-hibernate3-2.0.8.jar
spring-web-3.0.3.RELEASE.jar
spring-webmvc-3.0.3.RELEASE.jar
sqljdbc4.jar
standard.jar
tree.jar
validation-api-1.0.0.GA.jar
wloracle.jar
wlsqlserver.jar
Here goes the stacktrace
SEVERE: Error loading WebappClassLoader
delegate: false
repositories:
/WEB-INF/classes/
----------> Parent Classloader:
org.apache.catalina.loader.StandardClassLoader#ca2dce
org.springframework.web.servlet.DispatcherServlet
java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1360)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1206)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1083)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4058)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4364)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:516)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
at org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:315)
at org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:420)
at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:483)
at org.apache.jasper.compiler.Parser.parseElements(Parser.java:1433)
at org.apache.jasper.compiler.Parser.parse(Parser.java:133)
at org.apache.jasper.compiler.ParserController.doParse(ParserController.java:216)
at org.apache.jasper.compiler.ParserController.parse(ParserController.java:103)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:153)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Unknown Source)
I have deleted many jars, which I thought, are repetitive.
My question is whether all these jars are exactly enough or are there duplicates?
Please help, this 404 is killing me...

You have a lot of duplicated jars there:
antlr
jta
mysql-connector
javassist
mssqlserver
I would make sure you only have one of each before continuing, work out which version you need and include that one.
If you are not sure how to do this, let us know how you are importing your dependencies.
It would also be helpful to see the stacktrace you are seeing and a simplified Spring context that causes the error.
If you look at this question: JasperException: absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved
You need to make sure you have the right version of JSTL, maybe once you remove the duplicate JSTL it may fix that error.

My guess would be deleting spring.jar and spring-1.2.6.jar ; they conflict with spring*3.0.3.RELEASE.jars
And my two cents would be using maven when working with spring framework.

Related

java.lang.NoClassDefFoundError: javax/el/ELException

I am working on a web application and I have been facing this issue for a while after looking at multiple post I still was unable to solve this issue. I'm using tomcat 7.0.23 which provides el-api which i believe is the jar thought to be missing. I have not included any jar files in the WEB-INF/lib folder at all I am adding all of my dependencies through pom.xml because of maven. I have attempted all of the possible quick fixes i could think of including maven clean/install server clean(multiple times), project clean, adding tomcat to the targeted runtimes. in my build path is tomcat, jdk1.6, and maven)
The pom.xml and web.xml files that I am using are identical my other team members and they are currently working so i don't believe the issue is there.
Here is the error I am getting when starting the server
SEVERE: Exception sending context initialized event to listener instance of class org.apache.myfaces.webapp.StartupServletContextListener
java.lang.NoClassDefFoundError: javax/el/ELException
at org.apache.myfaces.webapp.AbstractFacesInitializer._createFacesContext(AbstractFacesInitializer.java:403)
at org.apache.myfaces.webapp.AbstractFacesInitializer.initStartupFacesContext(AbstractFacesInitializer.java:376)
at org.apache.myfaces.webapp.StartupServletContextListener.contextInitialized(StartupServletContextListener.java:105)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5260)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1525)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1515)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.ClassNotFoundException: javax.el.ELException
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at sun.misc.Launcher$ExtClassLoader.findClass(Launcher.java:229)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 13 more
these are the dependices after a maven clean/ install
activation-1.1.jar
antlr-2.7.7.jar
aopalliance-1.0.jar
asm-3.3.1.jar
captcha-0.0.1-SNAPSHOT.jar
cmu_time_awb-0.0.1-SNAPSHOT.jar
cmu_us_kal-0.0.1-SNAPSHOT.jar
cmudict04-0.0.1-SNAPSHOT.jar
cmulex-0.0.1-SNAPSHOT.jar
cmutimelex-0.0.1-SNAPSHOT.jar
commons-beanutils-1.8.3.jar
commons-cli-1.2.jar
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-digester-1.8.1.jar
commons-el-1.0.jar
commons-fileupload-1.2.1.jar
commons-io-1.3.1.jar
commons-lang-2.6.jar
commons-logging-1.1.1.jar
commons-pool-1.5.4.jar
commons-validator-1.3.1.jar
cxf-api-2.7.0.jar
cxf-rt-bindings-soap-2.7.0.jar
cxf-rt-bindings-xml-2.7.0.jar
cxf-rt-core-2.7.0.jar
cxf-rt-databinding-jaxb-2.7.0.jar
cxf-rt-frontend-jaxrs-2.7.0.jar
cxf-rt-frontend-jaxws-2.7.0.jar
cxf-rt-frontend-simple-2.7.0.jar
cxf-rt-transports-http-2.7.0.jar
cxf-rt-ws-addr-2.7.0.jar
cxf-rt-ws-policy-2.7.0.jar
dom4j-1.6.1.jar
ejb3-persistence-1.0.2.GA.jar
en_us-0.0.1-SNAPSHOT.jar
freemarker-2.3.9.jar
freetts-0.0.1-SNAPSHOT.jar
freetts-jsapi10-0.0.1-SNAPSHOT.jar
geronimo-javamail_1.4_spec-1.7.1.jar
hibernate-annotations-3.4.0.GA.jar
hibernate-commons-annotations-3.1.0.GA.jar
hibernate-core-3.3.1.GA.jar
javassist-3.4.GA.jar
javax.ws.rs-api-2.0-m10.jar
jaxb-impl-2.1.13.jar
jcaptcha-1.0-mod-0.0.1-SNAPSHOT.jar
jdom-1.1.jar
jettison-1.0.jar
jsf-facelets-1.1.6.jar
jta-1.1.jar
jtds-1.2.4.jar
junit-4.7.jar
jxl-2.6.12.jar
log4j-1.2.17.jar
mail-1.4.5.jar
myfaces-api-2.1.0.jar
myfaces-impl-2.1.0.jar
neethi-3.0.2.jar
oro-2.0.8.jar
primefaces-3.3.jar
slf4j-api-1.6.6.jar
slf4j-log4j12-1.6.6.jar
spring-aop-3.0.6.RELEASE.jar
spring-asm-3.0.6.RELEASE.jar
spring-batch-core-2.0.3.RELEASE.jar
spring-batch-infrastructure-2.0.3.RELEASE.jar
spring-beans-3.0.6.RELEASE.jar
spring-context-3.0.6.RELEASE.jar
spring-context-support-3.0.6.RELEASE.jar
spring-core-3.0.6.RELEASE.jar
spring-expression-3.0.6.RELEASE.jar
spring-jdbc-3.0.6.RELEASE.jar
spring-ldap-core-1.3.1.RELEASE.jar
spring-ldap-core-tiger-1.3.1.RELEASE.jar
spring-ldap-ldif-batch-1.3.1.RELEASE.jar
spring-ldap-ldif-core-1.3.1.RELEASE.jar
spring-ldap-odm-1.3.1.RELEASE.jar
spring-orm-3.0.6.RELEASE.jar
spring-test-3.0.6.RELEASE.jar
spring-tx-3.0.6.RELEASE.jar
spring-web-3.0.6.RELEASE.jar
stax2-api-3.1.1.jar
tomahawk-1.1.6.jar
velocity-1.6.2.jar
woodstox-core-asl-4.1.4.jar
wsdl4j-1.6.2.jar
xml-apis-1.0.b2.jar
xml-resolver-1.2.jar
xmlschema-core-2.0.3.jar
xpp3_min-1.1.4c.jar
xstream-1.3.jar
The “javax.el.ExpressionFactory” class belongs to the “el-api.jar” library, you can download it from Maven central repository.
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<version>2.2</version>
</dependency>
and place it in tomcat/lib directory.
Alternative Solution

How to use catalina.jar

I'm using websocket function of tomcat 7.0.39, so I have to include catalina.jar into my classpath. But when I deploy my project, if I deploy the jar files into WEB-INF/lib, I get the following exception:
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
and when catalina.jar is not deployed, I get ClassNotFoundException:
java.lang.ClassNotFoundException: org.apache.catalina.websocket.MessageInbound
Someone please help me.
StackTrace:
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
at org.apache.tomcat.util.IntrospectionUtils.callMethod1(IntrospectionUtils.java:802)
at org.apache.tomcat.util.digester.SetNextRule.end(SetNextRule.java:201)
at org.apache.tomcat.util.digester.Digester.endElement(Digester.java:1057)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:604)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1759)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2915)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:525)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1543)
at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1694)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1197)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:882)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:317)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:89)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5081)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
at org.apache.catalina.startup.Catalina.start(Catalina.java:620)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
The web socket support in 7.0.x is experiemental (and will soon be deprecated and replaced with a port of the JSR 356 implementation from Tomcat 8).
A side-effect of this is that the API can and does change between point releases. Therefore, you must compile your code againt the Tomcat JARs from the Tomcat version you intend to deploy on. There errors you are seeing are an indication of a version mis-match.
There is no need to package any Tomcat JARs in your web application.
Do you really need to put the catalina.jar in your classpath. Catalina.jar should already be present in tomcat/lib directory. Tomcat class loader will load the jar from its own lib directory and hence it is the parent class loader so your classpath or application catalina.jar will not picked. Hope you will be able to resolve your problem with this information.
You are getting NoSuchMethodDefinition error, which means the jar which you are using for compiling has that method but the jar, which is loaded for execution does not have that method definition. Check with replacing the catalina.jar in tomcat/lib with the jar that you are using for compiling your code.

Exception coming while running JSP

I am getting this exception while running any JSP on my tomcat5.5 server.Do I need to add any JAR ??? Please Help.
StackTrace:
DEBUG http-8181-Processor25 org.apache.catalina.loader.WebappClassLoader - Loading class from parent
FATAL http-8181-Processor25 org.apache.jasper.runtime.JspFactoryImpl - Exception initializing page context
java.lang.NoSuchMethodError: org.apache.tomcat.util.http.ServerCookie.appendCookieValue(Ljava/lang/StringBuffer;ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZZ)V
at org.apache.catalina.connector.Response.addCookieInternal(Response.java:970)
at org.apache.catalina.connector.Request.doGetSession(Request.java:2285)
at org.apache.catalina.connector.Request.getSession(Request.java:2031)
at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:832)
at org.apache.catalina.connector.RequestFacade.getSession(RequestFacade.java:843)
at org.apache.jasper.runtime.PageContextImpl._initialize(PageContextImpl.java:136)
at org.apache.jasper.runtime.PageContextImpl.initialize(PageContextImpl.java:113)
at org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:105)
at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:62)
at org.apache.jsp.banner_jsp._jspService(banner_jsp.java:33)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Thread.java:619)
DEBUG http-8181-Processor25 org.apache.catalina.loader.WebappClassLoader - loadClass(javax.servlet.jsp.PageContext, false)
Check if you have tomcat-coyote.jar in $CATALINA_BASE/shared/lib/ folder. If exist somehow its not being loaded to classpath while starting server. Check you have this line in conf/catalina.properties
server.loader=${catalina.home}/server/classes,${catalina.home}/server/lib/*.jar
If yes then may be you need to update. What enviornment you are using.
I think the issue is more of the jar versions you are using or jars you are in your class path. It is trying to point to in correct class version due to which the required method is unavailable. Which all jars are already set in your classpath?
You are not missing any jars. Otherwise you would have got ClassNotFound exception. The NoSuchMethodError indicates that the jars are not compatible. Did you by any chance change(or copy from different location) the jar files in /lib, espcially jasper*.jar, tomcat-coyote?

Tomcat Restart automatically Web Application on startup, after error

I've a big trouble on tomcat.
Before explaine, let me tell is the first time I see something like this...
I'm building an application using JPA on Hibernate, Spring 3.0 and Jersey REST Framework.
When using glassfish, everything works fine, but deployng the same application on tomcat, I registered the following error code:
GRAVE: Error deploying configuration descriptor java-zero.xml
java.lang.NoClassDefFoundError: com/sun/jersey/spi/container/servlet/ServletContainer
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2527)
at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1010)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1483)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1095)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:993)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4187)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4496)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:637)
at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:563)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:498)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
... 34 more
Then tomcat restarts the application and again, the same error. In an infinite loop.
Looks like a library conflict, but I really don't have any ideas on how to solve it...
Any suggestion is appreciated!
Ciao, Davide.
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer suggests that you either don't have the Jersey JAR file or you've put it in the wrong place.
If it's the former, download it here and add it to Tomcat.
If it's the latter, put it and all its dependencies in either your WEB-INF/lib, server/lib for Tomcat 5.x or lib for Tomcat 6.x. (Just one, not all.)
It works with Glassfish because they've bundled it for you. Tomcat has not.
Remove all Jersey JAR from /WEB_INF/lib folder, refresh project and again paste all JARs of Jersey library into /WEB_INF/lib. Refresh project, stop server again, deploy and run.
It looks like either jersey.jar and/or jsr311-api.jar are missing from your webapp. You might check they are in the WEB-INF/lib folder.

ClassNotFoundException in Hibernate

I am getting the following error when I am trying to run my J2EE project. The same project was working before and I started getting this exception now. I am sure that all class are there along with their mapping files.
If I remove mapping of jobtitle from my hibernate.cfg.xml in the project, it is running.
java.lang.ExceptionInInitializerError
hrm.dao.HibernateUtil.<clinit>(HibernateUtil.java:28)
hrm.dao.AbstractDAO.<init>(AbstractDAO.java:29)
hrm.dao.JobSpecificationDAO.<init>(JobSpecificationDAO.java:22)
hrm.actions.JobSpecificationAction.execute(JobSpecificationAction.java:53)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:414)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
java.lang.ClassNotFoundException: hrm.dao.Jobtitle
java.lang.ClassNotFoundException: hrm.dao.Jobtitle
means you do indicate a mapping in your hibernate.cfg.xml, but a mapping to a class which is not in the classpath of the j2ee project.

Categories