• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in the stand alone client

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
naresh govindaswmay
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to add AdviceClient.class to your classpath.
 
Yup, yup, yup. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic