Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Logback DBAppender in Virgo. (How configure DBAppender in serviceability.xml)
Logback DBAppender in Virgo. [message #869417] Thu, 03 May 2012 11:22 Go to next message
Dmitry Axenenko is currently offline Dmitry AxenenkoFriend
Messages: 3
Registered: August 2011
Junior Member
I have log configuration

<?xml version="1.0" encoding="UTF-8"?>
<included>
	<property name="serverName" value="127.0.0.1" />
	<property name="port" value="3306" />
	<property name="dbName" value="struct" />
	<property name="user" value="root" />
	<property name="password" value="root" />

	<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
   <connectionSource class="ch.qos.logback.core.db.DriverManagerConnectionSource">
				<driverClass>com.mysql.jdbc.Driver</driverClass>
				url>jdbc:mysql://${serverName}:${port}/${dbName}/url>
				<user>${user}</user>
				<password>${password}</password>
		
		</connectionSource>
	</appender>

	<logger name="db" level="TRACE" additivity="false">
		<appender-ref ref="DB" />
	</logger>


</included>



and include it in serviceability.xml

but I got the follow error
 Configuration failed with the following problems: [Could not load JDBC driver class: com.mysql.jdbc.Driver, RuntimeException in Action for tag [appender]]

and full trace
[size=6]org.eclipse.virgo.medic.log.impl.logback.LoggerContextConfigurationFailedException: Configuration failed with the following problems: [Could not load JDBC driver class: com.mysql.jdbc.Driver, RuntimeException in Action for tag [appender]]
	at org.eclipse.virgo.medic.log.impl.logback.JoranLoggerContextConfigurer.reportFailureIfNecessary(JoranLoggerContextConfigurer.java:54)
	at org.eclipse.virgo.medic.log.impl.logback.JoranLoggerContextConfigurer.applyConfiguration(JoranLoggerContextConfigurer.java:46)
	at org.eclipse.virgo.medic.log.impl.logback.StandardContextSelectorDelegate.configureDefaultContext(StandardContextSelectorDelegate.java:133)
	at org.eclipse.virgo.medic.log.impl.logback.DelegatingContextSelector.configureDefaultContextIfNecessary(DelegatingContextSelector.java:41)
	at org.eclipse.virgo.medic.log.impl.logback.DelegatingContextSelector.setDefaultLoggerContext(DelegatingContextSelector.java:34)
	at org.eclipse.virgo.medic.log.impl.logback.DelegatingContextSelector.<init>(DelegatingContextSelector.java:29)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at ch.qos.logback.classic.util.ContextSelectorStaticBinder.dynamicalContextSelector(ContextSelectorStaticBinder.java:100)
	at ch.qos.logback.classic.util.ContextSelectorStaticBinder.init(ContextSelectorStaticBinder.java:72)
	at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:90)
	at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55)
	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:121)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:268)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:241)
	at org.eclipse.virgo.medic.log.impl.LoggingPrintStreamWrapper.<init>(LoggingPrintStreamWrapper.java:66)
	at org.eclipse.virgo.medic.impl.MedicActivator.wrapPrintStream(MedicActivator.java:188)
	at org.eclipse.virgo.medic.impl.MedicActivator.logStart(MedicActivator.java:176)
	at org.eclipse.virgo.medic.impl.MedicActivator.start(MedicActivator.java:108)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
	at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
	at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
	at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:291)
	at org.eclipse.virgo.osgi.launcher.FrameworkBuilder.installAndStartBundles(FrameworkBuilder.java:187)
	at org.eclipse.virgo.osgi.launcher.FrameworkBuilder.start(FrameworkBuilder.java:159)
	at org.eclipse.virgo.osgi.launcher.Launcher.main(Launcher.java:54)[/size]


virgo version - 3.0.1.RELEASE

How include com.mysql.jdbc.Driver to classpath virgo kernel?
Re: Logback DBAppender in Virgo. [message #869730 is a reply to message #869417] Fri, 04 May 2012 05:00 Go to previous messageGo to next message
Dmitry Axenenko is currently offline Dmitry AxenenkoFriend
Messages: 3
Registered: August 2011
Junior Member
I try put mysql-connector-java-5.1.19.jar to virgo-tomcat-server-3.0.1.RELEASE\lib\kernel\ - no effect.

I resolve it. But it's ugly.
I put mysql-connector-java-5.1.19.jar to org.eclipse.virgo.medic.core-3.0.1.RELEASE.jar and add line to Bundle-ClassPath

Bundle-ClassPath: .,com.springsource.ch.qos.logback.classic-0.9.24.jar
 ,com.springsource.ch.qos.logback.core-0.9.24.jar,mysql-connector-java-5.1.19.jar


Re: Logback DBAppender in Virgo. [message #871120 is a reply to message #869730] Fri, 11 May 2012 00:18 Go to previous messageGo to next message
Mastah Naleh is currently offline Mastah NalehFriend
Messages: 32
Registered: April 2012
Member
Anything that is using java.sql.DriverManager will fail to load JDBC driver in osgi.
Sadly for you, I just looked at the code source of ch.qos.logback.core.db.DriverManagerConnectionSource and it's using it.

Try some other kind of datasources like commons-dbcp (BasicDataSource) or spring one (SimpleDataSource). Try using ch.qos.logback.core.db.DataSourceConnectionSource.

Have a look here : forum.springsource.org/showthread.php?77332-java-sql-SQLException-No-suitable-driver-when-deployed-the-Osgi-bundle-in-servicemix
Re: Logback DBAppender in Virgo. [message #871121 is a reply to message #871120] Fri, 11 May 2012 00:23 Go to previous messageGo to next message
Mastah Naleh is currently offline Mastah NalehFriend
Messages: 32
Registered: April 2012
Member
Could you try :

<configuration>

<appender name="DB" class="ch.qos.logback.classic.db.DBAppender">
<connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
<dataSource class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<driverClass>com.mysql.jdbc.Driver</driverClass>
<url>jdbc:mysql://${serverName}:${port}/${dbName}</url>
<user>${user}</user>
<password>${password}</password>
</dataSource>
</connectionSource>
</appender>

<root level="DEBUG">
<appender-ref ref="DB" />
</root>
</configuration>

That should do the trick.

Edit: you'll need org.springframework.jdbc.datasource as bundle import.
If you find better than using spring-orm feel free. I just did not checked all the data source around to see if they were working (I know that c3p0 and all datasource using DriverManager won't work)

[Updated on: Fri, 11 May 2012 00:27]

Report message to a moderator

Re: Logback DBAppender in Virgo. [message #871370 is a reply to message #871121] Sat, 12 May 2012 15:41 Go to previous messageGo to next message
Mastah Naleh is currently offline Mastah NalehFriend
Messages: 32
Registered: April 2012
Member
Any feedback if that's working ?
Re: Logback DBAppender in Virgo. [message #875046 is a reply to message #871370] Tue, 22 May 2012 03:16 Go to previous message
Dmitry Axenenko is currently offline Dmitry AxenenkoFriend
Messages: 3
Registered: August 2011
Junior Member
Thanks for replays. I try it later.
Previous Topic:Spring MVC Web-bundle no context created
Next Topic:log cookies
Goto Forum:
  


Current Time: Mon Dec 22 16:31:31 GMT 2014

Powered by FUDForum. Page generated in 0.01779 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software