You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by ABDumalagan <ad...@scarletmail.rutgers.edu> on 2020/11/05 18:27:08 UTC

Connecting to RDBMS - Failed to instantiate Spring XML application context

Hello all,

This is my first time using Apache Ignite, and I am working directly with
the given example configuration files in the binary release folder. 

Currently I am using PuTTY, and my objective is to load data from an
existing Oracle database into cache. The first and only step I've taken
right now is to create my own XML file with the  CacheJdbcBlobStore
configurations
<https://ignite.apache.org/docs/latest/persistence/external-storage#cachejdbcblobstore> 
, and I pass the file as a parameter to the script /bash ignite [file
path]/. 

The error I get is class /org.apache.ignite.IgniteException: Failed to
instantiate Spring XML application context/, and I think it's caused by
/org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find
class/

I have tried to  set and export USER_LIBS to the
apache-ignite-2.8.1-bin/benchmarks/libs file path, however I still get the
same error. 

Below I have my XML file config and error log - any advice or help is
appreciated! 


*XML File
*
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
       xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
       xsi:schemaLocation=&quot;
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd&quot;>
    <bean id="mysqlDataSource"
class="com.mysql.jdbc.jdbc2.optional.MysqlDataSource">
        <property name="URL"
value="jdbc:oracle:thin:@//[host]:[port]/[database]"/>
        <property name="user" value="[username]"/>
        <property name="password" value="[password]"/>
    </bean>
    <bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
        <property name="cacheConfiguration">
            <list>
               
                <bean
class="org.apache.ignite.configuration.CacheConfiguration">
                    <property name="name" value="default"/>
                    <property name="cacheStoreFactory">
                        <bean
class="org.apache.ignite.cache.store.jdbc.CacheJdbcBlobStoreFactory">
                        <property name="dataSourceBean" value =
"mysqlDataSource" />
                        </bean>
                    </property>
                </bean>
            </list>
        </property>

       
        <property name="discoverySpi">
            <bean
class="org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi">
                <property name="ipFinder">
                   
                   
                    <bean
class="org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder">
                        <property name="addresses">
                            <list>
                               
                                <value>127.0.0.1:47500..47509</value>
                            </list>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    </bean>
</beans>


*Error*

class org.apache.ignite.IgniteException: Failed to instantiate Spring XML
application context (make sure all classes used in Spring configuration are
present at CLASSPATH)
[springUrl=file:/app/apache/apache-ignite-2.8.1-bin/examples/config/example-cache-blob-store.xml]
        at
org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:1067)
        at org.apache.ignite.Ignition.start(Ignition.java:349)
        at
org.apache.ignite.startup.cmdline.CommandLineStartup.main(CommandLineStartup.java:300)
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to
instantiate Spring XML application context (make sure all classes used in
Spring configuration are present at CLASSPATH)
[springUrl=file:/app/apache/apache-ignite-2.8.1-bin/examples/config/example-cache-blob-store.xml]
        at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:387)
        at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:104)
        at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:98)
        at
org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:710)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:911)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:820)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:690)
        at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:659)
        at org.apache.ignite.Ignition.start(Ignition.java:346)
        ... 1 more
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException:
Cannot find class [com.mysql.jdbc.jdbc2.optional.MysqlDataSource] for bean
with name 'mysqlDataSource' defined in URL
[file:/app/apache/apache-ignite-2.8.1-bin/examples/config/example-cache-blob-store.xml];
nested exception is java.lang.ClassNotFoundException:
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
        at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1397)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:638)
        at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:607)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1496)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1018)
        at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:737)
        at
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)
        at
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
        at
org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:381)
        ... 9 more
Caused by: java.lang.ClassNotFoundException:
com.mysql.jdbc.jdbc2.optional.MysqlDataSource
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at org.springframework.util.ClassUtils.forName(ClassUtils.java:251)
        at
org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:408)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1444)
        at
org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1389)
        ... 17 more
Failed to start grid: Failed to instantiate Spring XML application context
(make sure all classes used in Spring configuration are present at
CLASSPATH)
[springUrl=file:/app/apache/apache-ignite-2.8.1-bin/examples/config/example-cache-blob-store.xml]
Note! You may use 'USER_LIBS' environment variable to specify your
classpath.




--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Connecting to RDBMS - Failed to instantiate Spring XML application context

Posted by akorensh <al...@gmail.com>.
Hi,
  If you look at the message, on the very bottom it tells you:

  Caused by: java.lang.ClassNotFoundException:
com.mysql.jdbc.jdbc2.optional.MysqlDataSource

  This means that the class in question is not on the classpath of the Java
VM.

   Add the relevant library to the classpath and it should work.
   
  To diagnose:
   1. start w/out this bean, and use visualvm/jinfo/jps or the logs inside
ignite to see what the classpath is.
   2. if you see that the relevant library is not there, add it to the place
where ignite will look for it.
      usually in the ${ignite_home}/libs dir. 
   3. restart w/out that bean and verify that the classpath contains your
jar file
   4. Once you verified that the classpath is correct, start w/the bean in
question.

 see:
https://ignite.apache.org/docs/latest/installation/installing-using-docker#deploying-user-libraries

https://stackoverflow.com/questions/17151058/how-can-i-view-the-classpath-and-jvm-args-of-an-executing-java-program-in-window

Also Ignite will show you the classpath of the process:
 look for: [INFO ][main][IgniteKernal%node1] Classpath value:
 (here you need to start ignite w/the vm system property IGNITE_QUIET=false)
   https://ignite.apache.org/docs/latest/logging#overview

Thanks, Alex



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/