tinesoft / appengine-maven-plugin

Automatically exported from code.google.com/p/appengine-maven-plugin
Apache License 2.0
0 stars 0 forks source link

ClassNotFoundException: com.mysql.jdbc.Driver using appengine:devserver with cloud sql #9

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Using latest snapshot version of plugin set jvmargs for cloud sql 
rdbms.driver etc as described here 
https://developers.google.com/appengine/docs/java/cloud-sql/developers-guide?hl=
en#using_the_java_development_server

2. Attempt to make a connection

What is the expected output? What do you see instead?
Expect the MySQL driver to be loaded and a connection returned but instead I 
see this stacktrace

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
[INFO]  at  
com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver.registerDriver(L
ocalRdbmsServiceLocalDriver.java:95)
[INFO]  at 
com.google.appengine.api.rdbms.dev.LocalRdbmsServiceLocalDriver.init(LocalRdbmsS
erviceLocalDriver.java:73)
[INFO]  at 
com.google.appengine.api.rdbms.dev.LocalRdbmsService.init(LocalRdbmsService.java
:85)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl.startServices(ApiProxyL
ocalImpl.java:612)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl.access$700(ApiProxyLoca
lImpl.java:46)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl$2.run(ApiProxyLocalImpl
.java:595)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl$2.run(ApiProxyLocalImpl
.java:592)
[INFO]  at java.security.AccessController.doPrivileged(Native Method)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl.getService(ApiProxyLoca
lImpl.java:591)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl.resolveDeadline(ApiProx
yLocalImpl.java:239)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl.doAsyncCall(ApiProxyLoc
alImpl.java:219)
[INFO]  at 
com.google.appengine.tools.development.ApiProxyLocalImpl.makeSyncCall(ApiProxyLo
calImpl.java:150)
[INFO]  at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:111)
[INFO]  at 
com.google.appengine.api.rdbms.RdbmsApiProxyClient$ApiProxyBlockingInterface.mak
eSyncCall(RdbmsApiProxyClient.java:93)
[INFO]  at 
com.google.appengine.api.rdbms.RdbmsApiProxyClient$ApiProxyBlockingInterface.ope
nConnection(RdbmsApiProxyClient.java:71)
[INFO]  at 
com.google.cloud.sql.jdbc.internal.SqlProtoClient.openConnection(SqlProtoClient.
java:58)
[INFO]  at com.google.cloud.sql.jdbc.Driver.connect(Driver.java:66)
[INFO]  at com.google.cloud.sql.jdbc.Driver.connect(Driver.java:26)
[INFO]  at java.sql.DriverManager.getConnection(DriverManager.java:582)
[INFO]  at java.sql.DriverManager.getConnection(DriverManager.java:185)

What version of the product are you using? On what operating system?
Using the 1.7.5-SNAPSHOT on OSX

Please provide any additional information below.
mysql-connector-java is a dependancy on both my war and the plugin. The 
connector jar file is correctly copied to the WEB-INF/lib directory.

I tried hacking the jvargs config to pass the jar on the -classpath but that 
didn't seem to work either.

Original issue reported on code.google.com by smdavid...@gmail.com on 5 Feb 2013 at 1:39

GoogleCodeExporter commented 8 years ago
I'll take a look at this.

Original comment by matts...@google.com on 19 Feb 2013 at 6:52

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Use maven-antrun-plugin like this will do the necessary job to solve this issue 
:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.7</version>
  <executions>
    <execution>
      <!-- Use 'package' instead of 'install' if you want the Driver to be available for 'integration-test' -->
      <phase>package</phase>
      <configuration>
        <target>
          <!-- delete existing mysql jar from appengine sdk lib/impl -->
          <delete>
            <fileset 
              dir="${settings.localRepository}/com/google/appengine/appengine-java-sdk/${appengine.target.version}/appengine-java-sdk/appengine-java-sdk-${appengine.target.version}/lib/impl" 
              includes="**/mysql-connector-java*" />
          </delete>
          <!-- copy mysql jar into appengine sdk lib/impl -->
          <copy 
            file="${settings.localRepository}/mysql/mysql-connector-java/${mysql.version}/mysql-connector-java-${mysql.version}.jar" 
            todir="${settings.localRepository}/com/google/appengine/appengine-java-sdk/${appengine.target.version}/appengine-java-sdk/appengine-java-sdk-${appengine.target.version}/lib/impl"/>
        </target>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin> 

Original comment by antoine....@gmail.com on 11 Mar 2013 at 2:46

GoogleCodeExporter commented 8 years ago
Antoine's suggestion modifies your m2 repository, which can cause other issues. 
 If you follow it, and you encounter other issues, please first remove the 
appengine artifacts from your local maven repository before filing a bug.

Original comment by matts...@google.com on 19 Mar 2013 at 8:50

GoogleCodeExporter commented 8 years ago
wow this is an old bug;

http://stackoverflow.com/questions/8952696/java-google-app-engine-and-google-clo
ud-sql-running-on-local-dev-server

Any news from Google on this?

Original comment by roland.b...@arcus-business.com on 26 Mar 2013 at 11:26