ClassNotFoundException: javax.ws.rs.client.ClientBuilder - java

I´m trying to consume a Jersey Rest Service from a Web Application (Dynamic Web App in eclispe) as follows:
Client client = ClientBuilder.newBuilder().build(); // Here is the error
WebTarget target = client.target("url/rest").path("List");
String result = target.request(MediaType.TEXT_PLAIN).get(String.class);
When debugging in the line ClientBuilder.newBuilder() the system throws the ClassNotFoundException: javax.ws.rs.client.ClientBuilder error, but the same code, in a java project works perfect.
Full trace:
javax.servlet.ServletException: Error instanciando clase de servlet test
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
causa raíz
java.lang.NoClassDefFoundError: javax/ws/rs/client/ClientBuilder
test.<init>(test.java:27)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
causa raíz
java.lang.ClassNotFoundException: javax.ws.rs.client.ClientBuilder
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1324)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1177)
test.<init>(test.java:27)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:526)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1078)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:655)
org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)

So here it comes ;)
First for the understanding:
javax.ws.rs.client is the standard package for RESTFul client implementations. Developers should programm against this interface.
At runtime you need an implementation of this interface in your classpath. Thats where projects like resteasy or jersey comes in.
Second:
In eclipse the buildpath and classpath settings only efect the environment in eclipse. When you put something in there manualy, it exist only in eclipse.
Third:
When you developing a webapplication depending on the Java EE webprofile you have automaticly access to all bundled packages of your application server like tomcat or jboss.
If your application uses more packages you have to distribute them together with your application. To do this you can place your third party jars under "WEB-INF/libs" in your project. When it is deployed to your application server, jars inside this folder are automaticly placed in your classpath of your app.
Fourth (about your solution):
Putting third party libs in the application server lib or endorsed directy make them accessable to all applications deployed on this application server and adds more complexity into your app server setup and maintenance.

Related

Why tomcat not serving for request after moving some files into it on running state?

I have five application which are running on tomcat-8.5.4. I moved any of the files(like .wav,.txt,.jsp and etc) under any one of the application. The tomcat getting stuck after few mins or hour.I don't know exact time when this issue will happen. I did not get any solution for this. so please help me to resolve the issue.
Note : The below issue occurred frequently once it started.
catlina error log line :
15-Apr-2020 07:44:18.784 SEVERE [http-nio-8080-exec-10] org.apache.coyote.http11.Http11Processor.service Error processing request
java.lang.NullPointerException
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:389)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
15-Apr-2020 07:44:18.784 SEVERE [http-nio-8080-exec-10] org.apache.coyote.http11.Http11Processor.endRequest Error finishing response
java.lang.NullPointerException
at org.apache.coyote.http11.Http11OutputBuffer.flushBuffer(Http11OutputBuffer.java:533)
at org.apache.coyote.http11.Http11OutputBuffer.endRequest(Http11OutputBuffer.java:318)
at org.apache.coyote.http11.Http11Processor.endRequest(Http11Processor.java:1787)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1149)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
at org.apache.tomcat.util.net.Socket
ProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)

java.lang.NoClassDefFoundError: org/apache/axiom/om/OMNode

Im having error its says java.lang.NoClassDefFoundError: org/apache/axiom/om/OMNode
in my java web application. By the way im implementing the servlet to call the dataservice in wso2 data service.
Here's the full stack trace:
type Exception report
message Error instantiating servlet class org.wso2.sample.RegisterpatientServlet
description The server encountered an internal error that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Error instantiating servlet class org.wso2.sample.RegisterpatientServlet
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: org/apache/axiom/om/OMNode
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.ClassNotFoundException: org.apache.axiom.om.OMNode
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1891)
org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1734)
java.lang.Class.getDeclaredConstructors0(Native Method)
java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
java.lang.Class.getConstructor0(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082)
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Unknown Source)
Thank You Please Help! Im having hard time in this..
An easy way to make this class available to your web application is to put the axiom.jar file in your WEB-INF/lib folder.
The apache axiom library is not in your classpath. If you use maven, make sure that it is in your pom.xml. if it's there, make sure that it has the runtime scope: <scope>runtime</scope>.
Add below dependency to your project. (Change version as you want)
https://mvnrepository.com/artifact/org.apache.ws.commons.axiom/axiom-impl/1.2.6

