| Author |
problem in the stand alone client
|
naresh govindaswmay
Ranch Hand
Joined: Aug 15, 2007
Posts: 90
|
|
hi, I have deployed my EJB jar into the JBOSS application server.Its deployed with out error.while accesing the jar into the client program i am getting NoInitialContextFactory exception please help out of this I have included all the xml file and client code. ejb-jar.xml file <?xml version="1.0"?> <!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> <enterprise-beans> <session> <display-name>AdviceBean</display-name> <ejb-name>AdviceBean</ejb-name> <!--<home>com.ejb.example.AdviceHome</home> <remote>com.ejb.example.Advice</remote> <ejb-home>com.ejb.example.AdviceHome</ejb-home> <ejb-home>com.ejb.example.AdviceHome</ejb-home> --> <home>com.ejb.example.AdviceHome</home> <remote>com.ejb.example.Advice</remote> <ejb-class>com.ejb.example.AdviceBean</ejb-class> <session-type>Stateless</session-type> <transaction-type>Container</transaction-type> </session> </enterprise-beans> <ejb-client-jar>Advice.jar</ejb-client-jar> </ejb-jar> 2.jboss.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS//EN" "http://www.jboss.org/j2ee/dtd/jboss.dtd"> <jboss> <enterprise-beans> <session> <ejb-name>AdviceBean</ejb-name> <jndi-name>AdviceBean</jndi-name> <local-jndi-name>AdviceBean</local-jndi-name> </session> </enterprise-beans> </jboss> 3.client Program package com.ejb.example; import java.rmi.*; import javax.ejb.*; import javax.naming.*; import javax.rmi.*; import java.util.Properties; public class AdviceClient { public static void main(String str[]) { new AdviceClient().go(); } public void go() { try { Context ctx=new InitialContext(); Properties properties=new Properties(); //properties.put(""); //properties.put(""); //properties prop= new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory"); properties.put(Context.PROVIDER_URL,"org.jnp.interfaces"); System.out.println("after the provider URL "); //InitialContext ctx = new InitialContext(prop); Object o=ctx.lookup("AdviceBean"); System.out.println("after the Object is looked up"); AdviceHome home=(AdviceHome) PortableRemoteObject.narrow(o,AdviceHome.class); Advice advice=home.create(); System.out.println("this String from Ejb-->"+advice.getAdvice()); } catch (Exception E) { System.out.println("Exception -->"+E.getClass()); } } } this is my client program structure please help m eout of this. cheers Naresh.
|
Thanks and Regards<br />Naresh govindaswamy
|
 |
naresh govindaswmay
Ranch Hand
Joined: Aug 15, 2007
Posts: 90
|
|
Thsi the error message i am getting now in the consoleE:\EJB\ejb practice>javac -d . *.java E:\EJB\ejb practice>java com/ejb/example/AdviceClient Exception in thread "main" java.lang.NoClassDefFoundError: com/ejb/example/Advic eClient E:\EJB\ejb practice>set classpath=%classpath%;C:\Program Files\Java\jdk1.5.0_06\ lib; E:\EJB\ejb practice>java com/ejb/example/AdviceClient Exception -->class javax.naming.NoInitialContextException this is the error message i am getting now. cheers naresh
|
 |
Roger Chung-Wee
Ranch Hand
Joined: Sep 29, 2002
Posts: 1683
|
|
|
You need to add AdviceClient.class to your classpath.
|
SCJP 1.4, SCWCD 1.3, SCBCD 1.3
|
 |
 |
|
|
subject: problem in the stand alone client
|
|
|