• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Unable to Access Stateles Session bean from Client

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am pretty new to EJB TEchnology. I am trying to create a simple stateless Session bean and trying to access through a Client program. I Am using BEA Weblogic Server 8.1.

This is my ejb-jar.xml


<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems,
Inc.//DTD Enterprise JavaBeans 2.0//EN"
"http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">

<ejb-jar>
<description></description>
<enterprise-beans>
<session>
<display-name>Converter</display-name>
<ejb-name>Converter</ejb-name>
<home>bean.ConverterHome</home>
<remote>bean.Converter</remote>
<ejb-class>bean.ConverterBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

And this is my weblogic-ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>

<!--
** This file was automatically generated by EJBGen 9.0
** Build: 20040513-1205
-->
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>Converter</ejb-name>
<jndi-name>Converter</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>



My Client program is somehting like this :-
import bean.ConverterHome;
import bean.Converter;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
public class ConverterClient
{
public static void main(String args[]) throws Exception
{
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
prop.put(Context.PROVIDER_URL,"t3://localhost:7001");

Context initialContext = new InitialContext(prop);

ConverterHome home = (ConverterHome) initialContext.lookup("java:comp/env/Converter");
Converter currencyConverter = home.create();
System.out.println(currencyConverter.displayMessage());
}

}

However i keep on getting this expcetion
Exception in thread "main" javax.naming.NameNotFoundException: While trying to lookup 'java:comp.env/Converter' didn't find subcontext 'java:comp'. Resolved ''
[Root exception is javax.naming.NameNotFoundException: While trying to lookup 'j
ava:comp.env/Converter' didn't find subcontext 'java:comp'. Resolved '']; remain
ing name 'java:comp/env/Converter'


Any Suggesiton would be welcomed. Thanking in advance,

Regards,
 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Go to the weblogic administration console and check if your bean is deployed and under what JNDI path.

The URL for the console should look like this.

http://hostname: port/console
[ January 29, 2006: Message edited by: Balazs Borbely ]
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you'll find that java:comp/env as a JNDI prefix is only relevant for code inside the container (ejb or web app), not remote clients. Doesn't matter if you are using a local interface or a remote interface, it is determined by where the client is.
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The home interface is bound into the global JNDI tree. So, you'll need this lookup.
 
Rohit Malhotra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

When i goto the Weblogic console, under the deployments i am unable to see my Bean.
My Folder structure is something like this

FIRSTEJB
|-META-INF
ejb-jar.xml
weblogic-ejb-jar.xml
CLASSES
bean
Converter.class
ConverterBean.class
ConverterHome.class

And i have made the .ear of the folder and deployed it inot the Autodeploy folder. Still i am unable to see the Bean. Do i need to put some additonal file? Please help me out.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>And i have made the .ear of the folder and deployed it inot the Autodeploy >folder.

1) ear file? I would think you need a jar file.
2) what does the WLS log say? When you copy something to the autodeploy folder, WLS tries to deploy it and will tell you if something goes wrong.
 
Rohit Malhotra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.. sorry for my mistake.

Yes i have deployed the .jar in the AutoDeploy Folder. There is no message posted on the Weblogic. So i guess the deployment should have been fine.
If the deployment isnt fine then is ther anything else that needs to be added here?

Thanking in advance,
 
Maarten de Heus
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rohit,

WLS will put something in the log when it performs a deploy. When the deploy goes fine it will say something like; deployed Converter. When the deploy goes bad it will write an error messages.

When the log doesn't say anything, probably nothing has hapened. Make sure the autodeploy facility is on and your not running in production mode.

An other solution is to deploy the bean via the console; open de deployments section en then the beans section. Click on configure new EJB. Then select configure new EJB. Select your converter.jar and deploy it.

good luck !
 
Rohit Malhotra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am now trying to deploy the same Bean through Admin Console. However i keep on getting the same error : Unable to load a class specified in your ejb-jar.xml: bean.ConverterBean

Even though the class is very much present in my .jar file Please help me out.

Thanking in advance,
 
Maarten de Heus
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From the description of your jar file I understand that you have a CLASSES folder containing a subfolder bean containing the classes. Is that correct?

You don't need the CLASSES folder (that's for wars).

greetz,
Maarten
 
Rohit Malhotra
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks a lot.. for your patience. Finally i was able to deploy and Access my First EJB .
 
And then we all jump out and yell "surprise! we got you this tiny ad!"
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic