aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes java.lang.No Class Def Found Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "java.lang.No Class Def Found Error" Watch "java.lang.No Class Def Found Error" New topic
Author

java.lang.No Class Def Found Error

Chapa Gurmukhi
Greenhorn

Joined: Nov 24, 2004
Posts: 10
I am just writing a simple session bean. I have successfuly deployed the bean
the directory structure is C:\asheesh\classes\com\bizwise\ejb. under This I have kept all my java files including client

my client code is
import javax.naming.*;
import javax.rmi.PortableRemoteObject;
import java.util.Properties;
import com.bizwise.ejb.*;
//import com.bizwise.ejb.Adder;
//import com.bizwise.ejb.AdderHome;

public class BeanClient {

public static void main(String[] args) {
// preparing properties for constructing an InitialContext object
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
properties.put(Context.PROVIDER_URL, "localhost:1099");

try {
// Get an initial context
InitialContext jndiContext = new InitialContext(properties);
System.out.println("Got context");

// Get a reference to the Bean
Object ref = jndiContext.lookup("Adder");
System.out.println("Got reference");

// Get a reference from this to the Bean's Home interface
AdderHome home = (AdderHome)
PortableRemoteObject.narrow (ref, AdderHome.class);

// Create an Adder object from the Home interface
Adder adder = home.create();
System.out.println ("2 + 5 = " + adder.add(2, 5));
}
catch(Exception e) {
System.out.println(e.toString());
}
}
}

Please help me I m getting the below error

C:\asheesh\classes>java com/bizwise/ejb/BeanClient
Exception in thread "main" java.lang.NoClassDefFoundError: com/bizwise/ejb/BeanC
lient (wrong name: BeanClient)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

Please help me
prem karun gopal
Greenhorn

Joined: Dec 03, 2003
Posts: 24
Hi,

Problem is with the classpath.Edit you classpath and append a . to the classpath.eg:
set classpath=%CLASSPATH%;.;

Hope this will solve your problem


bye


Prem Kumar.k<br />Email :write2premk@yahoo.com
prem karun gopal
Greenhorn

Joined: Dec 03, 2003
Posts: 24
Hey also why dont you put every thing in a package
and set the classpath to the starting directory
eg: If your Directory structure is D:\java\com\ejb
then give D:\java to the classpath.

Chapa Gurmukhi
Greenhorn

Joined: Nov 24, 2004
Posts: 10
Dear Prem,
Thanks a lot for your help. I am copying my classpath to you. Please have a look and tell me. I really want to see my ejb working

.;
C:\Sun\AppServer\jdk\lib\tools.jar;
C:\ProgramFiles\EditPlus;
C:\javaexam\javaprac;C:\asheesh\Titan-JBoss-3.2-12d\workbook\ant;
%PATH%;
C:\eclipse\workspace\IBE\src\server;
C:\eclipse\workspace\IBE\src\shared;
C:\Sun\AppServer\lib\j2ee.jar;
c:\IBE;C:\projects\jboss-tutorial;
C:\Sun\AppServer\lib\j2ee.jar;
C:\jboss-4.0.0\client\log4.jar;
C:\jboss-4.0.0\client\jboss-common-client.jar;
C:\jboss-4.0.0\client\jboss-system-client.jar;
C:\jboss-4.0.0\client\jnp-client.jar;
C:\jboss-4.0.0\client\jboss-client.jar;
C:\jboss-4.0.0\client\jbosssx-client.jar;
C:\projects\jboss-tutorial\HelloWorld.jar;
C:\jboss-4.0.0\server\default\deploy;
C:\jboss-4.0.0\server\default\lib\jboss-j2ee.jar;
C:\jboss-4.0.0\client;
C:\projects\jboss-tutorial;
C:\apache-ant-1.6.2\lib\ant.jar;
C:\asheesh\classes

This is all possible classpath I can think of

My java and class files are in C:\asheesh\classes\com\bizwise\ejb

I am calling my BeanClient class from classes directory using
java com/bizwise/ejb/BeanClient

Pleased help me. I know this is a problem of classpath only. Please help me
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
hi
Can u check the jar file the deploy tool created... and check if it has home component interfaces and the stubs???
Balaji Anand
Ranch Hand

Joined: Nov 03, 2004
Posts: 146
basically your jar file shd have something like these....

headfirst/_AdviceComponent_Stub.class
headfirst/_AdviceHome_Stub.class
headfirst/AdviceBean.class
headfirst/AdviceComponent.class
headfirst/AdviceHome.class
META-INF/sun-j2ee-ri.project
ejb-jar-ic.jar
.com.sun.deployment.backend.lock
META-INF/application.xml
META-INF/sun-application.xml
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.lang.No Class Def Found Error
 
Similar Threads
servlet calling ejb in RI server
How to call ejb from jsp
How to Deploy EJB in JBoss-2.4.3
what is wrong with this EJB
Problem Calling EJB from JSP