logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: ClassNotFoundException trying to use JDBC appender
Date Tue, 29 Nov 2016 20:43:14 GMT
Is your getConnection() method static?

Gary

On Tue, Nov 29, 2016 at 9:04 AM, Michael Carman <michael.j.carman@gmail.com>
wrote:

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



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<https://www.amazon.com/gp/product/1617290459/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1617290459&linkCode=as2&tag=garygregory-20&linkId=cadb800f39946ec62ea2b1af9fe6a2b8>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1617290459>
JUnit in Action, Second Edition
<https://www.amazon.com/gp/product/1935182021/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182021&linkCode=as2&tag=garygregory-20&linkId=31ecd1f6b6d1eaf8886ac902a24de418%22>

<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182021>
Spring Batch in Action
<https://www.amazon.com/gp/product/1935182951/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=1935182951&linkCode=%7B%7BlinkCode%7D%7D&tag=garygregory-20&linkId=%7B%7Blink_id%7D%7D%22%3ESpring+Batch+in+Action>
<http:////ir-na.amazon-adsystem.com/e/ir?t=garygregory-20&l=am2&o=1&a=1935182951>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

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