Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EclipseLink: How to set SLF4J logger for eclipselink 2.7.0

Bundle org.eclipse.persistence.extension_2.7.0.qualifier.jar (which I install to osgi framework) contains class org.eclipse.persistence.logging.slf4j.SLF4JLogger. In my persistence file I have

<property name="eclipselink.logging.logger" value="org.eclipse.persistence.logging.slf4j.SLF4JLogger"/>

But I get

Exception Description: ClassNotFound: [org.eclipse.persistence.logging.slf4j.SLF4JLogger] specified in [eclipselink.logging.logger] property.
Internal Exception: java.lang.ClassNotFoundException: org.eclipse.persistence.logging.slf4j.SLF4JLogger not found by org.eclipse.persistence.jpa [11]
    at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:231)
    ... 36 more
Caused by: Exception [EclipseLink-28006] (Eclipse Persistence Services - 2.7.0.qualifier): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: ClassNotFound: [org.eclipse.persistence.logging.slf4j.SLF4JLogger] specified in [eclipselink.logging.logger] property.
Internal Exception: java.lang.ClassNotFoundException: org.eclipse.persistence.logging.slf4j.SLF4JLogger not found by org.eclipse.persistence.jpa [11]
    at org.eclipse.persistence.exceptions.EntityManagerSetupException.classNotFoundForProperty(EntityManagerSetupException.java:135)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.findClassForPropertyInternal(EntityManagerSetupImpl.java:1341)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.findClassForProperty(EntityManagerSetupImpl.java:1327)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.updateLoggers(EntityManagerSetupImpl.java:1202)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1752)
    ... 34 more
Caused by: java.lang.ClassNotFoundException: org.eclipse.persistence.logging.slf4j.SLF4JLogger not found by org.eclipse.persistence.jpa [11]
    at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1574)
    at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:79)
    at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:2018)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)
    at org.eclipse.persistence.internal.security.PrivilegedAccessHelper.getClassForName(PrivilegedAccessHelper.java:165)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.findClass(EntityManagerSetupImpl.java:1319)
    at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.findClassForPropertyInternal(EntityManagerSetupImpl.java:1337)
    ... 37 more

I've checked bundle org.eclipse.persistence.extension_2.7.0.qualifier.jar doesn't export package org.eclipse.persistence.logging.slf4j So, could anyone please explain how to make eclipselink to log in slf4j?


1 Answers

Make sure you include the "org.eclipse.persistence.extension" Jar, and it should work fine. The Maven coordinates I've used are:

  <dependency>
     <groupId>org.eclipse.persistence</groupId>
     <artifactId>org.eclipse.persistence.extension</artifactId>
     <version>2.7.2</version>
     <scope>runtime</scope>
  </dependency>

Here is the SLF4JLogger source code.

Must set the eclipselink.logging.logger EclipseLink property to SLF4JLogger's fully qualified class name (i.e., org.eclipse.persistence.logging.slf4j.SLF4JLogger in version 3.0.4).

like image 169
Matt Meola Avatar answered Nov 18 '25 06:11

Matt Meola