0

I am trying to build multi module project using maven. following are the modules

1) base 2) common 3) client 4) service

pom.xml of base project is

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.se</groupId>
 <artifactId>base</artifactId>
 <packaging>pom</packaging>
 <version>0.1-SNAPSHOT</version>
 <name>base Maven Webapp</name>
 <url>http://maven.apache.org</url>
 <modules>
  <module>common</module>
  <module>client</module>
  <module>service</module>
 </modules>
 <dependencies>
  ...
 </dependencies>
 <build>
  <finalName>base</finalName>
  <plugins>
   ....
  </plugins>
 </build>
</project>

pom.xml of common module

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <groupId>com.vdcommon</groupId>
 <artifactId>common</artifactId>
 <packaging>jar</packaging>
 <version>0.1-SNAPSHOT</version>
 <name>VDCommon Maven Webapp</name>
 <url>http://maven.apache.org</url>
 <parent>
  <groupId>com.se</groupId>
  <artifactId>base</artifactId>
  <version>0.1-SNAPSHOT</version>
 </parent>
 <dependencies>
  ...
 </dependencies>
 <build>
  <finalName>common</finalName>
  <plugins>
   ...
  </plugins>
 </build>
</project>

pom.xml of client module

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.se</groupId>
  <artifactId>base</artifactId>
  <version>0.1-SNAPSHOT</version>
 </parent>
 <groupId>com.vdclient</groupId>
 <artifactId>client</artifactId>
 <packaging>jar</packaging>
 <version>0.1-SNAPSHOT</version>
 <name>VDClient Maven Webapp</name>
 <url>http://maven.apache.org</url>
 <properties>
  ....
 </properties>
 <dependencies>
  <dependency>
   <groupId>com.vdcommon</groupId>
   <artifactId>common</artifactId>
   <version>0.1-SNAPSHOT</version>
  </dependency>
  ....
 </dependencies>
 <build>
  <finalName>client</finalName>
  <plugins>
   <plugin>
    ....
   </plugin>
  </plugins>
 </build>
</project>

pom.xml of service module

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <parent>
  <groupId>com.se</groupId>
  <artifactId>base</artifactId>
  <version>0.1-SNAPSHOT</version>
 </parent>
 <groupId>com.vdservice</groupId>
 <artifactId>service</artifactId>
 <packaging>war</packaging>
 <version>0.0.1-SNAPSHOT</version>
 <name>vdservcie Maven Webapp</name>
 <url>http://maven.apache.org</url>
 <properties>
 ....
 </properties>
 <dependencies>
  ....
  <dependency>
   <groupId>com.vdclient</groupId>
   <artifactId>client</artifactId>
   <version>0.1-SNAPSHOT</version>
  </dependency>
   ....
 </dependencies>
 <build>
  <finalName>service</finalName>
  <plugins>
   ....
  </plugins>
 </build>
</project>

'service' module is a war file to deploy and test. I am able to do maven install for all the modules successfully and I am able to see the jar files of client and common modules in dependency tree.

   [INFO] +- com.vdclient:client:jar:0.1-SNAPSHOT:compile
   [INFO] |  \- com.vdcommon:common:jar:0.1-SNAPSHOT:compile

But when I try to deploy the service war file into tomcat server I am getting ClassNotFoundException for a class which is present in client module

Caused by: java.lang.TypeNotPresentException: Type logical.lookuplogicalds_ws.PartyLookupDS not present
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68)
at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138)
at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
at sun.reflect.generics.repository.ConstructorRepository.getParameterTypes(ConstructorRepository.java:94)
at java.lang.reflect.Executable.getGenericParameterTypes(Executable.java:283)
at java.lang.reflect.Method.getGenericParameterTypes(Method.java:283)
at java.beans.FeatureDescriptor.getParameterTypes(FeatureDescriptor.java:387)
at java.beans.MethodDescriptor.setMethod(MethodDescriptor.java:116)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:72)
at java.beans.MethodDescriptor.<init>(MethodDescriptor.java:56)
at java.beans.Introspector.getTargetMethodInfo(Introspector.java:1205)
at java.beans.Introspector.getBeanInfo(Introspector.java:426)
at java.beans.Introspector.getBeanInfo(Introspector.java:173)
at org.springframework.beans.CachedIntrospectionResults.<init>(CachedIntrospectionResults.java:277)
at org.springframework.beans.CachedIntrospectionResults.forClass(CachedIntrospectionResults.java:186)
at org.springframework.beans.BeanWrapperImpl.getCachedIntrospectionResults(BeanWrapperImpl.java:321)
at org.springframework.beans.BeanWrapperImpl.getPropertyDescriptors(BeanWrapperImpl.java:328)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1305)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.filterPropertyDescriptorsForDependencyCheck(AbstractAutowireCapableBeanFactory.java:1285)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1143)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
... 33 more
Caused by: java.lang.ClassNotFoundException: logical.lookuplogicalds_ws.PartyLookupDS
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1352)
    at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
at sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)
... 56 more

can anyone please help me on fixing this issue?

Subramanyam G
  • 21
  • 1
  • 2

1 Answers1

-1

You need to make sure that you're bundling all of the libraries into the war file. If it builds correctly but the war is missing the related libraries it will fail when you deploy it.

For example, at package time where are you putting the libraries you depend on? And how are you building your war to include those libraries?

Most likely you can solve your problem using the Maven War Plugin. It will help you package all of the libraries you need into your war.

https://maven.apache.org/plugins/maven-war-plugin/

That will setup your maven project to create your war with what you need.

Joe W
  • 2,773
  • 15
  • 35
  • Hi @Joe W thank you for your reply, all the required jars are bundled inside lib folder in `service war file` including both `common` and `client` jars without `maven war plugin`. still I am facing `ClassNotFoundException` – Subramanyam G Apr 13 '20 at 09:18