Please Please help me in jboss
asheeshshrivastav Nov 25, 2004 10:54 PMGuys, I am using jboss for the very first time so please help me
My project structure is C:\projects\jboss-tutorial\com\mastertech\sample
I have kept all my java files there including my client file which looks up the bean
jboss.xml
<?xml version="1.0" encoding="UTF-8" ?>
-
- <enterprise-beans>
-
<ejb-name>Hello</ejb-name>
<jndi-name>test/Hello</jndi-name>
</enterprise-beans>
ejb-jar.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ejb-jar PUBLIC
"-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/dtd/ejb-jar_2_0.dtd">
<ejb-jar>
JBoss Hello World Application
<display-name>Hello World EJB</display-name>
<enterprise-beans>
<ejb-name>Hello</ejb-name>
com.mastertech.sample.HelloWorldHome
com.mastertech.sample.HelloWorld
<ejb-class>com.mastertech.sample.HelloWorldBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</enterprise-beans>
</ejb-jar>
Client file
package com.mastertech.sample;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Hashtable;
import java.util.*;
public class HelloWorldClient{
public static void main( String [] args ){
try{
Properties props = System.getProperties();
Context ctx = new InitialContext(props);
Object obj = ctx.lookup( "test/Hello" );
HelloWorldHome home = (HelloWorldHome)javax.rmi.PortableRemoteObject.narrow(obj, HelloWorldHome.class );
HelloWorld helloWorld = home.create();
System.out.println( helloWorld.hello());
helloWorld.remove();
}
catch ( Exception e ){
e.printStackTrace();
System.out.println( "Exception: " + e.getMessage() );
}
}
}
I am able to deploy me bean properly but could not get the cleint java file running. I am running form C:\projects\jboss-tutorial\com\mastertech\sample folder
The error I am getting is
C:\projects\jboss-tutorial\com\mastertech\sample>java WorldClient
Exception in thread "main" java.lang.NoClassDefFoundError: WorldClient
C:\projects\jboss-tutorial\com\mastertech\sample>java HelloWorldClient
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldClient (wro
ng name: com/mastertech/sample/HelloWorldClient)
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)
To my knowledge it is a problem of the look up of the bean or the classpath. My classpath for jboss is as follows
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\com\mastertech\sample
I am using jBoss 4. please please help me