2016-10-04 24 views
1

キャッシュを作成しようとしています(実際にどのように動作するかを理解するためにサンプルコードからほぼコピーして貼り付けています)。私はのIgniteノードを開始することができるよしかしときにはキャッシュを作成しようとする時にスタックトレースを次のようにエラーを取得:Apache Igniteキャッシュの作成中にエラーが発生しました

Exception in thread "main" 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:/C:/temp/apache-ignite-fabric-1.7.0-bin/examples/config/example-ignite.xml] 
    at org.apache.ignite.internal.util.IgniteUtils.convertException(IgniteUtils.java:881) 
    at org.apache.ignite.Ignition.start(Ignition.java:349) 
    at ignite.HelloWorld.CacheApiExample.main(CacheApiExample.java:18) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:498) 
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) 
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:/C:/temp/apache-ignite-fabric-1.7.0-bin/examples/config/example-ignite.xml] 
    at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:370) 
    at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:87) 
    at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.loadConfigurations(IgniteSpringHelperImpl.java:81) 
    at org.apache.ignite.internal.IgnitionEx.loadConfigurations(IgnitionEx.java:596) 
    at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:774) 
    at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:705) 
    at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:576) 
    at org.apache.ignite.internal.IgnitionEx.start(IgnitionEx.java:546) 
    at org.apache.ignite.Ignition.start(Ignition.java:346) 
    ... 6 more 
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.h2.jdbcx.JdbcDataSource] for bean with name 'h2-example-db' defined in URL [file:/C:/temp/apache-ignite-fabric-1.7.0-bin/examples/config/example-default.xml]; nested exception is java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource 
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1325) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:623) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:592) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1394) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:957) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:705) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 
    at org.apache.ignite.internal.util.spring.IgniteSpringHelperImpl.applicationContext(IgniteSpringHelperImpl.java:364) 
    ... 14 more 
Caused by: java.lang.ClassNotFoundException: org.h2.jdbcx.JdbcDataSource 
    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:246) 
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:395) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1346) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1317) 
    ... 22 more 

コードは次のとおりです。

import org.apache.ignite.Ignite; 
import org.apache.ignite.IgniteCache; 
import org.apache.ignite.IgniteException; 
import org.apache.ignite.Ignition; 
import org.apache.ignite.cache.CacheAtomicityMode; 
import org.apache.ignite.configuration.CacheConfiguration; 
import org.apache.ignite.spi.indexing.IndexingQueryFilter; 

/** 
* Created by s.kachkin on 9/30/2016. 
*/ 
public class CacheApiExample { 
    public static void main(String[] args) throws IgniteException { 
     Ignition.setClientMode(true); 

     try(Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) { 
      CacheConfiguration<Integer, String> cfg = new CacheConfiguration<>(); 
      cfg.setName("Democache"); 
      cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); 

      IgniteCache<Integer, String> cache = ignite.getOrCreateCache(cfg); 

      cache.put(1, "cache item 1"); 
      cache.put(2, "cache item 2"); 

      System.out.println(cache.get(1)); 
      System.out.println(cache.get(2)); 
     } 
    } 
} 

答えて

1

$ IGNITE_HOMEていることを確認してください/ libs/ignite-indexing/*はクラスパスにあります。

またはH2への依存が含まれている必要があり、あなたのプロジェクト:

<dependency> 
    <groupId>com.h2database</groupId> 
    <artifactId>h2</artifactId> 
    <version>1.3.175</version> 
</dependency> 
+0

おかげで、タラス!それはエラーを回避するのに役立ちました。 – caccini

関連する問題