NameNotFoundException on lookup in JSP

I'm new to EJBs. I got an extremely basic stateless session bean to work on a JSP,
now I'm trying to get an entity bean working.
I'm getting a javax.naming.NameNotFoundException on my lookup. Here's my JSP code:
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost" );
Context ctx = new InitialContext( ht );
WBaseUserLocalHome userLocalHome = (VWBaseUserLocalHome) ctx.lookup("VWBaseUser");
(yes, I've changes my weblogic port from the default port 7001 to 80)
I thought that the string that you perform the lookup on is supposed to match
the <jndi-name> in the weblogic-ejb-jar.xml, and it is.

Inline.
Brian Preston wrote:
Excellent explanation, thanks. I think I followed most of it. Your explanation
also seems to describe my problem - I'm trying to deploy this test EJB as an 'exploded'
application, but I've only built the EJB with local interfaces. I previously
thought that since the JSP and EJB were running on the same server, the calls
would be local, not remote. I didn't know about the classloader issues.
So if I want to stick with the exploded app, I need to use Remote Interfaces then?Not necessarily. You could deploy the JSP in an exploded WAR format in the same exploded EAR
that contains the exploded JAR for the EJB. This deploys the JSP and the EJB in the same
classloader hierarchy allowing by reference semantics, therefore supporting the call to a Local
Interface fromt the JSP. Or, yes, you could just change the Local Interfaces to Remote
Interfaces. Really depends on the app, other apps, how you are using it, etc.
Bill
>
I'll go ahead and try both that, and packaging everything into a WAR and EAR.
I haven't tried that yet because I'm still trying to find explanation/documentation
about how to create those and what the directory structure is supposed to be before
you jar it.
Thanks,
Brian
William Kemp <[email protected]> wrote:
The EJB 2.0 Spec defines EJB Local Interfaces. The object that implements
these is not a
java.rmi.Remote object, and therefore may only be passed by reference.
When you refer to
them, you must be in the same JVM, and in the same enterprise app, on
WebLogic. They are
available and looked up through the local JNDI tree, which is common,
or local, to all of
the components in a J2EE app. An object reference may be returned when
looked up through the
local JNDI tree because the accessor and the object have been loaded
by the same classloader
hierarchy. You may not look them up and use them from outside of the
app because that
implies pass by value, which requires a java.rmi.Remote object.
So, if you access an EJB Local Interface, you must do it from the same
JVM and the same
enterprise application. As for examples, WLS is shipped with several
EJB 2.0 CMP examples
that demonstrate the use of Local Interfaces. In your example, you need
to package the JSP
and the EJB Local Inteface in the same EAR. Here are some good links
for this:
http://edocs.bea.com/wls/docs70/programming/index.html
http://edocs.bea.com/wls/docs70/programming/classloading.html#1029830
http://edocs.bea.com/wls/docs70/ejb/cmp.html#1070133
Bill
Brian Preston wrote:
Could you explain this a little more? I'm not following you when yousay 'access
to the local interfaces is scoped at the application level.' Somecode samples
would probably help, too. I'm pretty new to JNDI and RMI. I'm tryingto understand
these underlying APIs behind EJBs.
Thanks,
Brian
William Kemp <[email protected]> wrote:
The app can be exploded. The requirement is that access to the local
interfaces is scoped
at the application level.
Bill
Brian Preston wrote:
Thanks for your reply. Does that mean there's no way to do this
with
an 'exploded'
applicationk? I.e., without using an ear file?
William Kemp <[email protected]> wrote:
Looks like you are trying to look up a local interface in the global
jndi tree. Local
interfaces are only available in the local jndi tree. The JSP and
the
entity bean,
with the local interface you are trying to lookup, must be in thesame
J2EE
application which means they must be in the same application ear
file.
Bill
Brian Preston wrote:
I'm new to EJBs. I got an extremely basic stateless session bean
to
work on a JSP,
now I'm trying to get an entity bean working.
I'm getting a javax.naming.NameNotFoundException on my lookup.
Here's
my JSP code:
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost" );
Context ctx = new InitialContext( ht );
WBaseUserLocalHome userLocalHome = (VWBaseUserLocalHome) ctx.lookup("VWBaseUser");
(yes, I've changes my weblogic port from the default port 7001
to
80)
I thought that the string that you perform the lookup on is supposedto match
the <jndi-name> in the weblogic-ejb-jar.xml, and it is.

Similar Messages

  • JNDI Lookup in JSP fails for EJB 3.0

    I am new to Java technology. I read the EJB FAQ, NetBeans docs and may forum discussions and I am still confused with the error I am having.
    Background:
    I have developed a persistance bean and related sessions beans (similar to the customer-cmp-ear application in the Java App Server samples). Now I am trying to access this bean using a JSP. After deploying the war file in the App Server and try to access the page, I get the following error.
    javax.naming.NameNotFoundException: No object bound to name java:comp/env/ConsumerSessionLocal
    After reading many articles, I understood that I dont have to prepare any descriptors, or JAR files for EJB 3.0.
    Environment Details:
    Java App Server Ver 9.0
    NetBeans 5.5
    I normally build the war files using NetBeans.
    I use App Server Admin console to deploy the web applications using the above war file.
    EJB details:
    Persistance EJB : person.java
    Session Objects
    Consumer.java (this implements ConsumerSessionLocal, ConsumerSessionRemote). This Stateless bean accesses the methods in person.java.
    ConsumerSessionLocal.java - local interface
    ConsumerSessionRemote.java - remote interface
    SearchConsumer.jsp
    This JSP page is calling the ConsumerSessionLocal using the JNDI lookup through InitialContext.
    Here is the Code snippet:
    try {
    InitialContext ic = new InitialContext();
    Object o = ic.lookup("java:comp/env/ConsumerSessionLocal");
    ConsumerSessionLocal consSession = (ConsumerSessionLocal) o;
    I am able to see the jsp page in the browser, however, after a submit action, I get the Java Naming Exception error.
    javax.naming.NameNotFoundException: No object bound for java:comp/env/ConsumerSessionLocal
    I would appreciate your help/any of your thoughts.
    Thanks in advance.
    -Ram

    I did not really solve it. Instead I used some of the tutorials that used JNDI lookup and modified those as my way forward. I did not really find out exactly what I was doing wrong.
    /Anders

  • NameNotFoundException on lookup

    I see a bunch of questions in this area, but not a solution.
    I have an applet that tries to instantiate a stateless session bean to talk back
    to the server.
    I have an ear deployment that contains a bean (jar) & a application (war). The
    bean has a jndi entry (that I can see in the admin console, I can test the ejb
    in the admin console as well), but when the applet (that is in the war), does
    a lookup, it gets a NameNotFoundException.
    ejb-jar.xml:
    <!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>
    <ejb-name>TADGenerateMapService</ejb-name>
    <home>TAD.ejbs.TADGenerateMapEJBHome</home>
    <remote>TAD.ejbs.TADGenerateMapEJBRemote</remote>
    <ejb-class>TAD.ejbs.TADGenerateMapEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    Weblogic-ejb-jar.xml:
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
    '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN'
    'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>TADGenerateMapService</ejb-name>
    <jndi-name>TAD.map.statelessSession</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    web.xml contains
    <ejb-ref>
    <ejb-ref-name>TADGenerateMapService</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>TAD.ejbs.TADGenerateMapEJBHome</home>
    <remote>TAD.ejbs.TADGenerateMapEJBRemote</remote>
    <ejb-link>TAD_EJB.jar#TADGenerateMapService</ejb-link>
    </ejb-ref>
    Lookup snippet:
    String hostName = this.getCodeBase().getHost();
    Hashtable env = new Hashtable();
    env.put(Context.PROVIDER_URL, "t3://" + hostName + ":7001");
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    try {
    context = new InitialContext(env);
    catch( Exception e ) {
    System.out.println("Caught exception " + e.toString() + " in init");
    try
    // Get Initial JNDI Context
    // Get EJB
    TADGenerateMapEJBHome mapHome = (TADGenerateMapEJBHome) context.lookup
    ("TAD.map.statelessSession");
    TADGenerateMapEJBRemote mapRemote = mapHome.create () ;
    mapNameWithPath = mapRemote.generateMap (mapProjection,
    mapType,
    mapWidth,
    mapCenterLat,
    mapCenterLon);
    catch (NamingException e)
    System.out.println ("TADMapClient.generateMap - NamingException => " +
    e) ;
    e.printStackTrace();
    Error I receive in the browser java console:
    TADMapClient.generateMap - NamingException => javax.naming.NameNotFoundException:
    remaining name: java:/comp/env/TAD.map.statelessSession
    javax.naming.NameNotFoundException: remaining name: java:/comp/env/TAD.map.statelessSession
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
         at javax.naming.InitialContext.lookup(Unknown Source)
         at TAD.common.TestApp.generateMap(TestApp.java:67)
         at TAD.common.TestApp.start(TestApp.java:45)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I think I am missing a piece.
    Thanks

    Yes. it is in the JNDI tree.
    "eran" <[email protected]> wrote:
    >
    Does the bean's JNDI name appears in the server JNDI tree?
    "James Martin" <[email protected]> wrote:
    I do have a remote and home interface. Can't use an intermediate servlet
    for this.
    "eran" <[email protected]> wrote:
    Hi,
    If you use the EJB from your applet you must make the home and remote
    interfaces
    avavilable for your applet.
    Wouldn't it be easier to use an intermediate servlet.
    Eran
    "James Martin" <[email protected]> wrote:
    I see a bunch of questions in this area, but not a solution.
    I have an applet that tries to instantiate a stateless session beanto
    talk back
    to the server.
    I have an ear deployment that contains a bean (jar) & a application(war).
    The
    bean has a jndi entry (that I can see in the admin console, I can
    test
    the ejb
    in the admin console as well), but when the applet (that is in thewar),
    does
    a lookup, it gets a NameNotFoundException.
    ejb-jar.xml:
    <!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD EnterpriseJavaBeans
    2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
    <ejb-jar>
    <enterprise-beans>
    <session>
    <ejb-name>TADGenerateMapService</ejb-name>
    <home>TAD.ejbs.TADGenerateMapEJBHome</home>
    <remote>TAD.ejbs.TADGenerateMapEJBRemote</remote>
    <ejb-class>TAD.ejbs.TADGenerateMapEJB</ejb-class>
    <session-type>Stateless</session-type>
    <transaction-type>Container</transaction-type>
    </session>
    </enterprise-beans>
    </ejb-jar>
    Weblogic-ejb-jar.xml:
    <?xml version="1.0"?>
    <!DOCTYPE weblogic-ejb-jar PUBLIC
    '-//BEA Systems, Inc.//DTD WebLogic 8.1.0 EJB//EN'
    'http://www.bea.com/servers/wls810/dtd/weblogic-ejb-jar.dtd'>
    <weblogic-ejb-jar>
    <weblogic-enterprise-bean>
    <ejb-name>TADGenerateMapService</ejb-name>
    <jndi-name>TAD.map.statelessSession</jndi-name>
    </weblogic-enterprise-bean>
    </weblogic-ejb-jar>
    web.xml contains
    <ejb-ref>
    <ejb-ref-name>TADGenerateMapService</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <home>TAD.ejbs.TADGenerateMapEJBHome</home>
    <remote>TAD.ejbs.TADGenerateMapEJBRemote</remote>
    <ejb-link>TAD_EJB.jar#TADGenerateMapService</ejb-link>
    </ejb-ref>
    Lookup snippet:
    String hostName = this.getCodeBase().getHost();
    Hashtable env = new Hashtable();
    env.put(Context.PROVIDER_URL, "t3://" + hostName + ":7001");
    env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    try {
    context = new InitialContext(env);
    catch( Exception e ) {
    System.out.println("Caught exception " + e.toString() + " in
    init");
    try
    // Get Initial JNDI Context
    // Get EJB
    TADGenerateMapEJBHome mapHome = (TADGenerateMapEJBHome)context.lookup
    ("TAD.map.statelessSession");
    TADGenerateMapEJBRemote mapRemote = mapHome.create () ;
    mapNameWithPath = mapRemote.generateMap (mapProjection,
    mapType,
    mapWidth,
    mapCenterLat,
    mapCenterLon);
    catch (NamingException e)
    System.out.println ("TADMapClient.generateMap - NamingException
    => " +
    e) ;
    e.printStackTrace();
    Error I receive in the browser java console:
    TADMapClient.generateMap - NamingException => javax.naming.NameNotFoundException:
    remaining name: java:/comp/env/TAD.map.statelessSession
    javax.naming.NameNotFoundException: remaining name: java:/comp/env/TAD.map.statelessSession
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:35)
         at weblogic.j2eeclient.SimpleContext.resolve(SimpleContext.java:39)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:57)
         at weblogic.j2eeclient.SimpleContext.lookup(SimpleContext.java:62)
         at javax.naming.InitialContext.lookup(Unknown Source)
         at TAD.common.TestApp.generateMap(TestApp.java:67)
         at TAD.common.TestApp.start(TestApp.java:45)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    I think I am missing a piece.
    Thanks

  • Problem in creating a lookup in oim.

    when i am trying to create a lookup in jsp, it is directly printing on jsp page.
    the code is:
    row.add(TableCellFactory.createText("<input type=\"text\" name=\"selectedValuesToMove" +
    objectInstanceKey +
    "maxlength=\"50\" tabindex=\"\" "+
    i +
    "\" value=\"\" readonly=\"readonly\" class=\"Fields\"><a href='' onClick='openLookupWindow(\"LookupForm.do?method=Lookup+By+API&lookupAPI=-19&property=selectedValuesToMove" +
    objectInstanceKey +
    "&columnLabelKey=global.label.managerid&htmlFormName=serviceAccountsForm&className=Thor.API.Operations.tcUserOperationsIntf&methodName=findUsersFiltered&fixedFilter=Users.Status%3AActive&columnNames=Users.User+ID%2CUsers.Last+Name%2CUsers.First+Name&selectionColumn=Users.User+ID\",\"Lookup\",\"height=500,width=500,scrollbars=yes,status=yes, resizable\");return false;'><img src='images/lookup.gif' border=0></a>  \n" +
    "                              <a href=\"#\" onClick='clearLookupField(\"selectedValuesToMove" +
    objectInstanceKey +
    "\");' >Clear</a>"));
    can any one help me.
    it is important to my project.
    Edited by: anu on Jul 22, 2011 4:32 AM
    Edited by: anu on Jul 22, 2011 4:35 AM
    Edited by: anu on Jul 22, 2011 6:36 AM

    Hi Dharmi
    Here is a quote of Dafna's post in [another thread in this forum|Re: Copy VC controls]
    CE7.1.1 will be released at September 2008 for ramp-up customers.
    There are many improvements and new capabilities in the new release of Visual Composer for CE7.1.1. Among the new features you can find:
    The missing features from Visual Composer 7.0 (Html view, portal Eventing support (EPCM), JDBC, Undo/Redo, and more..)
    Many layout & modeling improvements
    Additional ALV table functionality - export to Excel, switch to chart, configure ALV behavior at design time
    Integration of Visual Composer in Eclipse - additional entry point to the Visual Composer models from the NWDS. This integration provides the option to add a WD component (in case of missing functionality in Visual Composer), as a black box component to the Visual Composer model. Right-clicking the component will open the Web Dynpro perspective for creating/modifying the component.
    Regards,
       Shai

  • How to call the form bean value on jsp withthe help of jstl tag

    hi
    all friends
    i am working in struts & i use jstl tag in jsp. i have one problem rise is how to call the form bean value in jsp page by using jstl tag.
    i now how to retrive the value through jsp:logic
    eg. <logic:empty name="userListForm" property="users">
    NO USER FOUND
    </logic:empty>
    see * userListForm mean formbaen name.
    * users means collection object.
    so how can i write above e.g in jstl

    You use the jstl core:if or core:choose combined with the EL:
    <c:if test="${empty users.userListForm}">
    NO USERS FOUND
    </c:if>I suggest you lookup the jsp expression language (EL) using google, it's very powerful.

  • JSP - Bean - Scope Issue with ResultSet

    Hi there,
    I have a JSP page that uses a Bean to get ResultSets from a db. My methods return ResultSets, but they seem to get out of scope on the JSP page when I try to use them. I'm not sure why. I have included 2 snippets below one that works and one that doesn't. I get a java.lang.null exception when the page is run. Not sure how or why the variable seems to go out of scope? I can work around it, but I would rather find out why this is happening.
    This one fails:
    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    try{
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <%
    ResultSet roem = lookup.getOEMDropdown();
    //open db conn
    lookup.openIlprod();
    if(roem!=null){
    %>
    OEM:  
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){     
         //log to Tomcat
    %>
    This one works....why??
    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    try{
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <%
    //open db conn
    lookup.openIlprod();
    ResultSet roem = lookup.getOEMDropdown();
    if(roem!=null){
    %>
    OEM:  
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){     
         //log to Tomcat
    %>

    <%@ page errorPage="error.jsp" %>
    <%@ page import="utils.LookupBean" %>
    <%@ page import="java.sql.ResultSet" %>
    <%
    String ilprod_db_user;
    String ilprod_db_pass;
    String tedsi_prod_owner;
    String nsp_portal_owner;
    String iladmin_owner;
    String ilprod_db_host;
    String ilprod_db_port;
    String ilprod_db_service;
    try{
         //get the ilprod_db_user from the deployment descriptor
         ilprod_db_user = (String)getServletContext().getInitParameter("ilprod_db_user");
         //ensure a value is present
         if(ilprod_db_user==null||ilprod_db_user.equals("")){
         throw new ServletException("Error retrieving ilprod_db_user from deployment descriptor. - ilprod_db_user is null or an empty string");
         //get the ilprod_db_pass from the deployment descriptor
         ilprod_db_pass = (String)getServletContext().getInitParameter("ilprod_db_pass");
         //ensure a value is present
         if(ilprod_db_pass==null||ilprod_db_pass.equals("")){
         throw new ServletException("Error retrieving ilprod_db_pass from deployment descriptor. - ilprod_db_pass is null or an empty string");
         //get the tedsi_prod_owner from the deployment descriptor
         tedsi_prod_owner = (String)getServletContext().getInitParameter("tedsi_prod_owner");
         //ensure a value is present
         if(tedsi_prod_owner==null||tedsi_prod_owner.equals("")){
         throw new ServletException("Error retrieving tedsi_prod_owner from deployment descriptor. - tedsi_prod_owner is null or an empty string");
         //get the nsp_portal_owner from the deployment descriptor
         nsp_portal_owner = (String)getServletContext().getInitParameter("nsp_portal_owner");
         //ensure a value is present
         if(nsp_portal_owner==null||nsp_portal_owner.equals("")){
         throw new ServletException("Error retrieving nsp_portal_owner from deployment descriptor. - nsp_portal_owner is null or an empty string");
         //get the iladmin_owner from the deployment descriptor
         iladmin_owner = (String)getServletContext().getInitParameter("iladmin_owner");
         //ensure a value is present
         if(iladmin_owner==null||iladmin_owner.equals("")){
         throw new ServletException("Error retrieving iladmin_owner from deployment descriptor. - iladmin_owner is null or an empty string");
         //get the ilprod_db_host from the deployment descriptor
         ilprod_db_host = (String)getServletContext().getInitParameter("ilprod_db_host");
         //ensure a value is present
         if(ilprod_db_host==null||ilprod_db_host.equals("")){
         throw new ServletException("Error retrieving ilprod_db_host from deployment descriptor. - ilprod_db_host is null or an empty string");
         //get the ilprod_db_port from the deployment descriptor
         ilprod_db_port = (String)getServletContext().getInitParameter("ilprod_db_port");
         //ensure a value is present
         if(ilprod_db_port==null||ilprod_db_port.equals("")){
         throw new ServletException("Error retrieving ilprod_db_port from deployment descriptor. - ilprod_db_port is null or an empty string");
         //get the ilprod_db_service from the deployment descriptor
         ilprod_db_service = (String)getServletContext().getInitParameter("ilprod_db_service");
         //ensure a value is present
         if(ilprod_db_service==null||ilprod_db_service.equals("")){
         throw new ServletException("Error retrieving ilprod_db_service from deployment descriptor. - ilprod_db_service is null or an empty string");
    %>
    <html>
    <head>
    <title>lookup</title>
    </head>
    <body>
    <jsp:useBean id="lookup" class="utils.LookupBean">
    <jsp:setProperty name="lookup" property="ilprod_db_user" value="<%=ilprod_db_user%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_pass" value="<%=ilprod_db_pass%>"/>
    <jsp:setProperty name="lookup" property="tedsi_prod_owner" value="<%=tedsi_prod_owner%>"/>
    <jsp:setProperty name="lookup" property="nsp_portal_owner" value="<%=nsp_portal_owner%>"/>
    <jsp:setProperty name="lookup" property="iladmin_owner" value="<%=iladmin_owner%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_host" value="<%=ilprod_db_host%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_port" value="<%=ilprod_db_port%>"/>
    <jsp:setProperty name="lookup" property="ilprod_db_service" value="<%=ilprod_db_service%>"/>
    <%
    //open db conn
    lookup.openIlprod();
    ResultSet roem = lookup.getOEMDropdown();
    ResultSet rstat = lookup.getStatusDropdown();
    if(roem!=null){
    %>
    OEM:��
    <select name="OEM">
    <%
    while(roem.next()){
    %>
    <option value="<%=roem.getString("id")%>"><%=roem.getString("name")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("OEM:  no records<br><br>");
    //******* IF I PUT ResultSet IN FRONT OF rstat HERE IT WORKS FINE?
    rstat = lookup.getStatusDropdown();
    if(rstat!=null){
    %>
    Status:��
    <select name="status">
    <%
    while(rstat.next()){
    %>
    <option value="<%=rstat.getString("id")%>"><%=rstat.getString("description")%></option>
    <%
    %>
    </select><br><br>
    <%
    else{
    out.println("Status:  no records<br><br>");
    //close db conn
    lookup.closeIlprod();
    %>
    </jsp:useBean>
    </body>
    </html>
    <%
    catch(Exception e){
         //set request attributes to pass to error page
         request.setAttribute("javax.servlet.error.exception",e);
         request.setAttribute("javax.servlet.error.message",e.getMessage());
         request.setAttribute("javax.servlet.error.request_uri",     request.getRequestURI());
         request.setAttribute("javax.servlet.error.servlet_name", request.getServletPath());
         //log to Tomcat
         application.log(" Message: "+e.getMessage()+'\r'+'\n'+"RequestURI: "+request.getRequestURI()+'\r'+'\n'+"Servlet Path: "+request.getServletPath(),e);
         //forward to the error page
         RequestDispatcher rd =     request.getRequestDispatcher("error.jsp");
         rd.forward(request,response);
         //out.println(e.getMessage());
    %>

  • Ejb3 session bean lookup

    Hello, I have following problem with the ejb3 and session bean lookup:
    For example, I have a session bean with some dummy method, i.e. getInfo() :
    @Stateless
    public class MySessionBean implements MySessionLocal {
    public String getInfo() {return "Hello from Session bean";}
    When I lookup and use this bean in servlet in the following way, everything is OK:
    public class MyServlet extends HttpServlet {
    @EJB() MySessionLocal mySession;
    protected void doPost(HttpServletRequest request, HttpServletResponse response) {
    out.println(mySession.getInfo());
    On the other side, when I create some java bean object as a facade, import and use it in servlet , it doesn't work:
    public class Facade {
    @EJB() MySessionLocal mySession;
    public String getInfo() { return mySession.getInfo();}
    public class MyServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) {
    Facade myFacade = new Facade();
    out.println(myFacade.getInfo());
    When servlet runs and gets to the command myFacade.getInfo(), NullPointerException is thrown, because mySession object in myFacade is null (ejb lookup method probably fails to perform...)
    I'm trying to use Facade to be able to use my Session Bean in JSP pages, i.e. to do something like <jsp:useBean id="myFacade" class="Facade" ...>
    Could someone clarify why lookup doesn't work in javabean object, despite the fact that it works in servlets?
    P.S. I'm running the latest promoted build (b31) of GlassFish (maybe this is the cause) and NetBeans IDE...

    Hi,
    Please try this ... http://weblogic-wonders.com/weblogic/2009/08/16/weblogic-10-3-ejb3-local-lookup-sample/ (Lookup from JSP)
    and
    http://weblogic-wonders.com/weblogic/2009/08/15/hello-world-2/  (Lookup/Injection from Servlet)
    Thanks
    Jay SenSharma

  • Assiginment to varaibles from jsp tags

    is it possible and how is it possible to assign something from jsp tag to an variable declared in scriptlet code - ie. - as below.
    also is there a good resource for jsp info - a comprehensive lookup on jsp syntax egs on the web that any one is aware of. - thanks.
    i 'm doing - can i use this variable as in below scrpitlet code :
    <%! List myAbridgments = new ArrayList(); %>
    then - Also at this stage it get a ClassCastException - why would i get that here i dont use this variable - results anywhere else - except in setting the session attribute in the original servlet that calls this jsp page
    <jsp:useBean id="results" class="com.bt.ros.Results" scope="session">
    <jsp:setProperty name="results" property="*"/>
    </jsp:useBean>
    the in some scrpitlet code doing:
    <%  myAbridgments = results.getAbridgments();
    for (int i = 0; i < myAbridgments.size(); i++) {
                    abridgment = (Abridgment) myAbridgments.get(i);
                        //out.println(abridgment.geta_volume_id());
    %>
    <p><input type="checkbox" name="list" value="ON"><span style="font-size:12pt"><jsp:getProperty name="abridgment" property="a_sub_year_volume"/></span><span style="font-size:12pt">,
         <a href="abridgment_link.htm"><jsp:getProperty name="abridgment" property="a_volume_id"/></a>, </span>

    yeah, but this doesn't really help me. I am trying (really hard!) to ensure my JSP's don't really contain any "code" as such, just JSP tags.
    The end result I want is to include one JSP in another. Now, I "could" just use a <jsp:include.., the problem is that the path to the file I want to include is tied up in an object which I have previously placed in the ServletRequest object. Again, I "could" extract this in the "parent" jsp, and pass it dynamically to the jsp:include, but I don't want any actual Java "code" in the JSP. (There IS a good reason for this, so I can't really comprimise).
    The fact that the IS a pageContext.include() method tells me that I can use it. I must be doing something wrong though.
    Thanks anyway.

  • JNDI-Tomcat 5.5.17, Cannot create JDBC driver of class '' for connect URL '

    I wrote a jsp program using JNDI to get connected to MySql DB, but i got the error " Cannot load JDBC driver class 'com.mysql.jdbc.Driver' " while running the program.
    I'm using NetBean5.5 which has bundled TomCat5.5.17.
    I've refered to many tutorials and websites, but i still can't solve it, here's my configuration and codes:
    Imported mysql-connector-java-5.0.5-bin into lib directory.
    context.xml:
    <Context path="/WebApplication1">
    <Resource name="jdbc/jsp" auth="Container" type="javax.sql.DataSource"/>
    <ResourceParams name="jdbc/jsp">
    <parameter>
    <name>driverClassName</name>
    <value>com.mysql.jdbc.Driver</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:mysql://localhost:3306/jsp</value>
    </parameter>
    <parameter>
    <name>username</name>
    <value>root</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>malaysia</value>
    </parameter>
    <parameter>
    <name>maxActive</name>
    <value>20</value>
    </parameter>
    <parameter>
    <name>maxIdle</name>
    <value>10</value>
    </parameter>
    <parameter>
    <name>maxWait</name>
    <value>-1</value>
    </parameter>
    </ResourceParams>
    </Context>
    i included the following in Web.xml:
    <resource-ref>
    <res-ref-name>jdbc/jsp</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    <res-sharing-scope>Shareable</res-sharing-scope>
    </resource-ref>
    My JSP Code:
    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/jsp");
    Connection conn = ds.getConnection();
    Thanks~~~~

    I think mysql jdbc library should add to the class library path of your project.
    Hope this helps.

  • Debugging Java Client Proxy - XI Interface

    Hi ,
       I am trying out Oubound Proxy client to an XI message interface through EJB client lookup from JSP.
    I would like to debug my java bean and jsp. I added system.out.println statements in my code, it is not coming out in console_logs of J2EE Server.. Can any one shed some light on what could be wrong. Or is there any other good way[like logger api's] to do debug.
    Thanks,
    Ganesh Ram

    Any comments?
    Ganesh Ram

  • Need help on Internationalization..(scalability issue)

    I am currently developing frame work for implementing internationalization in my project. I am following the approach of Properties file. I want to know how far it is scalable. Can some one suggest me some supporting document that says how it is scalable.
    help needed asap.
    TIA,
    CK

    I am currently developing frame work for implementing
    internationalization in my project. I am following the
    approach of Properties file. I want to know how far it
    is scalable. Can some one suggest me some supporting
    document that says how it is scalable.
    help needed asap.
    TIA,
    CKWell, I cant point you to a document - and I doubt such a document exist. I will however say that I have built i18N applications relying heavily on ResourceBundles (each view using on average maybe 40 - 100 lookups - from jsp custom actions) and I have seen no performance problems. In addition I would like to point out that it is trivial to stage a performance test verifying this for yourself - do it...

  • ZipException with EJB's???

              I am in the process of learning how to setup clusters and have run into a problem. Basically,
              I have a 3 server cluster: 1 proxy & 2 presentation/object tier servers. Without the EJB's deployed
              everything appears to work fine. I use the proxy servers URL to lookup a JSP and it forwards the reqest
              to 1 of the other servers. When I introduce the EJB into the mix I get a ZipException when it tries to
              read the deployed jar. I have tried deploying the EJB at server startup and after startup. Any ideas???
              Thanks in advance,
              Drew
              

    Which Service pack of iAS you are using? Please send more detail about your application. Can you figure out when your EJB's hang up. Are they hanging up always or in some specific condition?

  • ERROR:NameNotFoundException: Object not found in lookup of MYDB

    NW 7.0 SP3
    I have defined a datasource MYDB by VA,and it tests OK.
    I wonder about how to use it in J2EE project or in WebDynpro Project.
    I created a J2EE project ,in the Web Model ,i new a class Test:
    public static Connection myconn(){    
         Context ctx = new InitialContext();
         Connection conn = null;
         DataSource dataSource = null;
         dataSource = (DataSource) ctx.lookup("MYDB");
        conn = dataSource.getConnection();
        return conn;
    then in webcontent ,I new a JSP page:
    <%
      Connection conn = com.Test.myconn();
    java.sql.Statement st = conn.createStatement();
    String str = "select * from TMP_NAME";
    ResultSet rs = st.executeQuery(str);
    rs.next();
    String str1 = rs.getString(1);
    %>
    after build and deploy the *.ear,the server returns an error:
             com.sap.engine.services.jndi.persistent.exceptions.NameNotFoundException: Object not found in lookup of MYDB.
    Now I do not know anything else should I do,such as create a reference,and so on.
    Thanks for you all help!

    Hi,
    Try the code as below:
    DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/MYDB")
    Go through the below help link:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/82/fdbf2085f65f43a71e755fc904478d/content.htm
    Go through the below thread for more info:
    Re: datasource using VA
    Regards,
    Charan

  • JNDI lookup from a JSP page (URGENT)

    Hello,
    In my JSP I was using the "conn = DriverManager.getConnection("URL","username", "password")" scheme
    to connect to the database. I want to change this to use the JNDI for the database lookup in the same JSP.
    After creating this JSP i am using the include directive to include this JSP in all my other JSPs so that I can get the connection on other JSPs too.
    My included JSP where I use the JNDI look up is:
    <%@ page import="javax.naming.*,javax.sql.DataSource,java.sql.*" %>
    <%!
    static Connection conn;
    static Statement statement;
    static DataSource dataSource;
    %>
    try{
         Context ctx = new InitialContext();
         dataSource = (DataSource)ctx.lookup("MY_JNDI_NAME");
         conn = dataSource.getConnection();
         statement = conn.createStatement();
    }catch (Exception excep){
         out.println("Exception occurred "+excep);
    %>
    After I include this JSP in my main JSP, i get some error:
    188: Type expected. } catch (Throwable t) { ^ 1 error
    Can anyone here please help how to fix this.
    Thanks

    <%@ page import="javax.naming.*,javax.sql.DataSource,java.sql.*" %>
    <%!
    static Connection conn;
    static Statement statement;
    static DataSource dataSource;
    %><% // <-- you were missing a "<%" here
    try{
    Context ctx = new InitialContext();
    dataSource = (DataSource)ctx.lookup("MY_JNDI_NAME");
    conn = dataSource.getConnection();
    statement = conn.createStatement();
    }catch (Exception excep){
    out.println("Exception occurred "+excep);
    %>If I run that code in tomcat I get "Exception occurred javax.naming.NameNotFoundException: Name MY_JNDI_NAME is not bound in this Context". Which is what I would expect.
    btw: You really shouldn't be doing this stuff in a jsp.

  • How to use JNDI lookup from a JSP

    Hello,
    I know I should not be doing this (writing the lookup code in a JSP) but have to do it for some reasons.
    I am using this code in my JSP:
    try
         Context ctx = new InitialContext();
         dataSource = (DataSource)ctx.lookup("jdbc/mybillingora");
         conn = dataSource.getConnection();
         statement = conn.createStatement();
    catch(Exception excep)
    Is this code enough for a JNDI look up?? When I use this code, I get an exception:
    "javax.naming.NameNotFound exception:jdbc/mybillingora"
    Do I need to do something else??
    Why do we use :
    Properties env = new Properties();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
    "<some_context_factory>");
    env.put(Context.PROVIDER_URL, PROVIDER_URL);
    env.put(Context.SECURITY_PRINCIPAL, JNDI_USER);
    env.put(Context.SECURITY_CREDENTIALS, JNDI_PWD);
    InitialContext = new InitialDirContext(env);
    where JNDI_USER is the userid If ACL is configured at the JNDI server
    where JNDI_PWD is the password If ACL is configured at the JNDI server
    Context.INITIAL_CONTEXT_FACTORY is the initial Context factory and depends on ur JNDI service provider.
    PROVIDER_URL is the url of the JNDI server containing protocol/ip/port
    do i need to use this??
    would appreciate your help on this....
    Thanks

    If Tomcat is your servlet/JSP engine, they have a nice bit about how to do it:
    http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
    MOD

Maybe you are looking for

  • How do I configure portal desktop to use my own custom tag in template?

    I seem to have tried everything. I want to use a custom tag from a jar file on a template JSP. I keep getting error saying tag library not found. I have the tld in the meta-inf of the jar. I tried putting the jar in the desktop classes, the deployed

  • How to upload a Flat file into sap database if the file is in Appl'n Server

    Hello Sap Experts , Can you tel me " How to upload a Flat file into sap database if the file is in Application Server. what is Path for that ? Plz Tel Me its Urgent Thanks for all

  • Specify TIMESTAMP format -YYYYMMddHHmmss- in filename

    Hi, I am using B2B 10.1.2 and need to add TIMESTAMP to the file name of an Inbound file before it is dropped to the destination. The name of file at source does not have TIMESTAMP. If i just use %TIMESTAMP% timestamp in the default form is added to t

  • FORMS_PATH in 10g

    In the default.env file is there a limitation on how long the FORMS_PATH can be on an Oracle 10g Application Server running on Windows? I know that Windows has a restriction of 255 characters if you're using the registry but is there the same limitat

  • Should we be leaving some free space on iPod hard drives?

    I'm curious about this. Just recently bought a used 40 GB iPod (4th Gen.) and have loaded it nearly full. I just wondered if I should feel free to fill it up until there's essentially no space left, or if I'm better off to leave some open space on it