Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] jetty-maven-plugin JNDI JDBC Connection Problem

Hello, I need help please.

I've got a Maven 3.0.3 project configured to run my webapp in Jetty for integration testing. The problem I'm having is that if I start jetty using the jetty:run goal, the app initializes fine with a connection to MySQL. However, if I attempt to run a simple integration test by running the verify goal, jetty fails to successfully obtain a connection to MySQL.

My pom is configured as such:

<properties>
<jetty.port>7080</jetty.port>

   
<jetty.stopPort>7005</jetty.stopPort>

   
<jetty.version>8.0.0.M3</jetty.version>

</properties>
<build>

<plugins>
   
<plugin>

           
<groupId>org.mortbay.jetty</groupId>

           
<artifactId>jetty-maven-plugin</artifactId>

           
<version>${jetty.version}</version>

           
<configuration>
                   
<webdefaultxml>src/main/resource/webdefault.xml</webdefaultxml>

               
<scanIntervalSeconds>10</scanIntervalSeconds>

               
<stopPort>${jetty.stopPort}</stopPort>

               
<stopKey>STOP</stopKey>

               
<contextPath>/</contextPath>
               
<systemProperties>

                   
<systemProperty>
                       
<name>jetty.port</name>

                       
<value>${jetty.port}</value>

                   
</systemProperty>
                   
<systemProperty>

                       
<name>log4j.configurationFile</name>

                       
<value>file:${project.basedir}/src/main/resources/log4j.properties</value>

                   
</systemProperty>
               
</systemProperties>

           
</configuration>
           
<dependencies>

               
<dependency>
                   
<groupId>commons-dbcp</groupId>

                   
<artifactId>commons-dbcp</artifactId>

                   
<version>1.4</version>

               
</dependency>
               
<dependency>

                   
<groupId>mysql</groupId>

                   
<artifactId>mysql-connector-java</artifactId>

                   
<version>5.1.17</version>

               
</dependency>
           
</dependencies>

           
<executions>
               
<execution>

                   
<id>start-jetty</id>

                   
<phase>pre-integration-test</phase>

                   
<goals>
                       
<goal>run</goal>

                   
</goals>
                   
<configuration>

                       
<scanIntervalSeconds>0</scanIntervalSeconds>

                       
<daemon>true</daemon>

                   
</configuration>
               
</execution>

               
<execution>
                   
<id>stop-jetty</id>

                   
<phase>post-integration-test</phase>

                   
<goals>
                       
<goal>stop</goal>

                   
</goals>
               
</execution>

           
</executions>
       
</plugin>

</plugins>
</build>

And I have the following jetty-env.xml file under src/main/webapp/WEB-INF:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">

<New id="mysource" class="org.eclipse.jetty.plus.jndi.Resource">

   
<Arg></Arg>
   
<Arg>jdbc/DS</Arg>

   
<Arg>
       
<New class="org.apache.commons.dbcp.BasicDataSource">

           
<Set name="url">jdbc:mysql://localhost:3306/my_db?autoReconnect=true</Set>

           
<Set name="driverClassName">com.mysql.jdbc.Driver</Set>

           
<Set name="username">a</Set>

           
<Set name="password">b</Set>

           
<Set name="maxActive">10</Set>

           
<Set name="maxIdle">10</Set>

           
<Set name="minIdle">2</Set>

           
<Set name="maxWait">5000</Set>

           
<Set name="minEvictableIdleTimeMillis">25000</Set>

           
<Set name="timeBetweenEvictionRunsMillis">30000</Set>

           
<Set name="validationQuery">select 1</Set>

       
</New>
   
</Arg>

</New>
</Configure>

Any help would be greatly appreciated because I'm at a total loss with this one..


Back to the top