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

ceki ceki at qos.ch
Thu May 2 18:25:21 CEST 2013


Right before the error, there should be a message saying:

  "Looking up $SOME_LOCATION_NAME in JNDI"

What does it say?


On 02.05.2013 18:13, sgarlick wrote:
> I turned on debug, but it doesn't provide anymore relevant information than
>
> ERROR in ch.qos.logback.core.db.JNDIConnectionSource at 47f0bdcb - Error while
> getting data source javax.naming.NameNotFoundException: Name
> [comp/env/jdbc/datasource] is not bound in this Context. Unable to find
> [comp].
>          at javax.naming.NameNotFoundException: Name
> [comp/env/jdbc/datasource] is not bound in this Context. Unable to find
> [comp].
>          at javax.naming.NameNotFoundException: Name
> [comp/env/jdbc/datasource] is not bound in this Context. Unable to find
> [comp].
>          at at org.apache.naming.NamingContext.lookup(NamingContext.java:820)
>          at at org.apache.naming.NamingContext.lookup(NamingContext.java:168)
>          at at
> org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
>          at at javax.naming.InitialContext.lookup(InitialContext.java:411)
>          at at
> ch.qos.logback.core.db.JNDIConnectionSource.lookupDataSource(JNDIConnectionSource.java:100)
>
>
> I'm beginning to think this might be a TomEE issue and not logback.  The
> only thing I can think of is that TomEE is initializing logging, before it
> fills out the naming context.  I'm going to cross post this issue on their
> forum and see if they know whats up.
>
>
> Ceki Gulcu wrote
>> Hello,
>>
>> Can you set the debug attribute to true in
>> <configuration>
>>   and post on
>> this list the status messages printed by logback? If that does not
>> help, can you please run the your examples in a debugger to track down
>> the reason for the different behaviors?
>>
>> On 02.05.2013 02:40, sgarlick wrote:
>>> 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.
>>>
>>>
>>
>>
>> --
>> Ceki
>> 65% of statistics are made up on the spot
>> _______________________________________________
>> Logback-user mailing list
>
>> Logback-user@
>


-- 
Ceki
65% of statistics are made up on the spot


More information about the Logback-user mailing list