0

I am trying to do connection pooling on remote server(not database server) using JNDI, tomcat, Maven and etc. In details, I have two maven projects 1)Web application 2)Java Application in non maven Project and try to access the methods of Java Application from the Web Application. Here is the POM of two projects:

POM for Java Application

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-pool</groupId>
        <artifactId>commons-pool</artifactId>
        <version>1.6</version>
    </dependency>
    <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.13</version>
</dependency>  
  </dependencies>

POM for WebApp

<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.0.1</version>
    <scope>provided</scope>
</dependency>

    <dependency>
        <groupId>de.hello.simpleJavaApp</groupId>
        <artifactId>SimpleJavaApp</artifactId>
        <version>1.0-SNAPSHOT</version>
        <!-- <scope>compile</scope> -->
    </dependency>
        <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.13</version>
</dependency>          
  </dependencies>
  <build>
    <finalName>CPWebApp</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>2.1-alpha-2</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>2.3.2</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

web.xml of Web App:

 <resource-env-ref>
    <description>
        Connection pooling on HSM.
    </description>
    <resource-env-ref-name>bean/CXIResourceLocator</resource-env-ref-name>
    <resource-env-ref-type>
        de.hello.CPWebApp.CXIBean
    </resource-env-ref-type>
</resource-env-ref>

Now the problem is that I am not able to access the methods of Java Application(java.lang.ClassNotFoundException), since I have added the dependency in the web application's POM file. I am not getting any errors while compiling the both projects.

Waiting for your answer.

Ankit Ramani
  • 76
  • 1
  • 1
  • 6
  • There are 2 significant points for verifying, 1. Have you executed the `mvn clean install` for the java project at least once? 2. Are there java project jar file inside your war? at the `WEB-INF/lib`, if yes, does that jar file contains the Class you are looking for? – Charlee Chitsuk Mar 18 '13 at 11:45
  • 1) I have executed the mvn clean install for the java project, since I need jar file in my web App. 2) I have double checked the jar file which contained classes of java app. I am creating jar files for both projects. – Ankit Ramani Mar 18 '13 at 11:48
  • Solved the problem... Also need to add dependencies(jars) in tomcat/lib directory. – Ankit Ramani Mar 18 '13 at 13:41

0 Answers0