I am trying to deploy one war file to tomcat but the log file shows the following exception :
SEVERE: Servlet [rest] in web application [/sample] threw load() exception
java.lang.ClassCastException: org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration cannot be cast to javax.servlet.Servlet
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1148)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1087)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5253)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5543)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1930)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Here is the build.gradle file
repositories {
mavenCentral()
}
dependencies {
providedCompile 'org.apache.tomcat:tomcat-servlet-api:7.0.37'
providedCompile 'javax.servlet:javax.servlet-api:4.0.0-b01'
// Spring Framework Jars
compile 'org.springframework:spring-context:4.1.0'
compile 'org.springframework.ws:spring-ws-core:2.2.2.RELEASE'
compile 'org.springframework.data:spring-data-jpa:1.9.0.RELEASE'
// Spring Integration Jars
compile 'org.springframework.integration:spring-integration-core:4.1.2.RELEASE'
compile 'org.springframework.integration:spring-integration-stream:4.1.2.RELEASE'
compile 'org.springframework.integration:spring-integration-jms:4.1.2.RELEASE'
compile 'org.springframework.integration:spring-integration-xml:4.1.2.RELEASE'
compile 'org.springframework.integration:spring-integration-http:4.1.2.RELEASE'
compile 'org.springframework.integration:spring-integration-mail:4.1.2.RELEASE'
compile 'org.springframework:spring-webmvc:4.2.2.RELEASE'
compile 'org.springframework.data:spring-data-rest-webmvc:2.4.0.RELEASE'
// Spring Batch Framework Jars
compile 'org.springframework.batch:spring-batch-infrastructure:3.0.4.RELEASE'
compile 'org.springframework.batch:spring-batch-core:3.0.4.RELEASE'
// Log4j Jar
compile 'log4j:log4j:1.2.17'
// IBM JMS MQ Jars
compile 'com.ibm:com.ibm.mq:7.0.1.0'
compile 'com.ibm:com.ibm.mq.jmqi:7.0.1.0'
compile 'com.ibm:com.ibm.mqjms:7.0.1.0'
compile 'javax.jms:jms-api:1.1-rev-1'
// Hibernate JARS
compile 'org.hibernate:hibernate-entitymanager:5.0.1.Final'
//Oracle JDBC Jar
compile 'com.oracle:ojdbc6:11.2.0.3.0'
//Mail Jar
compile 'javax.mail:javax.mail-api:1.5.4'
}
And this is my web.xml file .
<web-app>
<display-name>sample Web Application</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/config/sample-servlet.xml</param-value>
</context-param>
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
I have tried to exclude "javax.servlet-api " ,but with no avail .
If anyone can help me in finding the reason behind this exception ,that would be of great help .
Thanks
Made a silly mistake ,instead of using
"org.springframework.data.rest.webmvc.RepositoryRestDispatcherServlet"
,i used
"org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration"
.
Hope after seeing this post other people will not make the same mistake
Related
previously my project was on jdk 6 with jboss 4.i upgraded from jdk6 to jdk8 . When i was using jdk 8 with jboss4 it was working properly but after upgrading jboss 4 with wildfly 15 i am getting below error.
in web.xml i configured crystalReportViewer as given below .wildfly 15 is giving error but when i removed the crystalReportConfiguration line then its working properly..
enter code here
<context-param>
<param-name>crystal_image_uri</param-name>
<param-value>crystalreportviewers</param-value>
</context-param>
<context-param>
<param-name>crystal_image_use_relative</param-name>
<param-value>webapp</param-value>
</context-param>
<servlet>
<servlet-name>CrystalReportViewerServlet</servlet-name>
<servlet-class>com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CrystalReportViewerServlet</servlet-name>
<url-pattern>/CrystalReportViewerHandler</url-pattern>
</servlet-mapping>
Caused by:
org.jboss.as.server.deployment.DeploymentUnitProcessingException:
java.lang.ClassNotFoundException:
com.crystaldecisions.report.web.viewer.CrystalReportViewerServlet from
[Module "deployment.ubarms.war" from Service Module Loader] at
org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.checkDeclaredApplicationClassAsServlet(JaxrsScanningProcessor.java:437)
at
org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.scanWebDeployment(JaxrsScanningProcessor.java:278)
at
org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor.deploy(JaxrsScanningProcessor.java:109)
at
org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:144)
... 8 more
I am using the Gradle plugin in Eclipse to create a JSF project. I am running the project on Tomcat 9. When I attempt run on server in Eclipse, I get the java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet exception.
My gradle.build looks like this:
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
apply plugin: 'war'
apply plugin: 'eclipse'
apply plugin: 'eclipse-wtp'
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
api 'org.apache.commons:commons-math3:3.6.1'
implementation 'com.google.guava:guava:21.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
//Jersey
implementation 'org.glassfish.jersey.containers:jersey-container-servlet:2.26'
implementation 'org.glassfish.jersey.inject:jersey-hk2:2.26'
implementation 'org.glassfish.jersey.core:jersey-common:2.26'
//JAXB
implementation 'org.glassfish.jersey.media:jersey-media-json-jackson:2.26'
//Javax Servlet
implementation 'javax.servlet:javax.servlet-api:3.1.0'
//JSF
implementation 'org.glassfish:javax.faces:2.2.16'
}
eclipse {
wtp {
facet {
facet name: "java", version: "1.8" // Java version
facet name: "jst.web", version: "3.1" // Dynamic Web Application
facet name: "jst.jsf", version: "2.2" // Java Server Faces
facet name: "wst.jsdt.web", version: "1.0" // JavaScript
}
}
}
project.webAppDirName='WebContent'
My web.xml looks like this:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4" id="WebApp_ID">
<display-name>com.xxx</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
I can see that gradle has added the correct library to my resources:
I cannot think of anything else that could be wrong. Any help is appreciated.
UPDATE: If I build a WAR file from the project, and then import that WAR as a new Dynamic Web Project, it runs fine, with no errors. So, there is obviously some other issue going on here, probably related to Gradle.
UPDATE2:
Stack Trace:
SEVERE: Servlet [Faces Servlet] in web application [/com.foo.bar] threw load() exception
java.lang.ClassNotFoundException: javax.faces.webapp.FacesServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1275)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1104)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:540)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:521)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1032)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:971)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4765)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5075)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:839)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1427)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1417)
at java.util.concurrent.FutureTask.run(Unknown Source)
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
at java.util.concurrent.AbstractExecutorService.submit(Unknown Source)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:258)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:422)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:770)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.startup.Catalina.start(Catalina.java:682)
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:353)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:493)
Build Path:
Class location:
Changing "implementation" to "compile" for the required libraries fixed the issue.
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java Library project to get you started.
* For more details take a look at the Java Libraries chapter in the Gradle
* user guide available at https://docs.gradle.org/3.5/userguide/java_library_plugin.html
*/
// Apply the java-library plugin to add support for Java Library
apply plugin: 'java-library'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:21.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
//Jersey
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.26'
compile 'org.glassfish.jersey.inject:jersey-hk2:2.26'
compile 'org.glassfish.jersey.core:jersey-common:2.26'
//JAXB
compile 'org.glassfish.jersey.media:jersey-media-json-jackson:2.26'
//Javax Servlet
compile 'javax.servlet:javax.servlet-api:3.0.1'
//JSF
compile 'org.glassfish:javax.faces:2.2.16'
compile 'javax.inject:javax.inject:1'
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.25.1'
}
eclipse {
wtp {
facet {
facets = []
facet name: "java", version: "1.8" // Java version
facet name: "jst.web", version: "3.0" // Dynamic Web Application
facet name: "jst.jsf", version: "2.2" // Java Server Faces
facet name: "wst.jsdt.web", version: "1.0" // JavaScript
}
}
}
project.webAppDirName='WebContent'
I am using Webshpere 7 and my Java version is 1.6. My Struts version is 1.1. When I start my server I get the following error:
com.ibm.ws.webcontainer.servlet.ServletWrapper run [Servlet Error]-[class java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet]: java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.apache.struts.action.ActionServlet
at java.beans.Beans.instantiate(Unknown Source)
at java.beans.Beans.instantiate(Unknown Source)
at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1682)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1673)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.initialize(ServletWrapper.java:1581)
at com.ibm.wsspi.webcontainer.extension.WebExtensionProcessor.createServletWrapper(WebExtensionProcessor.java:98)
at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:936)
at com.ibm.ws.webcontainer.webapp.WebApp.getServletWrapper(WebApp.java:857)
at com.ibm.ws.webcontainer.webapp.WebApp.initializeTargetMappings(WebApp.java:538)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:360)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:292)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:99)
at com.ibm.ws.webcontainer.VirtualHostImpl.addWebApplication(VirtualHostImpl.java:167)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApp(WSWebContainer.java:722)
at com.ibm.ws.webcontainer.WSWebContainer.addWebApplication(WSWebContainer.java:607)
at com.ibm.ws.webcontainer.component.WebContainerImpl.install(WebContainerImpl.java:376)
at com.ibm.ws.webcontainer.component.WebContainerImpl.start(WebContainerImpl.java:668)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:1162)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.fireDeployedObjectStart(DeployedApplicationImpl.java:1313)
at com.ibm.ws.runtime.component.DeployedModuleImpl.start(DeployedModuleImpl.java:611)
at com.ibm.ws.runtime.component.DeployedApplicationImpl.start(DeployedApplicationImpl.java:938)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.startApplication(ApplicationMgrImpl.java:740)
at com.ibm.ws.runtime.component.ApplicationMgrImpl.start(ApplicationMgrImpl.java:2092)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:437)
at com.ibm.ws.runtime.component.CompositionUnitImpl.start(CompositionUnitImpl.java:122)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.start(CompositionUnitMgrImpl.java:380)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl.access$300(CompositionUnitMgrImpl.java:105)
at com.ibm.ws.runtime.component.CompositionUnitMgrImpl$CUInitializer.run(CompositionUnitMgrImpl.java:928)
at com.ibm.wsspi.runtime.component.WsComponentImpl$_AsynchInitializer.run(WsComponentImpl.java:349)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1527)
I have included the struts jar and it is in my build path. My servlet is defined in web.xml as:
<servlet id="Servlet_1165231311172">
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>mapping</param-name>
<param-value>mj.cchp.actionMapping.CCHPActionMapping</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>validate</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
I uninstalled the application from my server, deleted the files from the profile and tried to redeploy the application but I got the following error:
java.lang.UnsupportedOperationException
at com.genuitec.eclipse.j2eedt.core.internal.project.WTPEarProject.getWorkareaDirectoryPath(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.packaging.DefaultPackagerStrategy.getBuildFolder(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.packaging.DefaultPackagerStrategy.initBuildArea(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.DeploymentUtil.copyDeploymentAssemblyLibraries(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.EARDeployment.ą(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.EARDeployment.doProjectTypeSpecificPostResyncAll(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.Deployment.resyncAll(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.EARDeployment.resyncAll(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.Deployment.resyncAll(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.EARDeployment.deployAsExplodedArchive(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.Deployment.deploy(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.jobs.C.ā(Unknown Source)
at com.genuitec.eclipse.ast.deploy.core.jobs.C.run(Unknown Source)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
There was the a problem with the EAR being created. I deleted the application, restarted the server and redeployed the application which solved it.
You need to add jar with Struts to your application. Build path is good in your development environment, but to run it must be somehow in the classpath during runtime. The easiest is as Steve C suggested - to add struts.jar to your WEB-INF/lib.
This kind of java.lang.ClassNotFoundException can manifest sometimes when a dependent class is not available.
Make sure that you application has access to the dependent jars as well, such as:
commons-beanutils
commons-digester
commons-logging
etc
I am trying to deploy a rest web service in WAS 8.0
The application EAR is getting installed successfully.
However, both on publishing as well as on hitting the service from web browser after publishing, I am getting below error:
[3/13/14 13:42:20:652 IST] 00000024 servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper run SRVE8052E: Logging ClassNotFoundException
java.lang.ClassNotFoundException: class java.lang.ClassNotFoundException: org.apache.cxf.transport.servlet.CXFServlet
at java.beans.Beans.instantiate(Beans.java:190)
at java.beans.Beans.instantiate(Beans.java:75)
at com.ibm.ws.webcontainer.servlet.ServletWrapper$1.run(ServletWrapper.java:1471)
at com.ibm.ws.security.util.AccessController.doPrivileged(AccessController.java:118)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.loadServlet(ServletWrapper.java:1460)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.load(ServletWrapper.java:1358)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:982)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3751)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:962)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1662)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:195)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1690)
However, the jar containing the class viz. cxf-rt-transports-http-2.7.4.jar is present inside lib directory of the WAR inside the EAR installed.
What is the cause of the issue ?
How can I resolve it ?
Update: My web.xml is as below:
<web-app>
<display-name>MyService</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CXFServlet</servlet-name>
<display-name>CXF Servlet</display-name>
<servlet-class>
org.apache.cxf.transport.servlet.CXFServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CXFServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
</web-app>
I see that you mentioned the word "publish", which hints that you might be using Eclipse, or possibly IBM's RAD or even MyEclipse Blue.
In case that's true, read on...
While your .ear, generated by m2e/Maven, may have the .jar file present in the .war file, there's a chance that the .ear and .war file, generated by m2e-wtp, is missing the .jar file. m2e-wtp's generated .ear file is what's used when you publish/republish your application to WAS from within Eclipse/RAD/MyEclipse Blue.
Try removing the app from your local WAS, finding the location of that m2e-wtp-generated .ear file, and deleting it. From there, m2e-wtp should automatically generate a fresh .ear file if you clean your project (all associated pom, ear, war, etc.)
When you publish your app, it should find the class. I've had the same problem happen to me in the past. My suggestion has fixed the problem.
Other than that, you may need to set the Classloader Policy to PARENT_LAST and check that you're using a single classloader for the entire app (the 2nd set of radio buttons below the Classloader Policy radio buttons) within the WAS admin console. However, I doubt that the Classloader Policy is the issue.
I cannot get My tomcat server to work with my WAR file.
I am using jersey 1.14 and It is running fine through tomcat 6 in eclipse. But when I upload the war to my remote tomcat 6 server I receive the following error when i try access the site.
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet Jersey REST Service threw exception
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:679)
root cause
java.lang.UnsupportedClassVersionError: com/shafer/server/server : Unsupported major.minor version 51.0 (unable to load class com.shafer.server.server)
org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:2822)
org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:1159)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1647)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:264)
com.sun.jersey.core.reflection.ReflectionHelper.classForNameWithException(ReflectionHelper.java:238)
com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.getClassForName(AnnotationScannerListener.java:222)
com.sun.jersey.spi.scanning.AnnotationScannerListener$AnnotatedClassVisitor.visitEnd(AnnotationScannerListener.java:186)
org.objectweb.asm.ClassReader.accept(Unknown Source)
org.objectweb.asm.ClassReader.accept(Unknown Source)
com.sun.jersey.spi.scanning.AnnotationScannerListener.onProcess(AnnotationScannerListener.java:136)
com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner$1.f(FileSchemeScanner.java:86)
com.sun.jersey.core.util.Closing.f(Closing.java:71)
com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scanDirectory(FileSchemeScanner.java:83)
com.sun.jersey.core.spi.scanning.uri.FileSchemeScanner.scan(FileSchemeScanner.java:71)
com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:225)
com.sun.jersey.core.spi.scanning.PackageNamesScanner.scan(PackageNamesScanner.java:141)
com.sun.jersey.api.core.ScanningResourceConfig.init(ScanningResourceConfig.java:80)
com.sun.jersey.api.core.PackagesResourceConfig.init(PackagesResourceConfig.java:104)
com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:78)
com.sun.jersey.api.core.PackagesResourceConfig.<init>(PackagesResourceConfig.java:89)
com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:700)
com.sun.jersey.spi.container.servlet.WebComponent.createResourceConfig(WebComponent.java:678)
com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:203)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:374)
com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:557)
javax.servlet.GenericServlet.init(GenericServlet.java:212)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:602)
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
java.lang.Thread.run(Thread.java:679)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.35 logs.`
here is 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_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>shafer</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.shafer.server</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Your .war was compiled under a newer JDK than the JRE that is available on the remote tomcat. Either install a matching JRE on the remote server or recompile your project with the correct version of the JDK.
This line should give you a clou:
java.lang.UnsupportedClassVersionError: com/shafer/server/server :
Unsupported major.minor version 51.0
(unable to load class com.shafer.server.server)
What is com.shafer.server.server? Check the versions of your libraries.
The UnsupportedClassVersionError means that the class was compiled with a more recent Java compiler than the one you are using in your runtime.
I don't know the version numbers by hearth, but you should probably use a JRE 6 or higher to run Tomcat.