Puzzle for Mysql Datasource

All Union Platform questions, comments, feature requests, and bug reports.

Puzzle for Mysql Datasource

Postby cripito » Mon 07 Jul 2014 16:56

Hi

I am trying to change the original datasource by an mysql. datasource with union 2.1.1

So i compiled the original example that comes in modules/net/user1/union/example/datasource/MySqlAccountDatasource.java

my union is seating in /usr/src/union/

so i just did
cd /usr/src/union/modules/net/user1/union/example/datasource
javac -cp /usr/src/union/lib/union.jar MySqlAccountDatasource.java
jar -cf mysql.jar MySqlAccountDatasource.class

then i copied the mysql.jar in my CLASSPATCH
[root@devel union]$ echo $CLASSPATH
:.:/opt/jdk1.7.0_25/lib/classes.zip:/usr/share/java:/usr/src/union/lib

and in /usr/src/union/lib/

i start the union server and i keep getting

this is part of my cfg users and pass are being replaced etc etc

<persistence>
<datasource id="sqlDS">
<class>net.user1.union.example.datasource.MySqlAccountDatasource</class>
<attributes>
<attribute name="dbURL">jdbc:mysql://localhost:3306/database</attribute>
<attribute name="dbUsername">user</attribute>
<attribute name="dbPassword">user_pass</attribute>
</attributes>
<account-attributes>
<scope id=""> <!-- global scope -->
<name>agentid</name>
<name>agent_code</name>
<name>agentpassword</name>
<name>name</name>
<name>tenantid</name>
<name>userid</name>
<name>status</name>
<name>talkingto</name>
<name>statustime</name>
</scope >
</account-attributes>
</datasource>
<datasource id="union"/>
</persistence>



14-07-07 13:51:30,102 WARN - ***********************************************
2014-07-07 13:51:30,103 WARN - *** Starting Union Server 2.1.1 (build 600) ***
2014-07-07 13:51:30,103 WARN - ***********************************************
2014-07-07 13:51:30,103 WARN - UPC Version: 1.10.3
2014-07-07 13:51:30,104 WARN - Java VM [1.7.0_25 from Oracle Corporation]
2014-07-07 13:51:30,104 WARN - Licence [Union Member]
2014-07-07 13:51:30,195 WARN - The use of <ip> and <port> under <admin> is now deprecated. Declare one or more [Admin] or [SecureAdmin] gateways using the <gateways> section to configure how admin tools will connect to the server.
2014-07-07 13:51:30,245 WARN - UNION_HOME set to [/usr/src/union/.]
2014-07-07 13:51:30,256 ERROR - Datasource type [net.user1.union.example.datasource.MySqlAccountDatasource] was not a class that could be loaded.
java.lang.ClassNotFoundException: net.user1.union.example.datasource.MySqlAccountDatasource
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at net.user1.union.persistence.a.a(SourceFile:23)
at net.user1.union.persistence.d.a(SourceFile:646)
at net.user1.union.persistence.d.onInit(SourceFile:40)
at net.user1.union.core.a.init(SourceFile:39)
at net.user1.union.core.LocalServer.a(SourceFile:1846)
at net.user1.union.core.LocalServer.onInit(SourceFile:106)
at net.user1.union.core.a.init(SourceFile:39)
at net.user1.union.core.t.a(SourceFile:159)
at net.user1.union.core.t.a(SourceFile:97)
at net.user1.union.core.t.onInit(SourceFile:15)
at net.user1.union.core.a.init(SourceFile:39)
at net.user1.union.core.q.a(SourceFile:118)
at net.user1.union.core.s.run(SourceFile:18)
at java.lang.Thread.run(Thread.java:724)
2014-07-07 13:51:30,259 ERROR - Could not load class for datasource [sqlDS].

Anyone experiencing something similar?

regards
cripito
 
Posts: 13
Joined: Sun 15 Jul 2012 11:54

Re: Puzzle for Mysql Datasource

Postby derek » Tue 08 Jul 2014 16:55

Hello

View the contents of your jar file with the following command:

Code: Select all
jar tf mysql.jar


Verify that the MySqlAccountDatasource.class file is in the nested directory structure /net/user1/union/example/datasource and is listed as:

Code: Select all
net/user1/union/example/datasource/MySqlAccountDatasource.class


If it is not you must create the jar file from the root directory of the file based on the package (net.user1.union.example.datasource). After you compile instead try:

Code: Select all
cd /usr/src/union/modules
jar -cfv mysql.jar net.user1.union.example.datasource.MySqlAccountDatasource.class


Cheers,

Derek
derek
 
Posts: 68
Joined: Mon 17 Oct 2011 19:12


Return to Union Platform

Online

Users browsing this forum: No registered users and 5 guests