将MySQL数据库连接到Glassfish类路径未设置或类名错误 [英] Connecting a MySQL database to Glassfish classpath is not set or classname is wrong

查看:377
本文介绍了将MySQL数据库连接到Glassfish类路径未设置或类名错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在换一个MySQL数据库。我以前有一切工作,但之后我认为是正确的配置我收到错误:



导致:javax.resource.ResourceException:类名称错误或classpath未设置为:com.mysql.jdbc.jdbc2.optional.MysqlDataSource



控制台的完整错误输出:



导致:javax.resource.ResourceException:类名不正确或类路径未设置为:com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at com。 sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:292)
在com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:114)
在com.sun.gjc。 spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1292)
在com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:148)
在com.sun.gjc.spi.DSManagedConnectionFactory。 createManagedConnection(DSManagedConnectionF actory.java:101)
在com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)

我已经仔细检查了一些名称,连接池和其他资源。我还在两个项目中将MySQL驱动程序.jars添加到了glassfish的库中。数据库绝对能够通过eclipse正常工作,因为我能够查看表并显示eclipse数据库环境中的资源。所以我知道至少THOSE驱动程序正常工作。 persistence.xml文件也看起来不错。它引用了jdbc / mydatabase jndi引用,它应该是这样的,默认的JTA被选为管理类型。有没有人有另一个建议?



谢谢

解决方案


我还将MySQL驱动程序.jars添加到库的两个项目中的玻璃鱼。


显然没有做到正确。 JAR必须进入Glassfish安装的 / glassfish / domains / [domainname] / lib / ext 文件夹,其中 [domainname] 通常默认为 domain1 。您可以也不应该将其从Eclipse端配置。


I'm swapping out a derby database for a MySQL one. I had everything working before but after what I thought was the proper configuration I'm getting the error:

Caused by: javax.resource.ResourceException: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource

Full error output from console:

Caused by: javax.resource.ResourceException: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlDataSource
at com.sun.gjc.common.DataSourceObjectBuilder.getDataSourceObject(DataSourceObjectBuilder.java:292)
at com.sun.gjc.common.DataSourceObjectBuilder.constructDataSourceObject(DataSourceObjectBuilder.java:114)
at com.sun.gjc.spi.ManagedConnectionFactory.getDataSource(ManagedConnectionFactory.java:1292)
at com.sun.gjc.spi.DSManagedConnectionFactory.getDataSource(DSManagedConnectionFactory.java:148)
at com.sun.gjc.spi.DSManagedConnectionFactory.createManagedConnection(DSManagedConnectionFactory.java:101)
at com.sun.enterprise.resource.allocator.LocalTxConnectorAllocator.createResource(LocalTxConnectorAllocator.java:87)

I've double checked some of the names, the connection pool and other resources.I've also added the MySQL driver .jars to the library of glassfish in both projects. The database was definitely working correctly through eclipse because I was able to view tables and display the resources inside the database context of eclipse. So I know that at least THOSE drivers are working correcly. Also the persistence.xml file looks good. it references the jdbc/mydatabase jndi reference like it should and default JTA is selected as the manament type.

Does anyone have another suggestion? Thank you

解决方案

I've also added the MySQL driver .jars to the library of glassfish in both projects.

It was apparently not done right. The JAR has to go in /glassfish/domains/[domainname]/lib/ext folder of the Glassfish installation where [domainname] usually defaults to domain1. You can and should not configure it from the Eclipse side on.

这篇关于将MySQL数据库连接到Glassfish类路径未设置或类名错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