部署到Glassfish类路径未设置为com.mysql.jdbc.jdbc2.optional.MysqlXADataSource [英] Deploying to Glassfish classpath not set for com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

查看:3508
本文介绍了部署到Glassfish类路径未设置为com.mysql.jdbc.jdbc2.optional.MysqlXADataSource的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Glassfish没有加载 com.mysql.jdbc.jdbc2.optional.MysqlXADataSource 包。



抛出以下错误

  javax.persistence.PersistenceException:异常[EclipseLink-4002](Eclipse Persistence 
服务 - 2.3.2.v20111125-r10461):org.eclipse.persistence.exceptions.DatabaseException
内部异常:java.sql.SQLException:
分配连接时出错。原因:类名错误或类路径未设置
为:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
错误代码:0在org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy
(EntityManagerSetupImpl.java:517)...

我已经复制了mysql连接器jar文件到Glassfish的 lib 目录,但我仍然收到上述错误。



如何确保Glassfish可以为我部署的应用程序找到我的JDBC驱动程序?

解决方案

您需要使Glassfish可以使用MySQL JDBC jar文件。 / p>

http:// ushainformatique。 com / blog / 2010/03/19 / jdbcwithglassfish /



编辑:



我使用不同的JDBC驱动程序?我应该在哪里复制jar?




建议放置所有
使用的JDBC驱动程序domain-dir / lib或
domain-dir / lib / classes中的域中的应用程序。今天需要重新启动应用程序服务器实例
,以便在域中部署的应用程序
可以看到JDBC驱动程序。


https://blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt



所以将jar文件移动到您正在部署应用程序的域下面的lib目录中。默认的Glassfish域是domain1。



重新启动Glassfish,这应该可以工作。



有一个Maven Glassfish插件可能值得评价 http://maven-glassfish-plugin.java.net/ 使用Maven和此插件有助于自动化部署步骤。这将比手动部署更强大。当然你的电话。


Glassfish is not loading the com.mysql.jdbc.jdbc2.optional.MysqlXADataSource package.

The following error is thrown

javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence
Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: 
Error in allocating a connection. Cause: Class name is wrong or classpath is not set    
for:com.mysql.jdbc.jdbc2.optional.MysqlXADataSource
Error Code: 0 at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy
(EntityManagerSetupImpl.java:517)...

I have copied the mysql-connector jar file to the lib directory of Glassfish but I still get the above error.

How do I ensure that Glassfish can find my JDBC driver for my deployed application?

解决方案

You will need to make the MySQL JDBC jar file available to Glassfish.

http://ushainformatique.com/blog/2010/03/19/jdbcwithglassfish/

EDIT:

How do I use different JDBC drivers? Where should I copy the jar(s)?

It is recommended to place JDBC drivers, that are used by all the applications in the domain, in domain-dir/lib or domain-dir/lib/classes. A restart of the application server instance is required today so that the JDBC drivers are visible to applications deployed in the domain.

From https://blogs.oracle.com/sivakumart/entry/classloaders_in_glassfish_an_attempt

So move the jar file into the lib dir below the domain into which you are deploying your app. The default Glassfish domain is domain1.

Restart Glassfish and this should work.

There is a Maven Glassfish plugin which may be worth evaluating http://maven-glassfish-plugin.java.net/ Using Maven and this plugin would help automate the deployment step. This would be more robust than doing manual deployments. Your call though of course.

这篇关于部署到Glassfish类路径未设置为com.mysql.jdbc.jdbc2.optional.MysqlXADataSource的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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