在 Solaris 上使用 MySQL jdbc 构建 jar
我正在构建一个使用 JDBC 连接到 MySQL 的 java 应用程序。我有一个 ant 脚本,它编译我的代码,然后将其与 log4j、junit、libshout-java 和 mysql jdbc 驱动程序一起打包到一个可执行 jar 中。这一切在 ubuntu 9.10 上运行良好,我的代码连接到 mysql,然后我们就可以开始了。
然而,我的生产环境将是solaris(我的开发盒是ubuntu),当我在那里构建和运行它时,我遇到了以下错误。
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)
我的 mysql 数据库区域设置在 solaris 上是 en_US,但我的 ubuntu mysql 数据库也是 en_US。
有人有什么想法吗?
我不确定还需要什么其他信息,所以如果您想了解更多信息,请在评论中告诉我。
打包的 jars
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 版本:MySQL 5.1.30
Cheers
Mark
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 mysql 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误显示:
所以看来目前您正在澳大利亚语言环境上运行
我认为您应该首先尝试将语言环境切换到 en_US 并尝试它是否有效。
[编辑] 另外请确保您的 mysql 连接器/驱动程序存储的路径不包含任何非法字符。请参阅此链接。
The error says:
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.
我认为这个令人惊讶、惊讶、用户错误的原因:)
我从源代码中的 lib 目录中删除了所有 mysql jdbc,然后将 opensolaris 附带的 mysql jdbc 连接器(看起来像是来自 sun studio)放在 lib/ 中java 的扩展名。一旦我这样做了,一切似乎都奏效了。经过仔细检查,我认为我的类路径中可能仍然有 ubuntu mysql JDBC 驱动程序,而且很可能在跨平台 jar 之前。所以我怀疑这就是问题所在。
感谢您的帮助!
标记。
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.