Glassfish下的Java EE和JPA,NoClassDefFound com / mysql / jdbc / ResultSetMetaData [英] Java EE and JPA under Glassfish, NoClassDefFound com/mysql/jdbc/ResultSetMetaData

查看:180
本文介绍了Glassfish下的Java EE和JPA,NoClassDefFound com / mysql / jdbc / ResultSetMetaData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从EJB访问MySql数据库时遇到问题。在将我的EAR部署到Glassfish服务器并调用使用实体类的方法后,我得到了如下异常:
$ b java.lang.NoClassDefFoundError:com / mysql / jdbc / ResultSetMetaData

我使用的是本地MySql数据库,连接到这些数据库仍然有效。为了访问这些Databese的表,我使用了Netbeans生成的实体类。这些课程位于外部图书馆(OthelloLibrarie)。在这里,您还可以找到我的会话Bean的远程接口。



我必须将实体类放在外部库中,因为我在Enterprise Client Application中使用它们连接到我的EAR。

我的企业应用程序项目包含主要会话bean和一些来自实体类的会话bean,这些实体类在外部库中使用我的实体类。它还包含持久性XML,它包含我的JDBC驱动程序:



从客户端应用程序调用createPartie方法时出现此错误:

  Partie p = eJBOthelloGame.createPartie(jTextFieldPseudo.getText()); b 


$ b

> @Stateless
public class SessionBeanOthello实现SessionBeanOthelloRemote {
@EJB
Private PlayerFacadeLocal playerFacade;
@EJB
私人PartieFacadeLocal partieFacade;
$ b $ @Override
public Partie createPartie(String player){
// Ajout du tuple
Partie p = new Partie();

播放器p1 =新播放器();
p1.setId(1);
p1.setNom(player);
playerFacade.create(p1);

p.setPlayer1(p1);
partieFacade.create(p);

return p;
}

Partie和Player是用于生成外观的实体类。



我在网上搜索了,但是我从未发现过这种错误。看来只有JDBC的包或类ResultSetMetaData有问题,而不是整个驱动程序。



你能帮我吗?

解决方案

您需要在您的项目中包含 mysql-connector-java.jar 提供MySql JDBC驱动程序类的文件。在使用Netbeans时,只需将其添加为库jar即可。
您可以在此链接。

I have a problem when I acces my MySql Database from an EJB. After deploying my EAR to the Glassfish server, and calling the method that use the entity class I get an exception like this:

java.lang.NoClassDefFoundError: com/mysql/jdbc/ResultSetMetaData

I am using a local MySql Database, the connection to these still works. To acces the tables of these Databese I am using entity classes generated by Netbeans. This classes are situated in external Library (OthelloLibrarie). Here you can also find the remote interface of my Session Bean.

I had to put the entity classes in an external library because I'm using them in an Enterprise Client Application which is connected to my EAR.

My Enterprise Application Project contains the main Session bean and somes Session beans from entity classes which uses my entity classes in the external Library. It also contains the persistence XML and it includes my JDBC driver:

The error appears when I call the method createPartie from the Client Application:

Partie p = eJBOthelloGame.createPartie(jTextFieldPseudo.getText());

SessionBeanOthelloRemote.java:

@Stateless
public class SessionBeanOthello implements SessionBeanOthelloRemote {
   @EJB
   private PlayerFacadeLocal playerFacade;
   @EJB
   private PartieFacadeLocal partieFacade;

   @Override
   public Partie createPartie(String player) {
    //Ajout du tuple
    Partie p = new Partie();

    Player p1 = new Player();
    p1.setId(1);
    p1.setNom(player);
    playerFacade.create(p1);

    p.setPlayer1(p1);
    partieFacade.create(p);

    return p;   
}

Partie and Player are Entity classes used with generated facades.

I searched yet on the web but I never found this kind of error. It seems that only the package or class ResultSetMetaData from JDBC has a problem and not the entire driver.

Can you help me?

解决方案

You need to include in your project the mysql-connector-java.jar file that provides the MySql JDBC driver classes. As you are using Netbeans, just add it as a library jar. You can find it, along with download and installation instructions, at this link.

这篇关于Glassfish下的Java EE和JPA,NoClassDefFound com / mysql / jdbc / ResultSetMetaData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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