Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipselink class "javax.persistence.PersistenceUtil"'s signer information does not match signer information of other classes in the same package

When I try to create an EntityManager, I get this exception:

java.lang.SecurityException: class "javax.persistence.PersistenceUtil"'s signer information does not match signer information of other classes in the same package

Perhaps it is something with the javax.persistence packages but I don't know how can I fix it.

    public static EntityManager getEntityManager() {
    if(emf == null) {
        emf = Persistence.createEntityManagerFactory("AccountsManager");
    }
    return emf.createEntityManager();
}

Here is the persistence.xml file

  <?xml version="1.0" encoding="UTF-8"?>
  <persistence version="2.1" 
  xmlns="http://xmlns.jcp.org/xml/ns/persistence" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence 
   http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="AccountsManager" transaction- 
                                  type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <class>model.Account</class>
    <class>model.AllSubscription</class>
    <class>model.Client</class>
</persistence-unit>

I found similar questions but I didn't find any solutions.

like image 220
Dexxrey Avatar asked Oct 27 '25 10:10

Dexxrey


2 Answers

After I have read all possible similar topics I figured it out.

In the current version of eclipselink(2.7.4) if you add jakarta.persistence_2.2.2.jar alongside with eclipselink.jar this problem occurs. Both jars have some classes and packages with the same name. In order to fix that you have to add jakarta.persistence_2.2.2.jar before the eclipselink.jar. So all the classes are taken from the jakarta not partly.

I don't fully understand how these two libraries interact with each other, but replacing the order in the build path helped.

like image 151
Dexxrey Avatar answered Oct 29 '25 00:10

Dexxrey


Replace jakarta.persistence_2.2.2.jar for jakarta.persistence-2.2.3.jar from maven repository.

like image 35
Marcelo P. Llanos C. Avatar answered Oct 29 '25 00:10

Marcelo P. Llanos C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!