Skip to Content
author's profile photo Former Member
Former Member

Cannot obtain ObjectFactory for reference javax.sql.DataSource


I am using jdbc/DefaultDB as my datasource through spring-cloud-connector. While deploying it on Java Web Tomcat 7, I am getting below errors:

"Cannot obtain ObjectFactory for reference javax.sql.DataSource"

"org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/catalina/loader/WebappClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature

at org.slf4j.LoggerFactory.getILoggerFactory(

at org.slf4j.LoggerFactory.getLogger(

at org.slf4j.LoggerFactory.getLogger(


at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(

at java.lang.reflect.Constructor.newInstance(

at java.lang.Class.newInstance(

at java.util.ServiceLoader$LazyIterator.nextService(

Below is the code snippet for datasource lookup:

final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();


DataSource dataSource = dsLookup.getDataSource("java:comp/env/jdbc/DefaultDB");

return dataSource;

I have referenced this resource in my web.xml as follow:





Can someone please help in identifying the error resolution?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Aug 23, 2016 at 08:21 AM


    It seems that you've packaged SLF4J within your WAR. Remove it and try again.

    Kind regards,

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.