This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Groovy and the fly likes Getting java.lang.NoClassDefFoundError Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Getting java.lang.NoClassDefFoundError" Watch "Getting java.lang.NoClassDefFoundError" New topic
Author

Getting java.lang.NoClassDefFoundError

Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17
Hi

I'm getting java.lang.NoClassDefFoundError despite adding required jars and importing the class in my script.

I could decompile the class from jar. It extends java.rmi.server.UnicastRemoteObject. I'm able to instantiate and use other classes from the jar except for this one.
The chance of multiple classes with same name is also absent.
Do I need to add any other groovy-specific Jars in the classpath?

Thank you!


SCBCD(EJB2.0)
SCJP(1.4)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

When are you getting this error ? Also, can you paste the full stack trace ?


[My Blog]
All roads lead to JavaRanch
Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17
I'm getting this error when I'm calling initialize() method on it. Stack trace :

WARNING: Sanitizing stacktrace:

java.lang.NoClassDefFoundError: Could not initialize class com.hp.mx.vmm.vmtools.remote.RemoteServerBase

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:169)

at createVM.class$(createVM.groovy)

at createVM.$get$$class$com$hp$mx$vmm$vmtools$remote$RemoteServerBase(createVM.groovy)

at createVM.run(createVM.groovy:33)

at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:264)

at groovy.lang.GroovyShell.run(GroovyShell.java:513)

at groovy.lang.GroovyShell.run(GroovyShell.java:170)

at groovy.lang.GroovyShell$run$2.call(Unknown Source)

at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy:878)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)

at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:151)

at groovy.ui.Console$_runScriptImpl_closure16.doCall(Console.groovy)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:88)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)

at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:273)

at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:886)

at groovy.lang.Closure.call(Closure.java:276)

at groovy.lang.Closure.call(Closure.java:271)

at groovy.lang.Closure.run(Closure.java:354)

at java.lang.Thread.run(Thread.java:619)

java.lang.NoClassDefFoundError: Could not initialize class com.hp.mx.vmm.vmtools.remote.RemoteServerBase

at createVM.class$(createVM.groovy)

at createVM.$get$$class$com$hp$mx$vmm$vmtools$remote$RemoteServerBase(createVM.groovy)
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Can you also show the piece of code where this happens ?
Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17
When I'm calling RemoteServerBase.initialize(); in my groovy script .
----------------------------------------------------------------------------------------------------
Method signature in RemoteServerBase class
public static synchronized void initialize()
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

How did you set the classpath ?
Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17
I used "Add Jar to Classpath" option available under Script tab in GroovyConsole.
Other classes available in the same jar are accessible from the same script and I can instantiate those classes and use them.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

com.hp.mx.vmm.vmtools.remote.RemoteServerBase.

Everything there is spelled right? No typos?

GenRocket - Experts at Building Test Data
Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17

No typos.. My script is just few lines long.


Here it is in entirety:

import com.hp.mx.vmm.api.v6_0.*;
import com.hp.mx.vmm.api.v6_0cli.Cli;
import com.hp.mx.vmm.vmtools.config.Configuration;
import com.hp.mx.vmm.vmtools.grid.GridAuthentication;
import com.hp.mx.vmm.vmtools.grid.VmmRuntimeException;
import com.hp.mx.vmm.vmtools.remote.RemoteServerBase;

println "createConfig";
Cli clmode = new Cli();
def proc = "cmd /c dir".execute();

proc.waitFor()
println "return code: ${ proc.exitValue()}"
println "stderr: ${proc.err.text}"
println "stdout: ${proc.in.text}"

RemoteServerBase.initialize();

The bold faced text for Cli is working fine. All these imported packages are available in vmmapi.jar.
In dire need of HELP!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Is there an API (javadoc) where we could see this RemoteServerBase class ?
Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17
I'm not aware of any javadoc for the RemoteServerBase class. On decompiling RemoteServerBase class into java:

package com.hp.mx.vmm.vmtools.remote;

import com.hp.mx.vmm.Version;
import com.hp.mx.vmm.obfus.NoObfuscate;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.rmi.server.RMISocketFactory;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;

public class RemoteServerBase extends UnicastRemoteObject
implements NoObfuscate
{
protected static final Logger logger = Logger.getLogger(RemoteServerBase.class);

protected static List remoteObjects = new ArrayList();

protected static int port = 0;

protected static boolean init = false;
protected static RemoteSocketFactory socketFactory;
protected static RemoteMultiHomeSupport multiHomeSupport;

public static synchronized void initialize()
{
initializeInternal(!Boolean.getBoolean("com.hp.mx.vmm.vmtools.remote.nomultihome"));
}
..
.....
..............

Please let me know if it's useful.
Shraddha Pandya
Greenhorn

Joined: Sep 20, 2004
Posts: 17
initializeInternal() method uses other classes in com.hp.mx.vmm.vmtools.remote.* package..
and those have also been imported!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Sorry, I can't tell much more here... What you could try is to make a Java class which uses that class, set the JAR in your classpath, and try to execute it.
 
 
subject: Getting java.lang.NoClassDefFoundError
 
Similar Threads
jar issues
Class loading hierrarchy
some JAR problems.
Creating a JavaBeans jar file - Please Help!
java.lang.NoClassDefFoundError When trying to load a class which is dependant on a class inside jar