[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

JSP page interact with an EJB session bean

Posted on 2006-11-30
5
Medium Priority
?
1,045 Views
Last Modified: 2010-08-05
Please help...
why it does not work
============================================================================



<%@ page import="javax.naming.*, javax.rmi.PortableRemoteObject, com.u8.servicerequest.SrTypeProcessorLocal, com.fujitsu.au.servicerequest.SrTypeProcessorLocalHome, com.fujitsu.au.servicerequest.util.SrTypeModel" %>

<%!
 //declare a "global" reference to an instance of the home interface of the session bean
 SrTypeProcessorLocal srTypeHome=null;

 public void jspInit() throws ServletException {
   //obtain an instance of the home interface
   try {
     Context ctx = new InitialContext();
     Object ref = ctx.lookup("java:comp/env/ejb/SrTypeProcessorBean");
       srTypeHome = (SrTypeProcessorLocal)PortableRemoteObject.narrow(ref,SrTypeProcessorLocal.class);
   } catch (CreateException e) {
         e.printStackTrace();
         throw new ServletException(e.toString());
   } catch (NamingException e) {
         e.printStackTrace();
         throw new ServletException(e.toString());
   }
 }
%>

<%
 //instantiate the session bean
  SrTypeProcessorLocal srType = srTypeHome.create();
 //invoke the remote methods
%>
0
Comment
Question by:LeanMoreTryMore
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 29

Expert Comment

by:bloodredsun
ID: 18053167
Please post the stackTrace or error that is printed.
0
 
LVL 14

Expert Comment

by:boonleng
ID: 18053168
Can you post the error log.
0
 
LVL 23

Accepted Solution

by:
rama_krishna580 earned 1500 total points
ID: 18056344
Hi,

look at the sample code here...i hope it might help you
http://www.jguru.com/faq/view.jsp?EID=5314
http://www.jguru.com/faq/view.jsp?EID=917

R.K
0
 

Author Comment

by:LeanMoreTryMore
ID: 18065075
Im using the MVC design pattern.
The javabean is used to retrieves the home interface of the session bean by performing a lookup operating in the naming system, and which invokes the bean’s business methods. and then via the session to invoke the entity bean to retreive the data from the underlying database

See below javabean
=============

public class SrTypeProxy {
   private SrTypeProcessorLocal srType;

   public SrTypeProxy() throws Exception {
          init();
   }
   public void init() throws Exception {
   
     // Lookup the enterprise bean
     try {
       InitialContext ctx = new InitialContext();
         Object ob = ctx.lookup("java:comp/env/ejb/SrTypeProcessorBean");
         SrTypeProcessorLocalHome home = ( SrTypeProcessorLocalHome ) PortableRemoteObject.narrow( ob, SrTypeProcessorLocalHome.class );
         //Initialize the enterprise bean
         srType = home.create();
     } catch ( Exception e ) {
         throw new Exception("Error instantiating SrTypeProcessorBean EJB" + e.toString());
     }
   }  
   
   public SrTypeModel[] getSrType()throws Exception {
         
         SrTypeModel[] srTypeModel;
    try {
            srTypeModel = srType.viewSrType();      
    }catch (Exception re){
          throw new Exception("Fail to retrive service types");
    }
    return srTypeModel;
   }
}

===========================================================================
The error is: java.lang.InstantiationException: ID018236: Cannot instantiate bean. java.lang.ClassNotFoundException: class com.fujitsu.au.servicerequest.beans.SrTypeProxy : java.lang.Exception: Error instantiating SrTypeProcessorBean EJBcom.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Path to object does not exist at java:comp, the whole lookup name is java:comp/env/ejb/SrTypeProcessorBean.

0
 
LVL 8

Expert Comment

by:mhunts
ID: 18072508
You need to include the jar file that contains SrTypeProxy in your classpath.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An overview of cyber security, cyber crime, and personal protection against hackers. Includes a brief summary of the Equifax breach and why everyone should be aware of it. Other subjects include: how cyber security has failed to advance with technol…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question