开发者

Building a jar with MySQL jdbc on solaris

Im building a java application that uses JDBC to connect to MySQL. I have an ant script that compiles my code and then packages it, along with log4j, junit, libshout-java and the mys开发者_运维技巧ql jdbc driver into one executable jar. This all works fine on ubuntu 9.10, and my code connects to mysql and away we go.

However my production env will be solaris (my dev box is ubuntu) and when I came to build and run this on there i had the following errors.

17 [main] DEBUG com.radiobusi.ShoutGen.ParseConfig  - [SQL, SELECT * FROM RadioBusi.RadioBusi_song JOIN RadioBusi.RadioBusi_playlist WHERE RadioBusi_playlist.Name = 'Placebo 2';]
18 [main] DEBUG com.radiobusi.ShoutGen.ParseConfig  - this is able to be broken up[SQL, SELECT * FROM RadioBusi.RadioBusi_song JOIN RadioBusi.RadioBusi_playlist WHERE RadioBusi_playlist.Name = 'Placebo 2';]
78 [main] ERROR com.radiobusi.ShoutGen  - An error occured instantiating the class ShoutGen
java.lang.ExceptionInInitializerError
        at com.mysql.jdbc.Util.stackTraceToString(Util.java:351)
        at com.mysql.jdbc.Util.<clinit>(Util.java:116)
        at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:672)
        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:277)
        at java.sql.DriverManager.getConnection(DriverManager.java:582)
        at java.sql.DriverManager.getConnection(DriverManager.java:185)
        at com.radiobusi.ShoutGen.PlayList.<init>(Unknown Source)
        at com.radiobusi.ShoutGen.ShoutGen.<init>(Unknown Source)
        at com.radiobusi.ShoutGen.ShoutGen.main(Unknown Source)
Caused by: java.lang.RuntimeException: Can't load resource bundle due to underlying exception java.util.MissingResourceException: Can't find bundle for base name com.mysql.jdbc.LocalizedErrorMessages, locale en_AU
        at com.mysql.jdbc.Messages.<clinit>(Messages.java:60)
        ... 9 more
Caused by: java.util.MissingResourceException: Can't find bundle for base name com.mysql.jdbc.LocalizedErrorMessages, locale en_AU
        at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1521)
        at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1260)
        at java.util.ResourceBundle.getBundle(ResourceBundle.java:715)
        at com.mysql.jdbc.Messages.<clinit>(Messages.java:58)
        ... 9 more
Exception in thread "main" java.lang.NullPointerException
        at com.radiobusi.ShoutGen.ShoutGen.main(Unknown Source)

My mysql database locale is en_US on solaris, but my ubuntu mysql database is the also en_US.

Anybody got any idea's?

Im not sure what other information is needed, so if you would like more information just let me know in the comments.

Jars that get packaged

junit-4.8.1.jar
libshout.jar
log4j-1.2.15.jar
mysql-5.1.6.jar

munderwo@opensolaris:~/ShoutGen-Java$ uname -a
SunOS opensolaris 5.11 snv_111b i86pc i386 i86pc Solaris

MySQL Version: MySQL 5.1.30

Cheers

Mark


The error says:

Can't find bundle for base name com.mysql.jdbc..., locale en_AU

So it seems currently you are running on Australian locale

I think you should first try switching the locale to en_US and try whether it works.

[EDIT] Also please make sure that the path where your mysql connector/driver are stored does not contain any illegal characters. See this link.


I think the reason for this surprise, surprise, user error :)

I removed any mysql jdbc from my lib directory in my source code and then put the mysql jdbc connector that came with opensolaris (looks like it came from sun studio) in lib/ext of java. Once I did this it all seemed to work. On closer inspection I think I might have still had the ubuntu mysql JDBC driver in my class path and quite possibly before the cross-platform jar. So I suspect that this was the problem.

Thanks for all your help!

Mark.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