• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error while invoking ClientApplication of a EJB  RSS feed

 
sameer barale
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!!

I m deploying my Stateless session bean on JBoss3.0.8. I m trying very simple example of Hello World. My Project Directory Structure is as Follows:

src/
|__client/
| |___examples/
| |___client java files(HelloClient.java)
|__server/
| |___examples/
| |___server (bean) java files(HelloBean.java)
| |___META-INF
| |___ejb-jar.xml , jboss.xml
|__shared
| |___examples/
| |___remote and home java files(Hello.java(Remote),HelloHome.java)
|
assemble/
|___client and server jars (helloclient.jar,helloserver.jar)
|
target/
|___client/
| |___examples/
| |___client,remote,home java classes(HelloClient.class)
| |___jndi.properties **
|___server/
|___examples/
|___server (bean), remote and home java classes
(Hello.class,HelloBean.class,HelloHome.class)
|___META-INF/
|___ejb-jar.xml


*****************************
Client program
**************************
package examples;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;
public class HelloClient
{
public static void main(String [] args) throws Exception
{
Properties props = System.getProperties();

Context ctx = new InitialContext(props);
Object obj = ctx.lookup("HelloHome");

HelloHome home = (HelloHome)
javax.rmi.PortableRemoteObject.narrow(obj, HelloHome.class);

Hello hello = home.create();
System.out.println(hello.hello());
hello.remove();
}
}

******************
ejb-jar.xml is:
******************
<ejb-jar>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<home>examples.HelloHome</home>
<remote>examples.Hello</remote>
<ejb-class>examples.HelloBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

***************
jboss.xml is
***************
<jboss>
<enterprise-beans>
<session>
<ejb-name>Hello</ejb-name>
<jndi-name>HelloHome</jndi-name>
</session>
</eneterprise-baens>

<resource-manager>
</resource-manager>

</jboss>

********************
jndi.properties is
********************
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.provider.url=jnp://localhost:1099
***************************

I compile client and server src files with:

javac -classpath %LIBDIR%\jboss-j2ee.jar -d
target\client src\client\com\examples\*.java
src\shared\examples\*.java

javac -classpath %LIBDIR%\jboss-j2ee.jar -d
target\server src\server\com\examples\*.java
src\shared\examples\*.java

*************************************

I execute the following command from my c:\ejb_example\target\client directory:
jar cvf ..\..\assemble\helloclient.jar .

*************************************

I execute the next command from my c:\ejb_example\target\server directory:
jar cvf ..\..\assemble\helloserver.jar .

**************************************

Now, I put helloserver.jar in %JBOSS_HOME%\server\default\deploy directory
and start the server.
**************************************
then, I wish to run the client:
I Create a LIBDIR environment variable and set it to the client directory under JBOSS_HOME (for instance, %JBOSS_HOME%\client).

From the command prompt (all as one line):

java -classpath helloclient.jar;%LIBDIR%\jnp-client.jar;%LIBDIR%\jboss-common-client.jar;
%LIBDIR%\jboss-j2ee.jar;%LIBDIR%\jboss-net-client.jar;%LIBDIR%\jbossall-client.jar;;%LIBDIR%\jnet.jar
com.examples.HelloClient

I set the following classpath:
C:\EJBPractice\src\assemble>set classpath=%classpath%;C:\EJBPractice\src\target\client;

and try to run the client
C:\EJBPractice\src\assemble>java -classpath helloclient.jar;%LIBDIR%\jbossall-client.jar;%LIBDIR%\jboss-client.jar;%LIBDIR%\jboss-common-client.jar;%LIBDIR%\jboss-j2ee.jar;%LIBDIR%\jboss-net-client.jar;%LIBDIR%\jnp-client.jar;%LIBDIR%\jnet.jar examples.HelloClient

But i got following Error:

Exception in thread "main" java.lang.NoClassDefFoundError: examples/HelloClient

well! is this aerror with classpath? and Is everithing ok with jndi and procedures i describe above.
Please help me if u can... )
--sameer
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!