java.lang.NullPointerException: inStream parameter is null while loading a properties file - java

I have created a ZK web application project in Eclipse, and deployed the same in Apache Tomcat 9.0.37. And I have a properties file to be read(aws.properties) - which is located right under WEB-INF.
I am having difficulties loading the properties file - getting a NullpointeException
Eclipse ZK Project
Project Structure:
I tried all the 3 approaches below and all of them throws a java.lang.NullPointerException: inStream parameter is null at the line PROPERTIES.load(inputStream);
Code:
private static final String PROPERTIES_FILE = "aws.properties";
private static final Properties PROPERTIES = new Properties();
...
...
...
// APPROACH 1.
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(PROPERTIES_FILE);
// APPROACH 2.
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(PROPERTIES_FILE);
// APPROACH 3.
ClassLoader classLoader = getClass().getClassLoader();
InputStream inputStream = classLoader.getResourceAsStream(PROPERTIES_FILE);
PROPERTIES.load(inputStream);
Stacktrace:
java.lang.NullPointerException: inStream parameter is null
at java.base/java.util.Objects.requireNonNull(Objects.java:246)
at java.base/java.util.Properties.load(Properties.java:404)
at in.net.cadentic.core.database.AmazonDynamoDBClientHandler.createNewClient(AmazonDynamoDBClientHandler.java:75)
at in.net.cadentic.core.dao.UsermasterDao.findBypassword(UsermasterDao.java:27)
at in.net.cadentic.composers.LoginComposer.onClick$loginButton(LoginComposer.java:71)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.zkoss.zk.ui.event.GenericEventListener.onEvent(GenericEventListener.java:80)
at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3184)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3154)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3096)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:353)
at org.zkoss.zk.ui.event.Events.sendEvent(Events.java:377)
at org.zkoss.zk.ui.AbstractComponent$ForwardListener.onEvent(AbstractComponent.java:3629)
at org.zkoss.zk.ui.AbstractComponent.onEvent(AbstractComponent.java:3184)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3154)
at org.zkoss.zk.ui.AbstractComponent.service(AbstractComponent.java:3096)
at org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:138)
at org.zkoss.zk.ui.impl.UiEngineImpl.processEvent(UiEngineImpl.java:1851)
at org.zkoss.zk.ui.impl.UiEngineImpl.process(UiEngineImpl.java:1623)
at org.zkoss.zk.ui.impl.UiEngineImpl.execUpdate(UiEngineImpl.java:1326)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:611)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:487)
at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:495)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1589)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:834)
Question:
What is being done incorrectly here?

Your properties file belongs in WEB-INF/classes. The class loader will not look for individual files in WEB-INF, because the servlet specification says it should not look for individual files there.

In addition to VGR's response a .properties file can be read from within the WEB-INF folder directly. Instead of loading it from the classpath via classloader it can be read from a ServletContext object.
That assumes you have access to a ServletContext object. The example below shows how to obtain the ServletContext from via WebApps.getCurrent() instance.
// using ZK specific WebApps util
ServletContext servletContext = WebApps.getCurrent().getServletContext();
// Servlet API
InputStream inputStream = servletContext.getResourceAsStream("/WEB-INF/aws.properties");
Properties myProps = new Properties();
myProps.load(inputStream);
A shortcut would be to call WebApps.getCurrent().getResourceAsStream("/WEB-INF/aws.properties") directly.
Still I'd prefer to keep the config file in the classpath and not to make the Dao-class dependent on the existence of a ServletContext. However your code example wasn't specific about at which layer your configuration is being read.

Related

How do I fix SEVERE: Allocate exception for servlet after Project clean?

I am working on a dynamic web project using JSP and multiple servlets with tomcat Apache and Eclipse.
I was having multiple problems with Eclipse today and I ran a clean on the project to try to fix some of the issues that I was having and ever since, I'm getting the following error every time a servlet is called.
SEVERE: Allocate exception for servlet [RegisterServlet]
java.lang.ClassNotFoundException: com.ogi.controller.RegisterServlet
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1372)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1195)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:545)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:526)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:150)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:763)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:134)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:544)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:698)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:353)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:616)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:831)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1629)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)
This project was working completely fine on localhost before the clean and I have all of the servlets defined in my web.xml file. CATALINA has an environmental variable and I already have the Jar files in my project.
I'm not sure why these errors are occurring and would appreciate some direction on how to attempt to fix this.

Tomcat can't find Log4j library

I'm trying to deploy a .war using Tomcat 8.5.56 (I have to use this version for company policy), it logs with Log4j and it is all setted at WEB-INF/web.xml as you can see here:
...
<env-entry>
<env-entry-name>LogClassName</env-entry-name>
<env-entry-value>com.lutris.logging.Log4jLogger</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>Log4j</env-entry-name>
<env-entry-value>../conf/log4j.xml</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
...
When I search the application url, I got a 500 Server error with the next message:
javax.servlet.ServletException: Initialization of logger failed
caused by class com.lutris.util.ConfigException: Key "LogFile" not found in configuration.
com.lutris.appserver.server.httpPresentation.servlet.HttpPresentationServlet.throwServletException(Unknown Source)
com.lutris.appserver.server.httpPresentation.servlet.HttpPresentationServlet.init(Unknown Source)
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1627)
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
java.lang.Thread.run(Thread.java:748)
After a long search I found that this problem comes up because it cant't find the LogClassName class and try to use the default logger, but all the .jars files are at the lib path in tomcat_folder/lib. At first I thought it would be solved if I put that .jars at the app lib folder (tomcat_folder/webapps/application/WEB-INF/lib) but the problem is still there.
Any help would be greatly appreciated.

java.lang.NoClassDefFoundError when referencing an external library in Eclipse

Edit:
I found the answer and I am posting it here in case anybody googles it in future: Turns out that Tomcat does not look up external libraries in Eclipse and they should be copied to [TomcatInstallDir]/lib.
Here is my code (which is for a servlet running on Tomcat server):
import com.google.gson.Gson;
public class AddCourse extends HttpServlet {
public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException{
Gson gson = new Gson();
//Some code
}
I have tried to export other libraries as well as same library with different version and had the same problem. Here is a picture of Build path:
I read that when writing a Dynamic Web Application (Which I am doing) then we should put the jars under Web-Content/lib, I did that also and it did not help.
Here is the stacktrace:
Apr 19, 2020 5:27:34 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [AddCourse] in context with path [/MTHDB] threw exception [Servlet execution threw an exception] with root cause
java.lang.Error: Unresolved compilation problems:
Gson cannot be resolved to a type
Gson cannot be resolved to a type
at servlets.AddCourse.doPost(AddCourse.java:26)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:660)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:688)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:373)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1594)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Edit:
I noticed that my MANIFEST.MF' contents looks like this:
Manifest-Version: 1.0
Class-Path:
Should not there be a mention the the JARs?
I found the answer and I am posting it here in case anybody googles it in future: Turns out that Tomcat does not look up external libraries in Eclipse and they should be copied to [TomcatInstallDir]/lib.

Getting An AccessDeniedException with Tomcat?

I want to have access to static resources outside my webapp so that they don't get destroyed every time I redeploy, but I can't seem to get them
I have a servlet that is meant to serve these images via a FileOutputStream, but it can't get the file when I deploy it on my tomcat server - it gives me a java.nio.file.AccessDeniedException.
Error from Catalina Log File
13-Feb-2020 16:53:10.621 SEVERE [http-nio-8080-exec-6] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [fileGetter] in context with path [] threw exception
java.nio.file.AccessDeniedException: C:\Users\micro\Pictures\WebsiteStuff\BlogPosts\Test Image 2020-02-12.jpg
at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:108)
at java.base/sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:235)
at java.base/java.nio.file.Files.newByteChannel(Files.java:374)
at java.base/java.nio.file.Files.newByteChannel(Files.java:425)
at java.base/java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:420)
at java.base/java.nio.file.Files.newInputStream(Files.java:159)
at java.base/java.nio.file.Files.copy(Files.java:3195)
at ImageGetterServlet.doGet(ImageGetterServlet.java:37)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:609)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:810)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1623)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:830)
This is especially strange given that I have allowed permission to the directory in my Catalina.policy file.
Catalina.Policy
grant {
...
permission java.io.FilePermission "C:${file.separator}Users${file.separator}micro${file.separator}Pictures${file.separator}WebsiteStuff", "read, write";
};
For whatever reason, this exact same code (minus the permission) works perfectly in Intellij. However, here it is not able to access the file.
Could anyone let me know why this is happening? Did I set the wrong permission/put the permission in the wrong place?
EDIT: It is NOT a permission problem
I granted everything in Catalina.policy java.security.AllPermission but to no avail, I’m getting the same exception.
I found out what was wrong. Tomcat cannot access anything inside the Users folder - probably a Windows 10 specific problem.
I just put my directory in question in the C: drive so that the path is now C:/WebsiteStuff and everything worked fine.

ClassNotFoundException - How to use external libraries without maven?

As a result of my previous question I followed these steps to include Apache PDFbox without maven:
downloaded .jars from download site of PDFbox (all under Libraries of each subproject)
downloaded .jars from dependencies of PDFbox from maven repository (commons-logging and fontbox, but fontbox was already included in step 1)
placed the downloaded .jars in a folder (C:\PDFjars)
configured build path in eclispe (added all .jars as external libraries) It now looks like this:
My servlet:
package servlets;
// other imports
import org.apache.pdfbox.pdmodel.PDDocument;
#WebServlet("/print")
public class PrintServlet extends HttpServlet {
public PrintServlet() {
super();
// TODO Auto-generated constructor stub
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// From a PDFbox Tutorial
//Creating PDF document object
PDDocument document = new PDDocument();
//Saving the document
document.save("C:/PdfBox_Examples/my_doc.pdf");
System.out.println("PDF created");
//Closing the document
document.close();
doGet(request, response);
}
}
So when I start my web project and call the function the should produce a simple PDF document, I get folloing error:
Servlet.service() for servlet [servlets.PrintServlet] in context with path [/StaticsCalculator] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: org.apache.pdfbox.pdmodel.PDDocument
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291)
at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119)
at servlets.PrintServlet.doPost(PrintServlet.java:44)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
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)
Solution: I had to copy the .jars in WEB-INF/lib folder as well.
Download the jar file by itself and add it to your code dependency. You can search for any Maven file on Maven Repository. If you're using Eclipse, just modify the build path to point to an external jar and give it the location of your jar. This will not take care of any dependencies your library requires, which leads into dependency hell where you'll have to read the pom and download each library manually.
You can
a) use a local maven repository and place the dependencies there.
b) add the dependencies in the classpath of the application - that's basically what maven does for you.

Categories