• Post Reply Bookmark Topic Watch Topic
  • New Topic

Deploy EJB in Websphere4.0

 
Doris Deng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I develop a EJB application in Jbuilder4.0, and it works right in IAS. When I deploy it in Websphere4.0, the session bean work right, but entity bean doesn't work.
when executed the following in JSP file:
InitialContext ctx = new InitialContext();
Object Ref = ctx.lookup("djf/Account");
I get the error message, it said djf/Account couldn't be finded.
if I change the JNDI name "djf/Account" to ejb-ref "java:comp/env/test/Account", I get another error message,
"Exception occurred while attempting to get an instance of the object for the specified reference object."
Who can help me?

[This message has been edited by Doris Deng (edited September 18, 2001).]
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Doris,
It sounds to me like you didn't deploy your EJB the way you think you did. Could you walk us through the steps you took to deploy your EAR file?

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, a useful tool is the namespace browser for WebSphere available here:
http://www-4.ibm.com/software/webservers/appserv/tools.html
It can help you find out what names everything is deployed under.
 
Doris Deng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I walk through the steps I developed and deployed the ear file.
Step 1.I develop a test.jar file in Jbuilder4.0, which include an entity bean TblAccount(CMP2.0) and a session bean TellerBean.
TblAccount JNDI name : djf/Account
TellerBean JNDI name : TellerHome
Step 2.I can run the TblAccount and the TellerBean rightly at JBuilder4.0 using Inprise Application Server.
Step 3.I use Application Assembly Tools to assemble an ear file.
I create a new application, and import the test.jar.I do nothing to the test.jar (I have a problem here. if I give a jndi name to the entity bean TblAccount, the primary key field would change from Accountid to compound key automaticly. Why? Is it right?)
Step 4.New a web module step7.war which includes two simple jsp files.
Step 5.New two EJB References in step7.war :step7/Teller & step7/TblAccountHome,I set the Home,Remote and Type of each ejb reference, but I don't set the bindings.(Because I didn't give the test.jar's EJB JNDI name in step3.)
Step 6.Save the file as Step7.ear.
Step 7.Genetate code for deployment.
Step 8.Launch the administrative console,deploy the ear file.
When go to the step Binding Enterprise Beans to JNDI names,the default jndi name is "test/EJSCMPTblAccountHomeBean" and "test/EJSStatelessTellerHomeBean", I change them to "djf/Account" and "TellerHome".
when mapping resource references to JNDI names, I set the JNDI name to "step7";
when mapping ejb references to enterprise beans ,I set as the following:
Step7.war step7/Teller : djf/Account
Step7.war Step7/TblAccountHome TellerHome
When Mapping ejb jar default data source references to jndi names,I set test.jar's Default Datasource JNDI Name to Step7 ;
When Mapping CMP data source references to JNDI name, I set test.jar:TblAccount's JNDI name Step7;
Save Configuration, finish the deployment.
Step 9. After restart the application server,I run the two jsp files.
the test1.jsp which use the session bean Teller works right, but the test2.jsp which use the entity bean TblAccount doesn't work.
test1.jsp:
-----------------------------------
Context ctx = new InitialContext();
Object Ref = ctx.lookup("TellerHome");
TellerHome Home = (TellerHome)PortableRemoteObject.narrow(Ref, TellerHome.class);
Teller teller=Home.create();
int t=teller.getTellerNo();
out.println("You use teller no:"+t);
-----------------------------------
test2.jsp
----------------------------------
Context ctx = new InitialContext();
Object Ref = ctx.lookup("djf/Account")
TblAccountHome Home = (TblAccountHome)PortableRemoteObject.narrow(Ref, TblAccountHome.class);
out.println("You are successful");
----------------------------------
when run the test2.jsp, I get the error message:"Error 500: Server caught unhandled exception from servlet [JSP 1.1 Processor]: djf/Account"
if I change the statement to
----------------------------------
Object Ref = ctx.lookup("java:comp/env/step7/TblAccountHome");
-----------------------------------
It still doesn't work, I get the error message:"Error 500: Server caught unhandled exception from servlet [JSP 1.1 Processor]: Exception occurred while attempting to get an instance of the object for the specified reference object. "

[This message has been edited by Doris Deng (edited September 19, 2001).]
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, one problem is that WebSphere 4.0 doesn't support EJB 2.0. You said it's a 2.0 CMP bean. That's probably the problem -- not only is the code different, but the deployment descriptors are different too. Try building a 1.1 CMP bean instead.
Kyle Brown
------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Doris Deng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,
Thank you very much. I will try it again with CMP1.1.
 
Doris Deng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kyle,
I am very sad. The CMP1.1 still doesn't work. I get the same error message. What should I do?
[This message has been edited by Doris Deng (edited September 19, 2001).]
 
Doris Deng
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps I installed WAS4.0 incorrectly.
I install the WAS and IAS on the same computer even though at some time I only start one application server.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Doris Deng:
Perhaps I installed WAS4.0 incorrectly.
I install the WAS and IAS on the same computer even though at some time I only start one application server.

Hmmm... That could be it -- WAS is a bit sensitive to JVM issues, even though it's theoretically not supposed to be. Try it on a different machine without IAS and see if you have the same problem.

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing.
Make sure your WAS server is configured to use Application Module visibility (look on the Application Server tab in the web console). If you are using Module Visibility the servlet and/or JSP might not be finding your EJB classes.

------------------
Kyle Brown,
Author of Enterprise Java (tm) Programming with IBM Websphere
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!