How to import external library from [tomcat_home]/lib in TOMCAT - java

I'm trying to apply external library in java project.
According to the API documentation, it shouldn't be located under reloadable classpath like WEB-INF/classes or WEB-INF/lib and the easiest way to apply API is put the .jar file into [tomcat home]/lib and restart tomcat.
So I put the jar file into [tomcat home]/lib folder and import the API on java class.
But error occurred when I run the server. It seems the API not imported.
2022-08-09 11:08:36,499 WARN [org.springframework.web.context.support.XmlWebApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name '[api class name]': Invocation of init method failed; nested exception is java.lang.Error: Unresolved compilation problem:
[api name] cannot be resolved
Do I need more settings?

#SOLVED
I just placed jar file only into tomcat server not local because the API is available
only in operation server.
So I add jar file on my eclipse (Project Right Click - Build Path - Configure Build Path - Add External JARs) and then deploy project as WAR.

Related

Error occurred during initialization of boot layer .Unable to derive module descriptor

While running spring application i am getting error as .I am following the following tutorialhttps://www.tutorialspoint.com/spring/spring_hello_world_example.html
I created files intially in a default package and after that created a new package and moved class to that new
Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\MIDHUN\Downloads\spring-framework-5.2.3.RELEASE\libs\spring-context-indexer-5.2.3.RELEASE-sources.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Provider class org.springframework.context.index.processor.CandidateComponentsIndexer not in module
i think that you should do: Spring(name-project) right click go to properties, then in java build path and try to add the jar files into classpath folder

ClassNotFoundException for dependent jar file of a java WebProject

I'm currently updating a legacy code, and below is the error occured.
SEVERE: Servlet.service() for servlet [RequestController] in context with path [/ngsf] threw exception [Servlet execution threw an exception] with root cause java.lang.ClassNotFoundException: com.hierynomus.mssmb2.SMBApiException
Now, MyProject.jar is the one im upgrading to use SMBJ due to limitation to SMB1 from jcifs. Built the jar via eclipse [ right-click project -> export -> JAR File]. After i exported the jar, i delete the old MyProject.jar in WebProject and pasted the new MyProject.jar (basically i've ovewritten the old for the new jar) and ran tomcat via eclipse run server. However, the exception occurred. com.hierynomus.mssmb2.SMBApiException can be found inside smbj-0.9.1.jar.
I did a comparison, using the old jar (using jcifs). everything was good. but when i used the new jar, above exception occured. Basically, i just updated the MyProject.jar. there is no modification on WebProject.
Anyone knows how to fix this?

java.lang.NoClassDefFoundError even though war file contains the jar containing the class

I have maven dependency to import an external project jar. The jar is imported in my project by Maven and is present in my Libraries->Maven Dependencies.
I access a static method of a class present inside this Jar from one of my classes. When I do Maven build and run the project in Tomcat that is configured inside my Eclipse, it runs fine and the class and its method is accessible.
But when I deploy the war file build by Maven to external Tomcat server, I get
14-May-2017 14:40:31.631 SEVERE [http-nio-8080-exec-3] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [apple] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.apple.fruit.security.client.TokenManager] with root cause
java.lang.NoClassDefFoundError: Could not initialize class com.apple.fruit.security.client.TokenManager
I accessed that war file and found that the war file contains that jar.
What am I doing wrong?

Java jetty servlet container fails to resolve class dependencies

15:28:38.716 [qtp1588771273-32] WARN o.e.jetty.servlet.ServletHandler - /tp/gremlin/execute
java.lang.IllegalArgumentException: Could not resolve dependency of type:javax.transaction.TransactionManager
at org.neo4j.graphdb.DependencyResolver$Adapter$1.select(DependencyResolver.java:87) ~[neo4j-kernel-2.2.9.jar:2.2.9]
at org.neo4j.kernel.extension.KernelExtensions.resolveDependency(KernelExtensions.java:112) ~[neo4j-kernel-2.2.9.jar:2.2.9]
This is from Neo4j 2.x (the Gremlin plug-in). The package, when built and deployed as instructed at https://github.com/thinkaurelius/neo4j-gremlin-plugin, does contain the jar-file which describes this class, and Maven did download it and did install it there. But, when the server attempts to load and execute the extension, nothing is resolved.
Why?

Maven: Updated struts version in pom and now i'm getting a weird error

I updated a project that was using struts 2.2.3.1 to the 2.3.1.2 in the pom.xml file. After running maven it picked up the jar from the repo and all that and built the package just fine. But, when I run the webapp I am getting this error:
2012-04-26 13:42:06,300 ERROR org.apache.struts2.dispatcher.Dispatcher.error:38 - Dispatcher initialization faile Unable to load configuration. - bean - jar:file:/Library/Tomcat/apache-tomcat-6.0.35/webapps/idmadmin/WEB-INF/lib/struts2-core-2.3.1.2.jar!/struts-default.xml:29:72.....
I was thinking that maybe the old one was still stuck in the classpath but I don't see it.

Categories

Resources