• 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
  • Liutauras Vilda
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Peter Rooke
  • Himai Minh
Bartenders:
  • Piet Souris
  • Mikalai Zaikin

unable to run ejb client

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi -

I am using JBoss 3.2.6. I was able to deploy the ejb jar file but I am unable to run the ejb client. I am running it with the option
C:\Test\>java -cp C:\Sun\AppServer\lib\j2ee.jar;.; TellerClient

It is giving the following error. Kindly let me know if I am missing something.

javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.
lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
 
Ranch Hand
Posts: 330
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you're using remote ejb, make sure that jboss-client or jbossall-client is also included in your jar path
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks so much for your reply Dennis ! But this time I get a ejb not bound exception. JBoss did not throw any exception when I have deployed.

I have included the jar file in the classpath but still gives exceptions.

This is how I am compiling -
C:\Test>java -cp C:\Sun\AppServer\lib\j2ee.jar;.;C:\jboss-3.2.6\client\jnp-client.jar;C:\jboss-3.2.6\client\jboss-common-client.jar;C:\jboss-3.2.6\client\jbossall-client.jar; TellerClient

javax.naming.NameNotFoundException: ejb not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:490)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:498)
at org.jnp.server.NamingServer.getObject(NamingServer.java:504)
at org.jnp.server.NamingServer.lookup(NamingServer.java:248)
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i am bak...

i know wats the problem with your program .. it cant find the ejb in the JBoss ejb container.

first thing find the exact JNDI name of your bean.
Object obj = ctx.lookup("SocketEJB");
here my beans jndi name is SocketEJB
you can find that in the ejb-jar.xml file and also in
jmx console view
second thing give that in the program ...

i think that will work..

regards
Narendran
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Naren -

Thanks for helping me.

This is where I am not clear.

1. In the lookup method, should I give the bean name (which is 'TellerBean') or should I give the jndi name ?

2. If it is jndi-name, since I am using sql server, it will be MSSQLDS. But I have seen the path in many many examples as either java:/comp/env or just java:/
What are those?

Thanks a ton for attempting to reply to my post. I am just learning by looking up examples and writing them. Sorry if I am asking dumb questions.

Thanks!
priya
[ November 03, 2004: Message edited by: Hari priya ]
 
Narendran Nair
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI

I am adding my program extracts with this mail

the ejb-jar.xml file for the session bean

<ejb-jar>
<description>Simple Socket Communication EJB</description>
<display-name>MySocket</display-name>
<enterprise-beans>
<session>
<ejb-name>SocketEJB</ejb-name>
<home>adapter.SessionHome</home>
<remote>adapter.SessionRemote</remote>
<ejb-class>adapter.SessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

the jboss.xml file
<jboss>
<enterprise-beans>
<session>
<ejb-name>SocketEJB</ejb-name>
<jndi-name>SocketEJB</jndi-name>
</session>
</enterprise-beans>
</jboss>

the client program

public class SocketClient {
public static Hashtable env = new Hashtable();
static SessionRemote remote ;
public SocketClient() {
env.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
env.put(Context.PROVIDER_URL,"localhost:1099");
connect();
}
public void connect(){
Context ctx = null;
Object obj = null;
try {
ctx = new InitialContext(env);
obj = ctx.lookup("SocketEJB");
SessionHome sessionHome = (SessionHome) PortableRemoteObject.narrow(obj,SessionHome.class);
remote = sessionHome.create();
System.out.println("Created ");
remote.connect();
} catch (NamingException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
} catch (CreateException e) {
e.printStackTrace();
}


}
public static void main(String args[]){
new SocketClient();
}
}

hope u know the home, bean and remote java file

if u look in the xml files mentioned above u will see the jndi name, that same name is used in the client program in the ctx.lookup
i wrote this this session bean to find a embedded device located in the network.. using socket communication

if u want i will send the whole thing as a attachment ...



regads
Narendran
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Naren -

Thanks again ! I saw that I used right jndi name in my client and could get the example working.

I have few questions which have been bothering me for quite some time. I will be immensely greatful if you can take time to answer them.

1. Can I give any name as JNDI name as long as I am refering to the correct one in the client?

2. Is it necessary to have all the entity bean, the home and remote interfaces on the client side for the client to execute?

3. How will the ejb know to create rows in the database table just because I have sent some parameters in the create statement? How will it know in which table it should create?

4. I see that you have only ejb-jar.xml and jboss.xml file while I have another extra one jboss-cmp.xml (which contains the table name I am referring to in the database. Still, where am I aksing it to create rows?)

5. Most importantly as I will be having to do a lot of this, if I have just to retrieve rows from the database, how will I achieve that as I dont see any sql statements.

6. Also, if I have different *-ds.xml files in the deploy directory, how will JBoss know which one to choose? Or is it limited to one -ds.xml file at a time?



Thanks for all the time you have taken again. It is really good to have a forum like java ranch where beginners like me can have some direction.

Best Regards,
Priya

PS: This is the jbosscmp-jdbc.xml that I have.

 
Narendran Nair
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

first of all I am using JBoss4 . I started to learn J2EE and use JBoss just after release of JBoss4. so it means i started few weeks or month before u started studying.

any thing mentioned below can be wrong since i am not a very big expert in this ... i am just like u ... Learning by my self


1. Can I give any name as JNDI name as long as I am refering to the correct one in the client?

u can give any name as JNDI name provided that u give the same name while looking up on the client make sure that u cross check with the JMX Console

2. Is it necessary to have all the entity bean, the home and remote interfaces on the client side for the client to execute?

just put the beans jar file in the classpath while running the client. i am doing that and few other JBoss Client jar file like
commons-discovery.jar,commons-logging.jar,concurrent.jar,jboss-client.jar,jboss-deployment.jar,
jboss-j2ee.jar,jbossall-client.jar,jbossha-client.jar,,jbossmq-client.jar,jbosssx-client.jar,jnp-client.jar,log4j.jar


3. How will the ejb know to create rows in the database table just because I have sent some parameters in the create statement? How will it know in which table it should create?

u must write in the java file that extends the SessionBean to make the database calls to do the db operations. I asume u are refering the the point where values are inserted in to the database

4. I see that you have only ejb-jar.xml and jboss.xml file while I have another extra one jboss-cmp.xml (which contains the table name I am referring to in the database. Still, where am I aksing it to create rows?)

i dont userstand this question, i am working with session beans not with entity beans

5. Most importantly as I will be having to do a lot of this, if I have just to retrieve rows from the database, how will I achieve that as I dont see any sql statements.

i wrote the client file in such a way that, the client calls a method in the bean that accepts the few parameters and the bean does all the db operation both insert, select and update.

6. Also, if I have different *-ds.xml files in the deploy directory, how will JBoss know which one to choose? Or is it limited to one -ds.xml file at a time?

in my server configuration i have the hypersonics-ds.xml file and also the oracle file.. any file put to the deploy directory is handled by the Jboss . just for example when jboss is running delete the mail-service.xml file from the deply directory and watch the console there will be some messages read it

regards
Narendran

narendran_js@hotmail.com
wm_destroyer@yahoo.com


PS: if anyone is not agreeing with me please post the correct reply
 
Hari priya
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much Naren!! It was really nice of you for taking time to reply to all my questions. I am now feeling more confident about working with JBoss and ejb.

Thanks again. I will keep working ....

Regards,
Priya
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
Today I had same problem with my client application. Make sure that your
environment doesn't contain j2ee.jar from J2EE App server.In order to use my client I have added following libs:jboss-common-client.jar, jnp-client.jar, jboss-j2ee.jar, jboss-client.jar.Since my application start to work.
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic