Tuesday, December 8, 2015

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver when executing asterix-java AGI server

I implemented an asterisk-java AGI script with MySQL DB integration and tried to execute with following command

java -jar asterisk-java-1.0.0.M3.jar

Server started successfully and called successfully to the service abstract method. How when the call flow met with a scripting line related to DB operations I always got the following run-time error.

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
 
This error can be resolved mentioning the class-path for  

mysql-connector-java-5.1.9.jar

I tried several standard ways to start the AGI server with mentioned class-path for jdbc but failed. Finally I found the way through following answer.
http://stackoverflow.com/questions/8818073/classnotfoundexception-com-mysql-jdbc-driver

I successfully started the AGI server and executed DB related functions by starting the AGI server jar file as follows.

java -classpath asterisk-java-1.0.0.M3.jar:mysql-connector-java-5.1.9.jar:. org.asteriskjava.fastagi.DefaultAgiServer

(asterisk-java-1.0.0.M3.jar & mysql-connector-java-5.1.9.jar are in the same location)

No comments:

Post a Comment