integrating apache tomcat and solr

I am trying to integrate apache tomcat (version 7)and solr (version 4) and i am getting this error :
HTTP Status 500 - {msg=SolrCore 'collection1' is not available due to init failure:
The filename, directory name, or volume label syntax is incorrect,
trace=org.apache.solr.common.SolrException: SolrCore 'collection1' is not available due to init failure: The filename, directory name, or volume label syntax is incorrect at
org.apache.solr.core.CoreContainer.getCore(CoreContainer.java:1212) at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:248) at
org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:155) at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241) at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208) at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218) at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122) at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169) at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103) at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956) at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116) at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442) at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1082) at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:623) at
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316) at
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at
java.lang.Thread.run(Unknown Source) Caused by:
org.apache.solr.common.SolrException: The filename, directory name, or volume label syntax is incorrect at
org.apache.solr.core.SolrCore.<init>(SolrCore.java:821) at
org.apache.solr.core.SolrCore.<init>(SolrCore.java:618) at
org.apache.solr.core.CoreContainer.createFromLocal(CoreContainer.java:949) at
org.apache.solr.core.CoreContainer.create(CoreContainer.java:984) at
org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:597) at
org.apache.solr.core.CoreContainer$2.call(CoreContainer.java:592) at
java.util.concurrent.FutureTask.run(Unknown Source) 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) ... 1 more
Caused by: java.io.IOException: The filename, directory name, or volume label syntax is incorrect at
java.io.WinNTFileSystem.canonicalize0(Native Method) at java.io.Win32FileSystem.canonicalize(Unknown Source)
at java.io.File.getCanonicalPath(Unknown Source) at
org.apache.solr.core.StandardDirectoryFactory.normalize(StandardDirectoryFactory.java:47)
at org.apache.solr.core.SolrCore.initIndex(SolrCore.java:462) at
org.apache.solr.core.SolrCore.<init>(SolrCore.java:745) ... 11 more ,code=500}
please help me fix it!
Go to Solrconfig.xml and there will be a tag called as data directory , so just try to hard code the required path , if it works , then you can conclude that it is the root cause of the issue .
You can add the following java environment variable in tomcat startup configuration (in JAVA_OPTS for example).
-Dsolr.solr.home=<your solr.xml path>

.Jar file in .war file does not get database connection tomcat java

