Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError  RSS feed

 
Monty Padre
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey ya'll, this is my first post here.

I'm working on an exercise from O'Reily's Learning Java concerning web services implemented with JAX-WS. It's my understanding that JAX-WS ships with the Java 7 JDK package. It's also my understanding that classes implementing annotation and importing the jws API deploy from their own mini-server, without the need for, say, Tomcat or GlassFish. I have the class packaged, per the instructions in the exercise, in a directory called learningjava, in a subdirectory called service. This path lives in my main user directory. I attempt to run the compiled class from the command line thus:

C:\Users\montypadre\learningjava\service>java Echo

This is the response I get:

Exception in thread "main" java.lang.NoClassDefFoundError: Echo (wrong name: learningjava/service/Echo)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.lang.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

This is my classpath, set in the system environment variables:
%JAVA_HOME%\bin;.;%JAVA_HOME%\jre\lib\rt.jar;.;%JAVA_HOME%\lib\tools.jar;.;%CATALINA_HOME%\lib\servlet-api.jar;.;%ANT_HOME%\bin\ant.bat;.

%JAVA_HOME% is C:\Program Files\Java\jdk1.7.0_51

The path, also in the system environment variables:
%JAVA_HOME%\bin;.;%ANT_HOME%/bin;


And finally, this is the code for the class itself:

package learningjava.service;

import javax.jws.*;
import javax.xml.ws.Endpoint;

@WebService()
public class Echo
{
@WebMethod()
public int echoInt( int value ) { return value; }

@WebMethod()
public String echoString( String value ) { return value; }

@WebMethod()
public MyObject echoMyObject( MyObject value ) { return value; }

public static void main( String[] args )
{
Endpoint endpoint = Endpoint.publish( "http://localhost:8080/echo",
new Echo() );
}
}

class MyObject
{
int intValue;
String stringValue;

public MyObject() { }

public MyObject( int i, String s ) {
this.intValue = i;
this.stringValue = s;
}

public int getIntValue() { return intValue; }
public void setIntValue( int intValue ) { this.intValue = intValue; }

public String getStringValue() {
return stringValue;
}
public void setStringValue( String stringValue ) {
this.stringValue = stringValue;
}
}


Any help I can get would be awesome, greatly appreciated. Thanks for ya'lls attention.
 
Surendra Kumar
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use full package name. Try 'java learningjava.service.Echo'.
 
Monty Padre
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, that helped me make some progress, but I'm getting a new error now:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\montypadre>java learningjava.service.Echo

Exception in thread "main" java.lang.IllegalAccessError: tried to access class l
earningjava.service.MyObject from class learningjava.service.jaxws.EchoMyObject$
JaxbAccessorF_arg0
at learningjava.service.jaxws.EchoMyObject$JaxbAccessorF_arg0.<init>(Fie
ldAccessor_Ref.java:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFac
tory.instanciate(OptimizedAccessorFactory.java:184)
at com.sun.xml.internal.bind.v2.runtime.reflect.opt.OptimizedAccessorFac
tory.get(OptimizedAccessorFactory.java:176)
at com.sun.xml.internal.bind.v2.runtime.reflect.Accessor$FieldReflection
.optimize(Accessor.java:266)
at com.sun.xml.internal.bind.v2.runtime.property.SingleElementNodeProper
ty.<init>(SingleElementNodeProperty.java:79)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
orAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
onstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at com.sun.xml.internal.bind.v2.runtime.property.PropertyFactory.create(
PropertyFactory.java:113)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.<init>(ClassBe
anInfoImpl.java:166)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXB
ContextImpl.java:493)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBConte
xtImpl.java:310)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBConte
xtImpl.java:125)
at com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl$JAXBContextBuild
er.build(JAXBContextImpl.java:1147)
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFact
ory.java:173)
at com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext
.java:95)
at com.sun.xml.internal.ws.developer.JAXBContextFactory$1.createJAXBCont
ext(JAXBContextFactory.java:98)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIM
odelImpl.java:151)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIM
odelImpl.java:143)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(
AbstractSEIModelImpl.java:143)
at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(Abstra
ctSEIModelImpl.java:84)
at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(Runtim
eModeler.java:234)
at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(Endpoin
tFactory.java:328)
at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(Endpoin
tFactory.java:190)
at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:
498)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndp
oint(EndpointImpl.java:246)
at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(En
dpointImpl.java:170)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(Pro
viderImpl.java:113)
at javax.xml.ws.Endpoint.publish(Endpoint.java:240)
at learningjava.service.Echo.main(Echo.java:20)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!