Archived

This forum has been archived. Please start a new discussion on GitHub.

could not find the main class on linux using IceGrid

I use jar for the server side of IceGrid, it worked perfect on windows, when i deploy it on linux, it throws the exception java.lang.NoClassDefFoundError, however when i start it using "java -jar **.jar" it worked well, so i suppose the jar file is fine. Can anyone help me about this? Thanks a lot!

Comments

  • some more information about this fault

    My os is linux 32bit and i build the source on it, i got a "Foward is not defined" when i run "ant" command but when i run "ant install" it seems ok. I wanna ask if i use java as Server,should i install java version of ICE? if so, does the problem came because the above fault? Or should I configure something to support java in ICE? Can anyone help me for this? Thanks a lot.Attachment not found.
  • benoit
    benoit Rennes, France
    Hi,

    Can you copy/paste the full stack trace of the java.lang.NoClassDefFoundError exception?

    You need to have the Ice.jar file and the classes for your server in the Java classpath.

    Cheers,
    Benoit.
  • full stack trace

    the full stack trace is :

    [root@localhost CaaSP_node_localhost]# icegridnode --Ice.Config=config.node
    -- 10/21/13 17:28:01.842 icegridnode: Activator: activating server `SimpleServer'
    path = java
    pwd = /root/ICE/CaaSP_node_localhost
    uid/gid = 99/99
    args = java -classpath .:./lib/Ice.jar:./lib/IceGrid.jar -jar Server.jar --Ice.Config=/root/ICE/CaaSP_node_localhost/db/node/servers/SimpleServer/config/config
    Exception in thread "main" java.lang.NoClassDefFoundError: cn/com/pattek/caasp/node/Server
    Caused by: java.lang.ClassNotFoundException: cn.com.pattek.caasp.node.Server
    at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
    Could not find the main class: cn.com.pattek.caasp.node.Server. Program will exit.
    -- 10/21/13 17:28:02.150 icegridnode: Activator: detected termination of server `SimpleServer'

    when i export the jar file i set the classpath,this is content of the MENIFEST.MF:
    Manifest-Version: 1.0
    Main-Class: cn.com.pattek.caasp.node.Server
    Class-Path: ./ ./Server.jar ./lib/Ice.jar ./lib/IceGrid.jar ./lib/log4j-1.2.14.jar ./lib/jna.jar ./lib/jna-platform.jar

    Actually, i run "java -jar Server.jar" in the terminal, it works fine, so i don't think there is something wrong with the jar file.
    benoit wrote: »
    Hi,

    Can you copy/paste the full stack trace of the java.lang.NoClassDefFoundError exception?

    You need to have the Ice.jar file and the classes for your server in the Java classpath.

    Cheers,
    Benoit.
  • content of application.xml

    And here is the content of application.xml
    <icegrid>

    <application name="Simple">

    <node name="node6">
    <server id="SimpleServer" exe="java" activation="on-demand">
    <option>-jar</option>
    <option>Server.jar</option>
    <adapter name="EngineExecutor" endpoints="tcp -h localhost">
    <object identity="EngineExecutor" type="::Demo::Work" property="Identity"/>
    </adapter>

    <property name="IceMX.Metrics.Debug.GroupBy" value="id"/>
    <property name="IceMX.Metrics.Debug.Disabled" value="1"/>
    <property name="IceMX.Metrics.ByParent.GroupBy" value="parent"/>
    <property name="IceMX.Metrics.ByParent.Disabled" value="1"/>
    </server>
    </node>

    </application>

    </icegrid>


    benoit wrote: »
    Hi,

    Can you copy/paste the full stack trace of the java.lang.NoClassDefFoundError exception?

    You need to have the Ice.jar file and the classes for your server in the Java classpath.

    Cheers,
    Benoit.
  • benoit
    benoit Rennes, France
    Hi,

    It looks like you have set things up correctly (although it's not clear why the IceGrid node activator trace shows a -classpath option since you didn't set this in the descriptor... this option shouldn't be necessary anyway since you setup the Class-Path in the MANIFEST.MF file and use the -jar option).

    The message indicates that Java can't find one of your class, the Main-Class "cn.com.pattek.caasp.node.Server" class. I don't know why this occurs when running under IceGrid and not when running on the command line.

    Are you sure the IceGrid node is using the correct Server.jar file? Can you change the XML configuration to specify the full path for the Server.jar file? Note also that by default servers are ran under the user nobody when running the IceGrid node as root. You could try running the IceGrid node as another user than root or set IceGrid.Node.AllowRunningServersAsRoot to 1 to run the server as root.

    Cheers,
    Benoit.
  • Thanks, benoit, it seems to be a problem of permission, i give an administrator permission to the anonymous user and it works fine. Again, thanks for your help!