title: javax.cache.CacheException: Failed to parse query. Table not found
body: <p>My code starts the node and executes the loadCache() method but when SQL query is applied to it, it gives the error mentioned in the title. Here is my code for configuration, cachestore and loadcache:</p>
  
  <p>Configuration.java:</p>
  
  <pre><code>public class Configuration {
  
  /** Helper class for datasource creation. **/
  public static class DataSources {
      public static final JdbcDataSource dataSource = createdataSource();
  
      private static JdbcDataSource createdataSource() {
          JdbcDataSource dataSource = new JdbcDataSource();
  
          dataSource.setURL("");
          dataSource.setUser("");
          dataSource.setPassword("");
  
          return dataSource;
      }
  }
  
  /**
   * Configure grid.
   * 
   * @return Ignite configuration.
   * @throws Exception If failed to construct Ignite configuration instance.
   **/
  public static IgniteConfiguration createConfiguration() throws Exception {
      //int cpus = Runtime.getRuntime().availableProcessors();
      IgniteConfiguration cfg = new IgniteConfiguration();
  
      cfg.setClientMode(true);
      cfg.setIgniteInstanceName("Reports");
  
      TcpDiscoverySpi discovery = new TcpDiscoverySpi();
  
      TcpDiscoveryMulticastIpFinder ipFinder = new TcpDiscoveryMulticastIpFinder();
  
      ipFinder.setAddresses(Collections.singletonList(""));
  
      discovery.setIpFinder(ipFinder);
  
      cfg.setDiscoverySpi(discovery);
  
  
      //cfg.setPeerClassLoadingEnabled(true);
  
      cfg.setCacheConfiguration(cacheOutputReportCache());
  
      return cfg;
  }
  
  
  
   //Configuration for cache "OutputReportCache".
  public static CacheConfiguration&lt;Long, OutputReport&gt; cacheOutputReportCache() throws Exception {
      CacheConfiguration&lt;Long, OutputReport&gt; ccfg = new CacheConfiguration&lt;&gt;();
  
      ccfg.setName("OutputReportCache");
      ccfg.setCacheMode(CacheMode.PARTITIONED);
      ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
  
      CacheJdbcPojoStoreFactory&lt;Long, OutputReport&gt; cacheStoreFactory = new CacheJdbcPojoStoreFactory&lt;&gt;();
  
      cacheStoreFactory.setDataSourceFactory(new Factory&lt;DataSource&gt;() {
          /**
           * 
           */
          private static final long serialVersionUID = 1L;
  
          @Override 
          public DataSource create() {
              return DataSources.dataSource;
          };
      });
  
      cacheStoreFactory.setDialect(new OracleDialect());
  
      ccfg.setCacheStoreFactory(cacheStoreFactory);
  
      ccfg.setReadThrough(true);
      ccfg.setWriteThrough(true);
  
      ArrayList&lt;QueryEntity&gt; qryEntities = new ArrayList&lt;&gt;();
  
      QueryEntity qryEntity = new QueryEntity();
  
      qryEntity.setKeyType(String.class.getName());
      qryEntity.setValueType(OutputReport.class.getName());
  
      LinkedHashMap&lt;String, String&gt; fields = new LinkedHashMap&lt;&gt;();
  
      fields.put("sid", "java.lang.String");
      fields.put("sName", "java.lang.String");
      fields.put("cname", "java.lang.String");
      fields.put("cnumber", "java.lang.String");
      fields.put("cname", "java.lang.String");
      fields.put("cid", "java.lang.String");
      fields.put("r", "java.lang.String");
      fields.put("b", "java.lang.String");
      fields.put("Date", "java.lang.String");
      fields.put("Side", "java.lang.String");
      fields.put("Quant", "java.lang.Float");
      fields.put("price", "java.lang.Float");
      fields.put("local", "java.lang.Float");
      fields.put("usd", "java.lang.Float");
      fields.put("trcy", "java.lang.String");
      fields.put("Count", "java.lang.Integer");
      fields.put("Type", "java.lang.String");
      fields.put("Category", "java.lang.String");
      fields.put("Subcategory", "java.lang.String");
      fields.put("Country", "java.lang.String");
      fields.put("eCountry", "java.lang.String");
      fields.put("Desc", "java.lang.String");
      fields.put("Sector", "java.lang.String");
      fields.put("isector", "java.lang.String");
      fields.put("Flag", "java.lang.String");
      fields.put("Region", "java.lang.String");
      fields.put("rowNum", "java.lang.Long");
  
      qryEntity.setFields(fields);
  
   // Listing indexes.
      Collection&lt;QueryIndex&gt; indexes = new ArrayList&lt;&gt;(3);
  
      indexes.add(new QueryIndex("sid"));
      indexes.add(new QueryIndex("Region"));
      indexes.add(new QueryIndex("cnumber"));
      indexes.add(new QueryIndex("eCountry"));
  
      qryEntity.setIndexes(indexes);
  
      qryEntities.add(qryEntity);
  
      ccfg.setQueryEntities(qryEntities);
  
      return ccfg;
  }
  }
  </code></pre>
  
  <p>OutputReportStore.java:</p>
  
  <pre><code>public class OutputReportStore implements CacheStore&lt;Long, OutputReport&gt; {
      //@SpringResource(resourceName = "dataSource")
      private DataSource dataSource = DataSources.dataSource;
      // This method is called whenever IgniteCache.loadCache() method is called.
      @Override
      public void loadCache(IgniteBiInClosure&lt;Long, OutputReport&gt; clo, @Nullable Object... objects) throws CacheLoaderException {
          System.out.println("&gt;&gt; Loading cache from store...");
          try (Connection conn = dataSource.getConnection()) {
              try (PreparedStatement st = conn.prepareStatement("select * from OUTPUTREPORT")) {
                  try (ResultSet rs = st.executeQuery()) {
                      while (rs.next()) {
                          OutputReport outputreport = new OutputReport(rs.getString(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5), rs.getString(6), rs.getString(7), rs.getString(8), rs.getString(9), rs.getString(10), rs.getFloat(11), rs.getFloat(12), rs.getFloat(13), rs.getFloat(14), rs.getString(15), rs.getInt(16), rs.getString(17), rs.getString(18), rs.getString(19), rs.getString(20), rs.getString(21), rs.getString(22), rs.getString(23), rs.getString(24), rs.getString(25), rs.getString(26), rs.getLong(27));
                          clo.apply(outputreport.getrowNum(), outputreport);
                      }
                  }
              }
          }
          catch (SQLException e) {
              throw new CacheLoaderException("Failed to load values from cache store.", e);
          }
      }
  
      // Other CacheStore method implementations.
      @Override
      public OutputReport load(Long arg0) throws CacheLoaderException {
          // TODO Auto-generated method stub
          return null;
      }
      @Override
      public void delete(Object arg0) throws CacheWriterException {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void write(Entry&lt;? extends Long, ? extends OutputReport&gt; arg0)
              throws CacheWriterException {
          // TODO Auto-generated method stub
  
      }
      @Override
      public Map&lt;Long, OutputReport&gt; loadAll(Iterable&lt;? extends Long&gt; arg0)
              throws CacheLoaderException {
          // TODO Auto-generated method stub
          return null;
      }
      @Override
      public void deleteAll(Collection&lt;?&gt; arg0) throws CacheWriterException {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void writeAll(
              Collection&lt;Entry&lt;? extends Long, ? extends OutputReport&gt;&gt; arg0)
              throws CacheWriterException {
          // TODO Auto-generated method stub
  
      }
      @Override
      public void sessionEnd(boolean arg0) throws CacheWriterException {
          // TODO Auto-generated method stub
  
      }
  
  }
  </code></pre>
  
  <p>LoadCaches.java:</p>
  
  <pre><code>public class LoadCaches {
      //Load caches from database.
      //1. Start cluster
      //2. Start this utility and wait while load complete
  
      public static void main(String[] args) throws Exception {
          try (Ignite ignite = Ignition.start(Configuration.createConfiguration())) {
  
              System.out.println("&gt;&gt;&gt; Loading cache: OutputReportCache");
              IgniteCache&lt;Long, OutputReport&gt; cache = ignite.getOrCreateCache("OutputReportCache");
      cache.loadCache(null);
  
      System.out.println("&gt;&gt;&gt; Cache loaded!");
  
      QueryCursor&lt;List&lt;?&gt;&gt; cursor = cache.query(new SqlFieldsQuery("select count(*) from outputreport"));
      System.out.println(cursor.getAll());
          }
      }
  }
  </code></pre>
  
  <p>Here is the stack trace:</p>
  
  <blockquote>
    <p>[16:59:22] Ignite node started OK (id=90c9464d, instance name=Reports)
    [16:59:22] Topology snapshot [ver=29, servers=1, clients=6, CPUs=12,
    offheap=90.0GB, heap=36.0GB] [16:59:22]   ^-- Node
    [id=90C9464D-A48A-4DB7-8812-65CE5FD4B8FD, clusterState=ACTIVE]</p>
    
    <blockquote>
      <blockquote>
        <blockquote>
          <p>Loading cache: OutputReportCache
          Cache loaded! Exception in thread "main" javax.cache.CacheException: Failed to parse query. Table
          "OUTPUTREPORT" not found; SQL statement: select count(<em>) from
          outputreport [42102-196]  at
          org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:676)
            at
          org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:615)
            at
          org.apache.ignite.internal.processors.cache.GatewayProtectedCacheProxy.query(GatewayProtectedCacheProxy.java:356)
            at project4.LoadCaches.main(LoadCaches.java:26) Caused by: class
          org.apache.ignite.internal.processors.query.IgniteSQLException: Failed
          to parse query. Table "OUTPUTREPORT" not found; SQL statement: select
          count(</em>) from outputreport [42102-196]    at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatementAndCaches(IgniteH2Indexing.java:2026)
            at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.parseAndSplit(IgniteH2Indexing.java:1796)
            at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.querySqlFields(IgniteH2Indexing.java:1652)
            at
          org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2035)
            at
          org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:2030)
            at
          org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
            at
          org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2578)
            at
          org.apache.ignite.internal.processors.query.GridQueryProcessor.querySqlFields(GridQueryProcessor.java:2044)
            at
          org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.query(IgniteCacheProxyImpl.java:664)
            ... 3 more Caused by: org.h2.jdbc.JdbcSQLException: Table
          "OUTPUTREPORT" not found; SQL statement: select count(*) from
          outputreport [42102-196]  at
          org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
            at org.h2.message.DbException.get(DbException.java:179)     at
          org.h2.message.DbException.get(DbException.java:155)  at
          org.h2.command.Parser.readTableOrView(Parser.java:5552)   at
          org.h2.command.Parser.readTableFilter(Parser.java:1266)   at
          org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1946)     at
          org.h2.command.Parser.parseSelectSimple(Parser.java:2095)     at
          org.h2.command.Parser.parseSelectSub(Parser.java:1940)    at
          org.h2.command.Parser.parseSelectUnion(Parser.java:1755)  at
          org.h2.command.Parser.parseSelect(Parser.java:1743)   at
          org.h2.command.Parser.parsePrepared(Parser.java:449)  at
          org.h2.command.Parser.parse(Parser.java:321)  at
          org.h2.command.Parser.parse(Parser.java:293)  at
          org.h2.command.Parser.prepareCommand(Parser.java:258)     at
          org.h2.engine.Session.prepareLocal(Session.java:578)  at
          org.h2.engine.Session.prepareCommand(Session.java:519)    at
          org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1204)
            at
          org.h2.jdbc.JdbcPreparedStatement.(JdbcPreparedStatement.java:73)
            at
          org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:288)
            at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepare0(IgniteH2Indexing.java:484)
            at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:452)
            at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:419)
            at
          org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatementAndCaches(IgniteH2Indexing.java:2008)
            ... 11 more</p>
        </blockquote>
      </blockquote>
    </blockquote>
  </blockquote>
  
  <p>How can this be resolved?</p>