Hi, I have an application running on TomEE 1.5.2 and have configured logback
in the application.  This works fine, and the application starts and logging
is fine.  

Now I've tried to configure the logback DBApender, using the JNDI connection
source and it fails to find the datasource.  This is not a issue when
looking up the datasource in my application beans using the same jndi
location.

Versions
logback 1.0.12
slf4j 1.75
slf4j-jcl 1.75
TomEE 1.5.2

My configuration

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)))" />

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>


logback.xml

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

code for successful look up in the application

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

And I've debugged the logback code and it is looking up the same resource as
the above code, but fails unlike the above code.

The only thing I can think of is that TomEE initializes logging before
initialing the naming context?  Otherwise I don't understand how it can fail
the initial lookup, but then later successfully lookup the same thing.

Please let me know if there is anymore information I can provide.  Thanks.



--
View this message in context: 
http://openejb.979440.n4.nabble.com/TomEE-with-logback-DBAppender-failing-jndi-lookup-tp4662655.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to