I'm not sure if this is the right place to ask this, but I'll go ahead anyway! I am trying to deploy a JAR that I built with maven into the Tomcat/lib folder. The problem I'm having is that all the classpath JARs for the JAR that I built, aren't getting read. So I am having to explicitly add those JARs to Tomcat's lib folder as well. Is this the expected behavior for Tomcat? Or am I doing something wrong with the Maven build/plugins? My JAR and classpath plugins are done like:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<addDefaultEntries>true</addDefaultEntries>
<addBuildEnvironmentEntries>true</addBuildEnvironmentEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
<attachClasses>true</attachClasses>
<includeEmptyDirectories>true</includeEmptyDirectories>
<outputDirectory>${project.basedir}\target</outputDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<inherited>false</inherited>
<executions>
<execution>
<id>pal-copy-dependencies</id>
<phase>generate-sources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<inherited>false</inherited>
<configuration>
<excludeScope>provided</excludeScope>
<excludeClassifiers>shared</excludeClassifiers>
<excludeTransitive>true</excludeTransitive>
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
<overWriteIfNewer>true</overWriteIfNewer>
<silent>true</silent>
<useBaseVersion>false</useBaseVersion>
</configuration>
</execution>
</executions>
</plugin>
For example, if I have the dependency:
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.3</version>
</dependency>
I keep getting the error:
09-Jan-2020 16:33:40.347 SEVERE [main] org.apache.catalina.core.ApplicationContext.log Servlet.init() for servlet [InitialiseDAC] threw exception
java.lang.NoClassDefFoundError: org/jasypt/util/text/AES256TextEncryptor
at com.provisioning.common.crypto.Decrypt.doDecrypt(Decrypt.java:192)
It only works when I make the dependency like:
<dependency>
<groupId>org.jasypt</groupId>
<artifactId>jasypt</artifactId>
<version>1.9.3</version>
<scope>provided</scope>
</dependency>
And put the jasypt.jar in the Tomcat's lib folder.
Is this normal for Tomcat?