[logback-user] DBAppender fails for find jndi dataSource from TomEE

sgarlick sgarlick987 at gmail.com
Thu May 2 02:40:45 CEST 2013


Hi, I've been having some issues setting up the DBAppender using a jndi
DataSource supplied by TomEE. The datasource works fine in the application,
but logback errors out when setting up its DBAppender with the same jndi
location. 

Specifically JNDIConnectionSource.lookupDataSource throws a NamingException,
which does the
same lookup as my application code, but only the application code finds the
datasource successfully.

TomEE version 1.5.2
Logback classic 1.0.9

I've configured a DBAppender in logback.xml as so

  <appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource class="ch.qos.logback.core.db.JNDIConnectionSource">
      <jndiLocation>java:comp/env/jdbc/datasource</jndiLocation>
    </connectionSource>
  </appender>

in web.xml

  <resource-ref>
    <res-ref-name>jdbc/datasource</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
  </resource-ref>

in tomee context.xml

        <Resource name="jdbc/datasource" auth="Container"
                type="javax.sql.DataSource"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
                maxActive="100" maxIdle="30" maxWait="10000" username="user"
                password="secret"
driverClassName="oracle.jdbc.driver.OracleDriver"
                url="jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS = (PROTOCOL =
TCP) (HOST =
localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME =
SERVICE)))" />

and my application dataSource bean successfully finds the dataSource

        Context ctx = new InitialContext();
        return (DataSource) ctx.lookup("java:comp/env/jdbc/datasource");

Please let me know if anymore information is needed.



--
View this message in context: http://logback.10977.n7.nabble.com/DBAppender-fails-for-find-jndi-dataSource-from-TomEE-tp12265.html
Sent from the Users mailing list archive at Nabble.com.


More information about the Logback-user mailing list