logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Carman <michael.j.car...@gmail.com>
Subject ClassNotFoundException trying to use JDBC appender
Date Tue, 29 Nov 2016 17:04:05 GMT
I'm using Log4j2 in an Eclipse RCP application. I've been using a
RollingFileAppender and am trying to switch to a JDBC appender backed by a
ConnectionFactory. I've implemented this using the examples at
https://logging.apache.org/log4j/2.x/manual/appenders.html#JDBCAppender as
a guide but get a ClassNotFoundException at each call to
LogManager.getLogger(). e.g.

2016-11-29 10:23:06,233 main ERROR java.lang.ClassNotFoundException:
x.y.z.LogDB java.lang.ClassNotFoundException: x.y.z.LogDB
    at
org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:506)
    at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:422)
    at
org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
    at
org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at
org.apache.logging.log4j.util.LoaderUtil.loadClass(LoaderUtil.java:141)
    at
org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource.createConnectionSource(FactoryMethodConnectionSource.java:82)
    ...

My log4j2.xml defines the appender as:

<JDBC name="DB" tableName="APP_LOG">
  <ConnectionFactory class="x.y.z.LogDB" method="getConnection" />
  <Column name="TIMESTAMP" isEventTimestamp="true"    />
  <Column name="PID"       pattern="%X{pid}"          />
  <Column name="THREAD"    pattern="%thread"          />
  <Column name="USERNAME"  pattern="${env:USERNAME}"  />
  <Column name="SEVERITY"  pattern="%level"           />
  <Column name="LOGGER"    pattern="%logger{1.1.1.*}" />
  <Column name="MESSAGE"   pattern="%message"         />
  <Column name="EXCEPTION" pattern="%exception" isClob="true" />
</JDBC>

I've looked at the obvious things: the name of my factory class matches
between my code and config file, it's declared public, and its package is
exported by the parent plug-in. (The parent plug-in is also required by
other plugins via their manifests.) I can't see why the class loader
shouldn't be able to find it. I assume there's something simple and stupid
that I'm missing.

I'm using Eclipse 3.6.2 (Helios) and Log4j 2.7.

-Mike

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message