Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

java.lang.No Class Def Found Error

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 karun gopal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 146
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic