I am currently trying to move a JAR from a deployed WAR to just being included in the Tomcat library. Here's the dependency in my pom.xml
<dependency>
<groupId>psft.pt8</groupId>
<artifactId>psjoa</artifactId>
<version>8.54.22</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
When scope is <scope>compile</scope> everything works fine. I build the artifact, deploy it in Tomcat, and can access the WSDL. When I change scope to provided, I can still build the artifact, deploy it in Tomcat, it LOOKS like it's fine, but then when attempting to go to the WSDL I reach this error.
The server encountered an internal error that prevented it from fulfilling this request: Servlet.init() for servlet spring-ws threw exception
javax.servlet.ServletException: Servlet.init() for servlet spring-ws threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
psiprobe.Tomcat80AgentValve.invoke(Tomcat80AgentValve.java:45)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:676)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:528)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1099)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:670)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1520)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1476)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
Not sure where to begin.
Solution 1.
If you don't want including artifact psft.pt8:psjoa:8.54.22 inside WAR generated artifact
use <scope>provided</scope> in pom.xml
put psft.pt8:psjoa:8.54.22 JAR file inside $CATALINA_HOME\lib (on macOS, Linux) or %CATALINA_HOME%\lib (on Windows operating system).
Solution 2.
If you want including artifact psft.pt8:psjoa:8.54.22 inside WAR generated artifact, use <scope>compile</scope> in pom.xml.
Related
This question already has answers here:
Deploying a JSF webapp results in java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config [duplicate]
(3 answers)
Closed 7 years ago.
When I am run my application after entering the URL, this exception is coming.I am using Eclipse and Tomcat7.0.35. I also added Jstl.jar and jstl1.2.jar
My code is
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559)
at org.apache.myfaces.view.jsp.JspViewDeclarationLanguage.buildView(JspViewDeclarationLanguage.java:91)
at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:78)
at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:241)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:199)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
The error is telling you it cannot find the class because it is not available in your application.
If you are using Maven, make sure you have the dependency for jstl artifact:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
If you are not using it, just make sure you include the JAR in your classpath. See this answer for download links.
Download the following jars and add it to your WEB-INF/lib directory:
jsp-api-2.0.jar
jstl-1.2.jar
By default, Tomcat container doesn’t contain any jstl library. To fix it, declares jstl.jar in your Maven pom.xml file if you are working in Maven project or add it to your application's classpath
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
Probably the jstl libraries are missing from your classpath/not accessible by tomcat.
You need to add at least the following jar files in your WEB-INF/lib directory:
jsf-impl.jar
jsf-api.jar
jstl.jar
Add jstl jar to your application classpath.
Just a quick comment: sometimes Maven does not copy the jstl-.jar to the WEB-INF folder even if the pom.xml has the entry for it.
I had to manually copy the JSTL jar to /WEB-INF/lib on the file system. That resolved the problem. The issue may be related to Maven war packaging plugin.
Add JSTL library as dependency to your project (javax.servlet.jsp.jstl.core.Config is a part of this package).
For example, if you were using Gradle, you could write in a build.gradle:
dependencies {
compile 'javax.servlet:jstl:1.2'
}
I had the same problem. Go to Project Properties -> Deployment Assemplbly and add jstl jar
I Created a Dynamic web project where the input parameters are coming from UI(Index.html) going to servlet.java, but when I am trying to call auth in oAuthBean.java file its giving me an error.
Attached navigation view:
Exception:
Aug 24, 2017 3:18:42 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [clientCredServlet1] in context with path [/Java-Credit-Offers-Example] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.http.HttpEntity
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1333)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1167)
at controller.clientCredServlet.doPost(clientCredServlet.java:45)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
It looks like your servlet uses Apache http client (that's where org.apache.http.HttpEntity is coming from), but corresponding dependency jar is not present in resulting deployment, most likely because there is a lack of configuration glue between Maven and Eclipse WTP plugin which deploys to and runs your Tomcat from IDE. That lack appeared because it seems that Maven project has been created outside of Eclipse.
Option 1. Leave things as is and do quickfix (worse)
Try executing under your project root folder:
mvn eclipse:eclipse -Dwtpversion=2.0
and reopen Eclipse workspace then
According to Maven Eclipse plugin documentation when the wtpversion flag is explicitly set, maven generates necessary workspace configuration for WTP plugins (including Tomcat one) in order to let them understand how to obtain Maven dependencies during deployments from Eclipse
Option 2. Rely on built-in IDE integration with Maven (best for long term)
Examine following great answer which, at some approximation, describes why, and how to rely on built-in Eclipse Maven support. This approach eliminates the problem with missing dependencies in IDE deployments as well, but requires more effort to migrate project onto, which however is quite minor while your project is at the beginning stage
After moving a Tomcat app from one server to the other, we get this error:
SEVERE: Servlet.service() for servlet dwr-invoker threw exception
java.lang.NoClassDefFoundError: org/directwebremoting/extend/ConvertUtil
at org.directwebremoting.dwrp.CallBatch.parseParameters(CallBatch.java:135)
at org.directwebremoting.dwrp.CallBatch.<init>(CallBatch.java:47)
at org.directwebremoting.dwrp.BaseCallHandler.handle(BaseCallHandler.java:72)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:120)
at org.directwebremoting.servlet.DwrServlet.doPost(DwrServlet.java:141)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
We have the dwr.jar in the WEB-INF/lib dir (and I opened it and checked, the org/directwebremoting/extend/ConvertUtil is there)
/srv/tomcat6/webapps/APPNAME/WEB-INF/lib/dwr.jar
UPDATE this is how DWR dependency is defined in the pom.xml
<dependency>
<groupId>org.directwebremoting</groupId>
<artifactId>dwr</artifactId>
<version>3.rc1</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/dwr.jar</systemPath>
</dependency>
Before you mark it as DUPLICATE please understand I've checked all the relevant links but to no avail.
I'm calling the following Service.
#Path("/courses")
public class CourseService {
// #GET
// #Produces(MediaType.TEXT_PLAIN)
// public String hello(){
// return "Hello World !!!";
// }
private DataService _service;
public CourseService(String jsonData) throws ParseException, IOException, JSONException {
_service = new DataService(jsonData);
}
#GET
#Produces(MediaType.APPLICATION_XML)
public ArrayList<Course> getAllCourses(){
return _service.get_handler().getAllCourses();
}
}
If I just run the commented portion of the code my application runs fine and produces "Hello World"
But then when I run my actual service it gives me the following error.
type Exception report
message Servlet.init() for servlet Jersey Web Application threw exception
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Servlet.init() for servlet Jersey Web Application threw exception
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoClassDefFoundError: org/json/JSONException
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
java.lang.Class.getConstructors(Class.java:1651)
org.glassfish.jersey.server.model.MethodHandler$ClassBasedMethodHandler.<init>(MethodHandler.java:265)
org.glassfish.jersey.server.model.MethodHandler.create(MethodHandler.java:155)
org.glassfish.jersey.server.model.ResourceMethod$Builder.createInvocable(ResourceMethod.java:550)
org.glassfish.jersey.server.model.ResourceMethod$Builder.build(ResourceMethod.java:536)
org.glassfish.jersey.server.model.Resource$Builder.processMethodBuilders(Resource.java:663)
org.glassfish.jersey.server.model.Resource$Builder.buildResourceData(Resource.java:599)
org.glassfish.jersey.server.model.Resource$Builder.build(Resource.java:655)
org.glassfish.jersey.server.model.Resource.from(Resource.java:798)
org.glassfish.jersey.server.ApplicationHandler.initialize(ApplicationHandler.java:465)
org.glassfish.jersey.server.ApplicationHandler.access$500(ApplicationHandler.java:184)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:350)
org.glassfish.jersey.server.ApplicationHandler$3.call(ApplicationHandler.java:347)
org.glassfish.jersey.internal.Errors.process(Errors.java:315)
org.glassfish.jersey.internal.Errors.process(Errors.java:297)
org.glassfish.jersey.internal.Errors.processWithException(Errors.java:255)
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:347)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:392)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:177)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:369)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1502)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1458)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
This is the structure of my Project Directory
I've tested my CourseService using a TestClient and it works fine. What am I doing wrong.
You shouldn't be defining dependencies like that. All your dependencies should be managed with something like maven or gradle. That being said, did you add it the jar to the class path?
Since your using maven, you would want to add this to your <dependencies> section. For example:
<dependencies>
<!-- other dependencies -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<!-- or w.e. version you wanted to use. -->
<!-- See http://mvnrepository.com/artifact/org.json/json-->
<version>20160212</version>
</dependency>
<!-- other dependencies -->
</dependencies>
Eclipse should automatically add dependencies like the one above to your class path.
Check out one of the official tutorials on maven: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
java.lang.NoClassDefFoundError: org/json/JSONException
Please make sure JSONException is defined and accessible.
I've lost hours trying to pinpoint this annoying issue. I've created a simple Java app that exposes a few REST services using Jersey.
When debugging the application in Eclipse, using a Tomcat 8 server, everything works fine. I then export the project to a WAR file, deploy it to a real Tomcat 8 server, and when I try to call the REST services, I get the below error. I've checked the obvious things: making sure I'm using the correct Java version on the server, making sure the libraries are included, ... But alas, I'm stuck.
type Exception report
message Servlet.init() for servlet Jersey REST Service threw exception
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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
root cause
java.lang.NoSuchMethodError: javax.ws.rs.core.Application.getProperties()Ljava/util/Map;
org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:309)
org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:338)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:171)
org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:363)
javax.servlet.GenericServlet.init(GenericServlet.java:158)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:617)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:668)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:745)
All important libraries for the project are added in the WEB-INF, which are the following:
aopalliance-repackaged-2.4.0-b10.jar
asm-debug-all-5.0.2.jar
commons-beanutils-1.9.2.jar
commons-collections-3.2.1.jar
commons-collections4-4.0.jar
commons-logging-1.2.jar
gson-2.3.1.jar
hk2-api-2.4.0-b10.jar
hk2-locator-2.4.0-b10.jar
hk2-utils-2.4.0-b10.jar
httpclient-4.4.1.jar
httpcore-4.4.1.jar
java-json.jar
javassist-3.18.1-GA.jar
javax.annotation-api-1.2.jar
javax.inject-2.4.0-b10.jar
javax.json-1.0.2.jar
javax.servlet-api-3.0.1.jar
javax.ws.rs-api-2.0.1.jar
jaxb-api-2.2.7.jar
jersey-client-1.7.jar
jersey-client.jar
jersey-common.jar
jersey-container-servlet-core.jar
jersey-container-servlet.jar
jersey-core-1.7.jar
jersey-guava-2.17.jar
jersey-json-1.7.jar
jersey-media-jaxb.jar
jersey-server.jar
joda-time-2.3.jar
log4j-1.2.17.jar
org.osgi.core-4.2.0.jar
org.restlet.ext.gson-2.3.1.jar
org.restlet.ext.json.jar
org.restlet.jar
osgi-resource-locator-1.0.1.jar
persistence-api-1.0.jar
unboundid-ldapsdk-se.jar
validation-api-1.1.0.Final.jar
I believe this is not because of missing jar.. I believe it is class loading issue. The jersey jars are not being loaded (or) might have been loaded the wrong version. Could you please check the dependencies properly and check for duplicate jars for jersey in your application.
Also Please try by undeploying appliation and deploying again.. This might remove all the classes that were already loaded for taht application and Tomcat might intialize class loading again..
Hope this works...