我想在 Wildfly 14 服务器上部署我的 EJB 项目,我已经设置了数据源并测试它是否有效,我在没有的情况下测试了我的项目的部署Java Classes
并且它有效,但是当我添加我的时候Java Classes
我并不顺利。我得到的错误信息:
12:31:20,381 WARN [org.jboss.modules.define](MSC 服务线程 1-7)无法在服务模块加载程序的模块“deployment.Projet_EJB.jar”中定义类 com.session.ImpCompteSociete:java.lang。 UnsupportedClassVersionError:无法链接 com/session/ImpCompteSociete(来自 Service Module Loader 的模块“deployment.Projet_EJB.jar”):com/session/ImpCompteSociete 已由 Java 运行时的更新版本(类文件版本 55.0)编译,这Java 运行时的版本仅在 java.lang.ClassLoader.defineClass1(Native Method) 处的 java.lang.ClassLoader.defineClass(ClassLoader.java:763) 处识别最高 52.0 的类文件版本
这是我的一门课:
package com.entities;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
@SuppressWarnings("serial")
@Entity
@Table(name = "tbl_clients")
public class Client implements Serializable {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private int code;
private String nom;
private String prenom;
private String ville;
@ManyToMany(mappedBy = "clients")
private List<Produit> produits;
@OneToOne
@JoinColumn(name = "numero_compte")
private Compte_Societe compte_societe;
public Client() {
super();
// TODO Auto-generated constructor stub
}
public Client(int code, String nom, String prenom, String ville) {
super();
this.code = code;
this.nom = nom;
this.prenom = prenom;
this.ville = ville;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getVille() {
return ville;
}
public void setVille(String ville) {
this.ville = ville;
}
public List<Produit> getProduits() {
return produits;
}
public void setProduits(List<Produit> produits) {
this.produits = produits;
}
public Compte_Societe getCompte_societe() {
return compte_societe;
}
public void setCompte_societe(Compte_Societe compte_societe) {
this.compte_societe = compte_societe;
}
}
我的远程类及其接口是:
界面:
package com.session;
import java.util.List;
import javax.ejb.Remote;
import com.entities.Client;
@Remote
public interface IRemote_Client {
public void addClient(Client clt);
public boolean deleteClient(int code);
public boolean updateClient(Client clt);
public Client getClient(int code);
public List<Client> getAllClients();
}
远程类:
package com.session;
import java.util.List;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import com.entities.Client;
/**
* Session Bean implementation class IRemote_Client
*/
@Stateless(name = "RClient")
@LocalBean
public class ImpClient implements IRemote_Client {
@PersistenceContext
EntityManager EM;
public ImpClient() {
// TODO Auto-generated constructor stub
}
@Override
public void addClient(Client clt) {
EM.persist(clt);
}
@Override
public boolean deleteClient(int code) {
Client clt = EM.find(Client.class, code);
if(clt != null) {
EM.remove(clt);
return true;
}
return false;
}
@Override
public boolean updateClient(Client clt) {
Client client = EM.find(Client.class, clt.getCode());
if(client != null) {
EM.merge(clt);
return true;
}
return false;
}
@Override
public Client getClient(int code) {
Client clt = EM.find(Client.class, code);
return clt;
}
@SuppressWarnings("unchecked")
@Override
public List<Client> getAllClients() {
Query query = EM.createQuery("from Client");
return query.getResultList();
}
}
我的Persistence.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="Projet_EJB" transaction-type="JTA">
<jta-data-source>java:/dsAvion</jta-data-source>
<class>com.entities.Client</class>
<class>com.entities.Produit</class>
<class>com.entities.Fournisseur</class>
<class>com.entities.Compte_Societe</class>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>
</persistence>