Failed to define class in deployment of my EJB project using Wildfly 14

572 Views Asked by At

I want to deploy my EJB project in Wildfly 14 server, I have set data source and test if it works, I tested the deployment of my project without the Java Classes and it worked, but when I added my Java Classes I didn't go well. The error msg I got:

12:31:20,381 WARN [org.jboss.modules.define] (MSC service thread 1-7) Failed to define class com.session.ImpCompteSociete in Module "deployment.Projet_EJB.jar" from Service Module Loader: java.lang.UnsupportedClassVersionError: Failed to link com/session/ImpCompteSociete (Module "deployment.Projet_EJB.jar" from Service Module Loader): com/session/ImpCompteSociete has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763)

Here is one of my classes:

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;
    }

}

My remote Class and its interface are:

Interface:

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();

}

RemoteClass:

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();
    }

}

and my 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>    
0

There are 0 best solutions below