Return-Path: X-Original-To: apmail-logging-log4j-user-archive@www.apache.org Delivered-To: apmail-logging-log4j-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7E7BA108A0 for ; Wed, 16 Apr 2014 21:58:42 +0000 (UTC) Received: (qmail 96099 invoked by uid 500); 16 Apr 2014 21:58:41 -0000 Delivered-To: apmail-logging-log4j-user-archive@logging.apache.org Received: (qmail 96003 invoked by uid 500); 16 Apr 2014 21:58:41 -0000 Mailing-List: contact log4j-user-help@logging.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Log4J Users List" Reply-To: "Log4J Users List" Delivered-To: mailing list log4j-user@logging.apache.org Received: (qmail 95988 invoked by uid 99); 16 Apr 2014 21:58:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2014 21:58:41 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of ralph.goers@dslextreme.com designates 209.85.220.45 as permitted sender) Received: from [209.85.220.45] (HELO mail-pa0-f45.google.com) (209.85.220.45) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 16 Apr 2014 21:58:36 +0000 Received: by mail-pa0-f45.google.com with SMTP id kl14so11443096pab.32 for ; Wed, 16 Apr 2014 14:58:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:content-transfer-encoding:message-id:references:to; bh=C6eQb68rFB4IPI3u0ctvZPGirkXvY4LchHULrM6E2Ok=; b=gV9e6Yj1VkeEgHDzbzV/i9g3gfumrS+KEnyIGp7XgKzlNtbhZUraRl6OTHhp6N6ttC 1s3YeIYcN7R2vy2Z/0Bb7TnY6F+y25dVdHKskEPUMx26ttQbE+RO6yLCehagkTPrIYgY e3uVPV3ZMzCvwFV5rKfJZDAQ5o43PV5duw8fuwIuzLk83Dvs8VANoORLUWE9lVDfOk8L +6hyuk5bKGCiONL5dJUrWE3/Dtpx28Q+fqns0Y3jyEuoz+9WvjUH6HNs2cF9TRxdHmJP qCawEM2DE4d+TeZ2eBBAs/BftOCavz4GrrcVZrW95FQwiG2q75s9qozd1mhtEW+8CbRL uw0w== X-Gm-Message-State: ALoCoQkfrUXf99cNA+RUbvJYGTlNxTkKI+tlzedryb3htvi+POfWicnNXhmQcTZvbctbVGIKum4R X-Received: by 10.67.13.226 with SMTP id fb2mr11296374pad.146.1397685492622; Wed, 16 Apr 2014 14:58:12 -0700 (PDT) Received: from [192.168.1.44] ([209.12.167.2]) by mx.google.com with ESMTPSA id vd8sm116533482pac.12.2014.04.16.14.58.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 16 Apr 2014 14:58:11 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: How to make a custom connection source available in log4j 2 config? From: Ralph Goers In-Reply-To: Date: Wed, 16 Apr 2014 14:58:09 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <508D5C8E-330A-4317-847F-D1559C879366@dslextreme.com> References: To: Log4J Users List X-Mailer: Apple Mail (2.1874) X-Virus-Checked: Checked by ClamAV on apache.org If you are using 2.0-rc1 then you need to make sure that you either: a) have the packages attribute specified on the configuration element = with the correct package name of your plugin. b) have run the PluginManager against your plugin and included the file = it generated in your jar. An enhancement was recently added to trunk that cause the plugin file to = be generated by an annotation processor that is invoked during the = compile, making it easier for plugins to be located automatically. Ralph On Apr 16, 2014, at 12:55 PM, Jeff Shaw wrote: > Hello, > I made a custom connection source that I want to use. (Source follows > this message.) However, when I attempt to use my BoneCP connection > source in my config, I get the error, "ERROR JDBC contains an invalid > element or attribute "BoneCP"". What else do I need to do to make my > custom connection source available in the configuration? >=20 > I'm hoping the answer will also apply to a custom appender and manager > I've written, neither of which work because they also cannot be > instantiated from the configuration, however the error is a class not > found error. >=20 > Thanks, > Jeff >=20 > Source: >=20 > /** > * Copyright (c) Bit Gladiator on 2014. > */ >=20 > @Plugin(name =3D "BoneCP", category=3D"Core", elementType =3D > "connectionSource", printObject =3D true) > public class BoneCPConnectionSource implements ConnectionSource { > private static final Logger LOGGER =3D StatusLogger.getLogger(); >=20 > private final BoneCP pool; >=20 > private BoneCPConnectionSource(final BoneCP pool) { > this.pool =3D pool; > } >=20 > @PluginFactory > public static BoneCPConnectionSource createConnectionSource( > @PluginAttribute("url") final String url, > @PluginAttribute("username") final String username, > @PluginAttribute("password") final String password, > @PluginAttribute("partitionCount") final String partitionCount, > @PluginAttribute("connectionsPerPartition") final String > connectionsPerPartition > ) { > BoneCPConfig config =3D new BoneCPConfig(); > config.setJdbcUrl(url); > config.setUsername(username); > config.setPassword(password); > config.setPartitionCount(Integer.parseInt(partitionCount)); > = config.setMaxConnectionsPerPartition(Integer.parseInt(connectionsPerPartit= ion)); > try { > BoneCP pool =3D new BoneCP(config); > return new BoneCPConnectionSource(pool); > } catch (SQLException e) { > LOGGER.error("Failed to create the connection pool."); > return null; > } > } >=20 > @Override > public Connection getConnection() throws SQLException { > return pool.getConnection(); > } >=20 > @Override > public String toString() { > return pool.getConfig().toString(); > } > } >=20 > --------------------------------------------------------------------- > To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org > For additional commands, e-mail: log4j-user-help@logging.apache.org >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org For additional commands, e-mail: log4j-user-help@logging.apache.org