PDA

View Full Version : Error instantiating instance of Java plugin 'DatabasePlugin': com.mysql.jdbc.Driver



willemfkkc
07-24-2007, 03:18 PM
Hi All,

I was hoping someone could help me out with this, I'm trying to connect to a mysql database, but at this point ElectroServer doesn't even start due to the following error:



A severe error occured and the server is unable to start properly!
Message follows:
Error instantiating instance of Java plugin 'DatabasePlugin': com.mysql.jdbc.Driver

Full stack trace:
com.electrotank.electroserver.plugins.PluginExcept ion: Error instantiating instance of Java plugin 'DatabasePlugin': com.mysql.jdbc.Driver
at com.electrotank.electroserver.utilities.Properties Loader.buildPlugin(PropertiesLoader.java:576)
at com.electrotank.electroserver.utilities.Properties Loader.loadServerPlugins(PropertiesLoader.java:518 )
at com.electrotank.electroserver.ElectroServer.startC hatServer(ElectroServer.java:287)
at com.electrotank.electroserver.ElectroServer.startC hatServer(ElectroServer.java:202)
at com.electrotank.electroserver.ElectroServer.main(E lectroServer.java:472)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.install4j.runtime.Launcher.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.electrotank.electroserver.utilities.Properties Loader.buildPlugin(PropertiesLoader.java:572)
... 10 more


ElectroServer is running on a Fedora 7 box, the mysql driver is located in
/usr/share/java/mysql-connector-java.jar (this is a link to /usr/share/java/mysql-connector-java-3.1.12.jar)

Now follows a copy of the configuration.xml file for ES:



<Name>DatabasePlugin</Name>
Java
<Scope>Server

<File>com.mysql.jdbc.Driver</File>
<Notifications />
<Variables>
<Variable Deep="true">
<Name>TestDB</Name>
<Value>

<ConnectionString>jdbc:mysql://localhost/test?user=monty&password=mysql</ConnectionString>
<DriverName>com.mysql.jdbc.driver</DriverName>
<MaxActive>5</MaxActive>
<MaxIdle>2</MaxIdle>
true
true
60000</PoolCleanerTime>
true
SELECT * FROM testtable ORDER BY id DESC LIMIT 1
<WhenExhausted>fail</WhenExhausted>
<WaitTime></WaitTime>
</PoolConfiguration>
</Value>
</Variable>
</Variables>
</Plugin>


I've also modified the start-script StartElectroServer.sh to make sure the java-classpath is included:


....
local_classpath=""
add_class_path "/usr/share/java/."
add_class_path "$app_home/.install4j/i4jruntime.jar"
add_class_path "$app_home/ElectroServer3.jar"
add_class_path "$app_home/."
for i in `ls "$app_home/plugins" | egrep "\.(jar$|zip$)"`
do
add_class_path "$app_home/plugins/$i"
done
....


I've also added the phrase '/usr/share/java/*' in the variable 'common_jvm_locations' in the shell script.

If any of you require more information to find an answer or a solution let me know ok ;)

Thanx in advance :)

ps: changed
[code]<DriverName>com.mysql.jdbc.driver</DriverName>
to
<Dri

willemfkkc
07-24-2007, 05:10 PM
Ok,
Appearantly I needed to point to the jar-files instead of the folder.
I changed
add_class_path '/usr/share/java'
to

add_class_path '/usr/share/java/mysql-connector-java.jar'

And the ClassNotFoundException disappeared.

But now another error occures:


Error instantiating instance of Java plugin 'DatabasePlugin': null

Full stack trace:
com.electrotank.electroserver.plugins.PluginExcept ion: Error instantiating instance of Java plugin 'DatabasePlugin': null
at com.electrotank.electroserver.utilities.Properties Loader.buildPlugin(PropertiesLoader.java:576)
at com.electrotank.electroserver.utilities.Properties Loader.loadServerPlugins(PropertiesLoader.java:518 )
at com.electrotank.electroserver.ElectroServer.startC hatServer(ElectroServer.java:287)
at com.electrotank.electroserver.ElectroServer.startC hatServer(ElectroServer.java:202)
at com.electrotank.electroserver.ElectroServer.main(E lectroServer.java:472)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknow n Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Un known Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.install4j.runtime.Launcher.main(Unknown Source)
Caused by: java.lang.ClassCastException
at com.electrotank.electroserver.utilities.Properties Loader.buildPlugin(PropertiesLoader.java:573)
... 10 more


Any ideas ?

webgeek
07-24-2007, 06:15 PM
That's an odd one... What class does your plugin extend?

Mike

P.S. Also, an easier way to get the jar file working with the server is to simply throw it in the plugins folder. Every jar or class in that folder gets loaded automatically.

willemfkkc
07-24-2007, 06:31 PM
P.S. Also, an easier way to get the jar file working with the server is to simply throw it in the plugins folder. Every jar or class in that folder gets loaded automatically.

Indeed, thanx for the tip.

Back on topic:

It is used to create a object to execute database queries, is it supposed to extend another plugin ??

willemfkkc
07-24-2007, 09:32 PM
Must the configuration Plugin -> File-node point to 'com.electrotank.electroserver.plugins.dbio.Databa sePlugin' ?


<File>com.electrotank.electroserver.plugins.dbio.Databas ePlugin</File>

instead of

<File>com.mysql.jdbc.Driver</File>

??