1 Reply Latest reply on Dec 19, 2013 11:11 AM by weimeilin

    Problem when starting Hot Rod Server instance

    weimeilin

      Hi,

       

      Using the quick start as example, I did a Cache Remote Hot Rod Server, it runs smoothly in my JBDS environment.

      But it throws this exception when I tried packaging it up into a jar file, and running it alone...

       

      2013-12-19 15:00:25,551 INFO  [LifecycleManager] (main) ISPN014003: Registering Query interceptor

      2013-12-19 15:00:25,557 INFO  [CacheJmxRegistration] (main) ISPN000031: MBeans were successfully registered to the platform MBean server.

      2013-12-19 15:00:25,564 INFO  [LifecycleManager] (main) ISPN014003: Registering Query interceptor

      2013-12-19 15:00:25,571 INFO  [CacheJmxRegistration] (main) ISPN000031: MBeans were successfully registered to the platform MBean server.

      java.lang.NullPointerException

        at org.infinispan.server.core.AbstractProtocolServer.registerTransportMBean(AbstractProtocolServer.scala:78)

        at org.infinispan.server.core.AbstractProtocolServer.startTransport(AbstractProtocolServer.scala:58)

        at org.infinispan.server.hotrod.HotRodServer.startTransport(HotRodServer.scala:77)

        at org.infinispan.server.core.AbstractProtocolServer.startInternal(AbstractProtocolServer.scala:39)

        at org.infinispan.server.hotrod.HotRodServer.startInternal(HotRodServer.scala:56)

        at org.infinispan.server.hotrod.HotRodServer.startInternal(HotRodServer.scala:29)

        at org.infinispan.server.core.AbstractProtocolServer.start(AbstractProtocolServer.scala:44)

        at com.redhat.jdgdemo.util.TestHelper.startHotRodServer(TestHelper.java:32)

        at com.redhat.jdgdemo.CacheServer.startHotRodServers(CacheServer.java:116)

        at com.redhat.jdgdemo.CacheServer.main(CacheServer.java:100)

       

      Here is some of my configurations in my code,

       

      GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder().clusteredDefault();
              gcb.globalJmxStatistics().enable().cacheManagerName("ChtPocCacheManager")
                    .allowDuplicateDomains(true)
                    .jmxDomain(JMX_DOMAIN)
                    .mBeanServerLookup(new PerThreadMBeanServerLookup())
                    .transport().addProperty("configurationFile", "jgroups-cht.xml");
      
             
              System.out.println("jmxDomain:["+JMX_DOMAIN+"]");
             
              ConfigurationBuilder builder = new ConfigurationBuilder();
              builder.dataContainer()
                    .keyEquivalence(ByteArrayEquivalence.INSTANCE)
                    .clustering().cacheMode(CacheMode.DIST_SYNC).hash().numOwners(2)
                    .indexing().enable()
                    .addProperty("default.directory_provider", getLuceneDirectoryProvider())
                    .addProperty("lucene_version", "LUCENE_CURRENT")
                    .jmxStatistics().enable();
               
              //cacheManager = createCacheManagerProgramatically();
              cacheManager = new DefaultCacheManager(gcb.build());
             
              for(String cache_name: CACHE_NAMES){
              cacheManager.defineConfiguration(cache_name, builder.build());
             
              }
      
         ProtocolServerConfiguration serverConfig = new HotRodServerConfigurationBuilder().host("127.0.0.1").port(15233).build();
          HotRodServer server = new HotRodServer();
          server.start(serverConfig, cacheManager);
      

       

      here is the pom.xml

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
          <modelVersion>4.0.0</modelVersion>
      
      
          <groupId>cht.jdgdemo</groupId>
          <artifactId>POC-Server</artifactId>
          <version>6.2.0-SNAPSHOT</version>
          <name>JBoss JDG Quickstart: hotrod-endpoint</name>
      
      
          <licenses>
              <license>
                  <name>Apache License, Version 2.0</name>
                  <distribution>repo</distribution>
                  <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
              </license>
          </licenses>
      
      
          <properties>
              <!-- Explicitly declaring the source encoding eliminates the following 
                  message: -->
              <!-- [WARNING] Using platform encoding (UTF-8 actually) to copy filtered 
                  resources, i.e. build is platform dependent! -->
              <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      
      
              <!-- Defines the main class to be execute when running java -jar 
                  command -->
              <main.class.hotrod-endpoint>com.redhat.jdgdemo.FootballManager</main.class.hotrod-endpoint>
      
      
              <version.org.infinispan>6.0.0.CR1</version.org.infinispan>
      
      
              <!-- other plugin versions -->
              <shade.plugin.version>1.5</shade.plugin.version>
              <exec.plugin.version>1.2.1</exec.plugin.version>
              <ant.plugin.version>1.7</ant.plugin.version>
      
      
              <!-- maven-compiler-plugin -->
              <maven.compiler.target>1.7</maven.compiler.target>
              <maven.compiler.source>1.7</maven.compiler.source>
          </properties>
      
      
          <dependencyManagement>
              <dependencies>
                  <dependency>
                      <groupId>org.infinispan</groupId>
                      <artifactId>infinispan-bom</artifactId>
                      <version>${version.org.infinispan}</version>
                      <type>pom</type>
                      <scope>import</scope>
                  </dependency>
              </dependencies>
          </dependencyManagement>
      
      
          <dependencies>
              <!-- Import the infinispan core -->
              <dependency>
                  <groupId>org.infinispan</groupId>
                  <artifactId>infinispan-core</artifactId>
              </dependency>
      
      
              <!-- Import the Infinispan client hotrod -->
              <dependency>
                  <groupId>org.infinispan</groupId>
                  <artifactId>infinispan-client-hotrod</artifactId>
                  <version>6.0.0.Final</version>
              </dependency>
              
              <dependency>
              <groupId>org.infinispan</groupId>
              <artifactId>infinispan-query</artifactId>
              </dependency>
              <dependency>
              <groupId>org.hibernate</groupId>
              <artifactId>hibernate-search-infinispan</artifactId>
              </dependency>
              <dependency>
              <groupId>org.infinispan.protostream</groupId>
              <artifactId>protostream</artifactId>
              </dependency>
              <dependency>
              <groupId>org.infinispan</groupId>
              <artifactId>infinispan-remote-query-client</artifactId>
              <optional>true</optional>
              </dependency>
              <dependency>
              <groupId>org.infinispan</groupId>
              <artifactId>infinispan-remote-query-server</artifactId>
              </dependency>
              <dependency>
              <groupId>org.infinispan</groupId>
              <artifactId>infinispan-server-hotrod</artifactId>
              <version>6.0.0.CR1</version>
              </dependency>
              <dependency>
                <groupId>org.infinispan</groupId>
                <artifactId>infinispan-server-hotrod</artifactId>
                <version>6.0.0.CR1</version>
              <type>test-jar</type>
                <scope>compile</scope>
              </dependency>
              <dependency>
              <groupId>org.scala-lang</groupId>
              <artifactId>scala-library</artifactId>
              </dependency>
          </dependencies>
      
      
          <build>
              <!-- Maven will append the version to the finalName (which is the 
                  name given to the generated jar) -->
              <finalName>${project.artifactId}</finalName>
              <plugins>
                  <!-- This plugin permits the execution of this quickstart 
                      through mvn exec:java command -->
                  <plugin>
                      <groupId>org.codehaus.mojo</groupId>
                      <artifactId>exec-maven-plugin</artifactId>
                      <version>${exec.plugin.version}</version>
                      <executions>
                          <execution>
                              <goals>
                                  <goal>java</goal>
                              </goals>
                          </execution>
                      </executions>
                      <configuration>
                          <mainClass>com.redhat.jdgdemo.CacheServer</mainClass>
                      </configuration>
                  </plugin>
                  <plugin>
             <artifactId>maven-assembly-plugin</artifactId>
             <configuration>
               <archive>
                 <manifest>
                   <mainClass>com.redhat.jdgdemo.CacheServer</mainClass>
                 </manifest>
               </archive>
               <descriptorRefs>
                 <descriptorRef>jar-with-dependencies</descriptorRef>
               </descriptorRefs>
             </configuration>
             <executions>
                        <execution>
                            <id>make-my-jar-with-dependencies</id>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
           </plugin>
              </plugins>
          </build>
      
      
          <profiles>
              <profile>
                  <id>custom-classpath</id>
                  <build>
                      <plugins>
                          <plugin>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-antrun-plugin</artifactId>
                              <version>${ant.plugin.version}</version>
                              <executions>
                                  <execution>
                                      <id>prepare-directories</id>
                                      <phase>generate-sources</phase>
                                      <goals>
                                          <goal>run</goal>
                                      </goals>
                                      <configuration>
                                          <tasks>
                                              <echo message="Build create lib/ directory"/>
                                              <delete dir="${project.build.directory}/lib"/>
                                              <mkdir dir="${project.build.directory}/lib"/>
                                          </tasks>
                                      </configuration>
                                  </execution>
                                  <execution>
                                      <id>copy-dependencies</id>
                                      <phase>prepare-package</phase>
                                      <goals>
                                          <goal>run</goal>
                                      </goals>
                                      <configuration>
                                          <tasks>
                                              <echo message="Copying libraries from server distribution to lib/ directory"/>
                                              <copy todir="${project.build.directory}/lib">
                                                  <fileset
                                                          dir="${classpath}">
                                                      <include name="*.jar"/>
                                                  </fileset>
                                              </copy>
                                              <pathconvert pathsep=" " property="jar.classpath">
                                                  <fileset dir="${project.build.directory}/lib"/>
                                                  <chainedmapper>
                                                      <flattenmapper/>
                                                      <filtermapper>
                                                          <replacestring from=" " to="%20"/>
                                                      </filtermapper>
                                                      <globmapper from="*" to="lib/*"/>
                                                  </chainedmapper>
                                              </pathconvert>
                                              <echo message="CLASSPATH= ${jar.classpath}"/>
                                          </tasks>
                                          <exportAntProperties>true</exportAntProperties>
                                      </configuration>
                                  </execution>
                              </executions>
                          </plugin>
      
      
                          <plugin>
                              <groupId>org.apache.maven.plugins</groupId>
                              <artifactId>maven-jar-plugin</artifactId>
                              <configuration>
                                  <archive>
                                      <manifest>
                                          <addDefaultImplementationEntries>false</addDefaultImplementationEntries>
                                          <addClasspath>true</addClasspath>
                                          <mainClass>com.redhat.jdgdemo.CacheServer</mainClass>
                                      </manifest>
                                      <manifestEntries>
                                          <Class-Path>${jar.classpath}</Class-Path>
                                      </manifestEntries>
                                  </archive>
                              </configuration>
                          </plugin>
                      </plugins>
                  </build>
              </profile>