I have a Webservice which passes a string to a method of a jarfile. In the method are some database operations.
I created a .war file and wanted to run it in tomcat 8. But no changes are made in the database.
I googled a lot about tomcat database connections, but it looks like to me, that every tutorial is for webservice which directly use the database.
I somehow think that the jarfile should make the database connections without changes in the tomcat config or the code. in the cmd my jar is working fine.
What Informations do you need to know? I was not shure if anycode will be helpful. If you need something just tell me.
Edit:
I added the Tomcat to the eclipse environment. I created an easy webservice to test if tomcat is the problem. The answer was, that the other webservice were running in eclipse.
I created a dynamic web project added the main project as external jarfile.
I wrote the java class
import javax.jws.WebMethod;
import de.morpheus.chatbot.brain.io.datasource.DataSourceDB;
import de.morpheus.chatbot.model.*;
public class WSTEST {
private BotInit chatbot = new BotInit(new DataSourceDB());
#WebMethod
public String communicate(String input) {
return this.chatbot.processInput(input);
}
I right-clicked on the wetest.java in the project explorer and created the webservice.
type:Bottom UP
*StartService
*TestClient
*Monitoring the webservice
Then I clicked finish.
The Web Services Test Client window opened, and all MEthods worked except communication.
Here is the error
Feb 17, 2015 9:25:17 PM org.apache.axis.transport.http.AxisServlet logException
INFORMATION: Exception:
java.lang.NoClassDefFoundError: de/morpheus/chatbot/brain/io/datasource/DataSource
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.axis.utils.ClassUtils$2.run(ClassUtils.java:177)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.axis.utils.ClassUtils.loadClass(ClassUtils.java:160)
at org.apache.axis.utils.ClassUtils.forName(ClassUtils.java:142)
at org.apache.axis.utils.cache.ClassCache.lookup(ClassCache.java:85)
at org.apache.axis.providers.java.JavaProvider.getServiceClass(JavaProvider.java:428)
at org.apache.axis.providers.java.JavaProvider.initServiceDesc(JavaProvider.java:461)
at org.apache.axis.handlers.soap.SOAPService.getInitializedServiceDesc(SOAPService.java:286)
at org.apache.axis.deployment.wsdd.WSDDService.makeNewInstance(WSDDService.java:500)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getNewInstance(WSDDDeployableItem.java:274)
at org.apache.axis.deployment.wsdd.WSDDDeployableItem.getInstance(WSDDDeployableItem.java:260)
at org.apache.axis.deployment.wsdd.WSDDDeployment.getService(WSDDDeployment.java:427)
at org.apache.axis.configuration.FileProvider.getService(FileProvider.java:231)
at org.apache.axis.AxisEngine.getService(AxisEngine.java:311)
at org.apache.axis.MessageContext.setTargetService(MessageContext.java:756)
at org.apache.axis.handlers.http.URLMapper.invoke(URLMapper.java:50)
at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
at org.apache.axis.server.AxisServer.invoke(AxisServer.java:239)
at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:644)
at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:516)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1086)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:659)
at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:223)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1558)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1515)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: de.morpheus.chatbot.brain.io.datasource.DataSource
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
... 48 more
I have to admit I have no clue, what the log is saying me.

ClassNotFoundException after Changing Package Names in Eclipse

I am working on a Java Dynamic Web Project in Eclipse. Everything was running smoothly until I realized that my package names were uppercase, and decided to change them.
After changing them, I am getting ClassNotFoundExceptions at runtime. The code compiles fine. From what I understand, this is a runtime classpath issue.
The error is shown here:
javax.servlet.ServletException: Error instantiating servlet class
Controllers.LoginServlet
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.NoClassDefFoundError: Model/Converter
db.UserHelper.(UserHelper.java:34)
Controllers.LoginServlet.(LoginServlet.java:36)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
root cause
java.lang.ClassNotFoundException: Model.Converter
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
db.UserHelper.(UserHelper.java:34)
Controllers.LoginServlet.(LoginServlet.java:36)
sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source) java.lang.reflect.Constructor.newInstance(Unknown Source)
java.lang.Class.newInstance(Unknown Source)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
Here's a screenshot of my folder structure:
http://imgur.com/VJvJbeb
src/Controllers and src/Model were the packages I switched to lower case. I switched them back hoping to resolve the issue, but to no avail.
I tried checking my runtime classpath for the project by going to Run --> Run Configurations, but the project isn't listed there.
Here is a snapshot of my Web Deployment Assembly:
http://imgur.com/D0rg2aZ
Does anyone know how I might go about fixing this? Any help would be greatly appreciated.
Solution Found
Thanks for responses everyone. Thankfully I managed to fix the issue by:
Right clicking the project folder ---> Build Path ---> Configure Build Path
Navigating to Source tab
I saw that the default output folder was "WorkTicketSystem/build/classes." I switched this to "WorkTicketSystem/WebContent/WEB-INF/classes."
And, voila. I'm not exactly sure why or how my actions fixed the problem, but if anyone could explain I would be very interested to hear it. For now I am just happy that it runs.
In your web.xml, you have a reference to the class Model.Converter. You need to change this to model.Converter.
If we change the package name to uppercase we have to check whether all references with that package got modified or not. As you are saying that if you try to run package names with lower case is working fine. If you try to modify the package names with IDE that will ask for updating references also. Once check that.
NOTE: *As per java coding standards package names should be in lower case.*

Categories