HELP! - BEAN and CLASS interchange?

When I setup to a bean like:
<jsp:useBean id="logger" scope="application" class="Logger" />
I can use the bean and bean's functions fine in the JSP, but not within functions that exist in the JSP like:
jspInit()
it says the "logger" is undefined. Is there a way I can access the logger function within the jspInit class or do i have to redefine a new instance of "logger" within jspInit().
The whole point is I would like to use the same instance of the class from all the JSPs. Thats what scope=application seems to do instead of instantiating everytime.
P.S. If I were to instantiate a class like:
Logger logger = new Logger;
would I be able to give it "applicate scope"? like a bean can have?
Really long question, thanks a lot for the help. :)

Hi yusufm1,
I can use the bean and bean's functions fine in the JSP, but not within functions that exist in the JSP like:
jspInit()it says the "logger" is undefined.
What ever you write in jsp, other than in <%! %> tags, is a part of _jspService() method. The life cycle of jsp has following 3 steps.
1. jspInit()
2. _jspService()
3. jspDestroy()
jspInit() is the first method of the jsp class that is executed. _jspService is the next method. The statement -
<jsp:useBean id="logger" scope="application" class="Logger" />
instantiates a bean in _jspService() method of jsp class. So it is evident that this instance is not available in jspInit().method.
Is there a way I can access the logger function within the jspInit class or do i have to redefine a new instance of "logger" within jspInit().
To use the bean instance in jspInit() you should instantiate the bean object in jspInit() or declare it as an instance variable.
If I were to instantiate a class like:
Logger logger = new Logger;
would I be able to give it "applicate scope"? like a bean can have?
No, simply instantiating a class in the jspInit() method wouldnot provide it with application scope. You have to put that instance in ServletContext (application) to make it available to all jsp pages. If you instantiate a class in jspInit() only and donot put it in application it is not even available to _jspService() method.
Hope this helps

Similar Messages

  • Beans and classes

    Is it possible to use bean not just as storage but as a class- to use methods other then get or set on it? I added a little method that just prints out all of the parameters but what I get is
    javax.servlet.ServletException: foo.Creature.stats()Ljava/lang/String;
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
    at org.apache.jsp.index1_jsp._jspService(index1_jsp.java:77)
    (jsp page is index1.jsp)
    and in that index1_jsp.java file line 77 looks like
    if (pageContext != null) pageContext.handlePageException(t);
    which doesnt tell me a whole lot. So how do I use methods on beans and how do I make errors make more sence?

    Sure you can call other methods of your bean.
    How are you invoking it? How does it print out the 'parameters'?
    What you might try is wrapping it in your own exception code to see what happens.
    You will need to import java.io.PrintWriter to get this to work.
    <%@ page import="java.io.PrintWriter" %>
    <%
    try{
      call your method...
    catch (Throwable t){
    %> 
      ERROR IN MY CODE HERE <br>
      <pre><% t.printStackTrace(new PrintWriter(out));%></pre>
    <%
    %>(Yes I know this code is ugly, but it does work for me)

  • What is exact diff between Bean and Class

    As my knowledge...
    Class should not depends on any specified rules..But Bean should specified on specified rules, like setters and getters....
    is there any more........
    thanks for giving help..........

    Yes, but what are they good for, except for providing
    examples of really bad OO design by just being a
    complicated struct?Look at Spring; an extremely powerful application configuration tool (and much, much more); all possible because of JavaBean conventions. Otherwise Spring would have had one set of conventions, JSF another, Hibernate another still, making programmers' lives difficult.
    Look at the PropertyEditorSupport class - it's fantastic that I can write a standardized String-to-instance-to-String class for a particular type and just have frameworks like Spring take care of the problems generating my domain model from configuration. Using a standard mechanism makes me confident that if, in the future, I ditch Spring, my bespoke property editors will not be obsolete.

  • Question about main difference between Java bean and Java class in JSP

    Hi All,
    I am new to Java Bean and wonder what is the main difference to use a Bean or an Object in the jsp. I have search on the forum and find some post also asking the question but still answer my doubt. Indeed, what is the real advantage of using bean in jsp.
    Let me give an example to illustrate my question:
    <code>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ page import="ShoppingCart" %>
    <!-- Instantiate the Counter bean with an id of "counter" -->
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    <html>
    <head><title>Shopping Cart</title></head>
    <body bgcolor="#FFFFFF">
    Your cart's ID is: <%=cart.getId()%>.
    </body>
    <html>
    </code>
    In the above code, I can also create a object of ShoppingCart by new operator then get the id at the following way.
    <code>
    <%
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    %>
    </code>
    Now my question is what is the difference between the two method? As in my mind, a normal class can also have it setter and getter methods for its properties. But someone may say that, there is a scope="session", which can be declared in an normal object. It may be a point but it can be easily solved but putting the object in session by "session.setAttribute("cart", cart)".
    I have been searching on this issue on the internet for a long time and most of them just say someting like "persistance of state", "bean follow some conventions of naming", "bean must implement ser" and so on. All of above can be solved by other means, for example, a normal class can also follow the convention. I am really get confused with it, and really want to know what is the main point(s) of using the java bean.
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

    Hi All,
    I am new to Java Bean and wonder what is the main
    difference to use a Bean or an Object in the jsp. The first thing to realize is that JavaBeans are just Plain Old Java Objects (POJOs) that follow a specific set of semantics (get/set methods, etc...). So what is the difference between a Bean and an Object? Nothing.
    <jsp:useBean id="cart" scope="session" class="ShoppingCart" />
    In the above code, I can also create a object of
    ShoppingCart by new operator then get the id at the
    following way.
    ShoppingCart cart = new ShoppingCart();
    out.println(cart.getId());
    ...Sure you could. And if the Cart was in a package (it has to be) you also need to put an import statement in. Oh, and to make sure the object is accessable in the same scope, you have to put it into the PageContext scope. And to totally equal, you first check to see if that object already exists in scope. So to get the equivalant of this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart"/>Then your scriptlet looks like this:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = pageContext.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        pageContext.setAttribute("cart", cart);
    %>So it is a lot more work.
    As in my mind, a normal class can also
    have it setter and getter methods for its properties.True ... See below.
    But someone may say that, there is a scope="session",
    which can be declared in an normal object.As long as the object is serializeable, yes.
    It may be
    a point but it can be easily solved but putting the
    object in session by "session.setAttribute("cart",
    cart)".Possible, but if the object isn't serializable it can be unsafe. As the point I mentioned above, the useBean tag allows you to check if the bean exists already, and use that, or make a new one if it does not yet exist in one line. A lot easier than the code you need to use otherwise.
    I have been searching on this issue on the internet
    for a long time and most of them just say someting
    like "persistance of state", "bean follow some
    conventions of naming", "bean must implement ser" and
    so on. Right, that would go along the lines of the definition of what a JavaBean is.
    All of above can be solved by other means, for
    example, a normal class can also follow the
    convention. And if it does - then it is a JavaBean! A JavaBean is any Object whose class definition would include all of the following:
    1) A public, no-argument constructor
    2) Implements Serializeable
    3) Properties are revealed through public mutator methods (void return type, start with 'set' have a single Object parameter list) and public accessor methods (Object return type, void parameter list, begin with 'get').
    4) Contain any necessary event handling methods. Depending on the purpose of the bean, you may include event handlers for when the properties change.
    I am really get confused with it, and
    really want to know what is the main point(s) of
    using the java bean.JavaBeans are normal objects that follow these conventions. Because they do, then you can access them through simplified means. For example, One way of having an object in session that contains data I want to print our might be:
    <%@ page import="my.pack.ShoppingCart %>
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        session.setAttribute("cart", cart);
    %>Then later where I want to print a total:
    <% out.print(cart.getTotal() %>Or, if the cart is a JavaBean I could do this:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session"/>
    Then later on:
    <jsp:getProperty name="cart" property="total"/>
    Or perhaps I want to set some properties on the object that I get off of the URL's parameter group. I could do this:
    <%
      ShoppingCart cart = session.getAttribute("cart");
      if (cart == null) {
        cart = new ShoppingCart();
        cart.setCreditCard(request.getParameter("creditCard"));
        cart.setFirstName(request.getParameter("firstName"));
        cart.setLastName(request.getParameter("lastName"));
        cart.setBillingAddress1(request.getParameter("billingAddress1"));
        cart.setBillingAddress2(request.getParameter("billingAddress2"));
        cart.setZipCode(request.getParameter("zipCode"));
        cart.setRegion(request.getParameter("region"));
        cart.setCountry(request.getParameter("country"));
        pageContext.setAttribute("cart", cart);
        session.setAttribute("cart", cart);
      }Or you could use:
    <jsp:useBean id="cart" class="my.pack.ShoppingCart" scope="session">
      <jsp:setProperty name="cart" property="*"/>
    </jsp:useBean>The second seems easier to me.
    It also allows you to use your objects in more varied cases - for example, JSTL (the standard tag libraries) and EL (expression language) only work with JavaBeans (objects that follow the JavaBeans conventions) because they expect objects to have the no-arg constuctor, and properties accessed/changed via getXXX and setXXX methods.
    >
    Any help will be highly apprecaited. Thanks!!!
    Best Regards,
    Alex

  • First use of jsp and java bean and "Unable to compile class for JSP" error

    Hi,
    I am trying to create my first jsp + java bean and I get a basic error (but I have no clue what it depends on exactly). Tomcat seems to cannot find my class file in the path. Maybe it is because I did not create a web.xml file. Did I forgot to put a line in my jsp file to import my bean?
    Thank you very much for your help.
    Here is my error:
    An error occurred at line: 2 in the jsp file: /login.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /usr/local/tomcat/jakarta-tomcat-5/build/work/Catalina/localhost/test/org/apache/jsp/login_jsp.java:43: cannot resolve symbol
    symbol : class CMBConnect
    location: class org.apache.jsp.login_jsp
    CMBConnect test = null;
    I only have this in my directory:
    test/login.jsp
    test/WEB-INF/classes/CMBConnect.java
    test/WEB-INF/classes/CMBConnect.class
    Do I need to declare another directory in classes to put my class file in it and package my bean differently?
    Here is my login.jsp:
    <%@ page errorPage="error.jsp" %>
    <jsp:useBean id="test" type="CMBConnect" scope="session" />
    <html>
    <head>
    <title>my test</title>
    </head>
    <body>
    <h3>Login information</h3>
    <b><%=session.getValue("customerinfo.message")%></b>
    <form> ....... </form>
    </body>
    </html>
    and here is my CMBConnect.java:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class CMBConnect
    public CMBConnect () { }
    public String openConnection(String id, String password) {
    String returnText = "";
    try {
    Connection con = null;
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection("jdbc:oracle:thin:@myserver.abc.com:1521:TEST", id, password);
    if(con.isClosed())
    returnText = "Cannot connect to Oracle server using TCP/IP...";
    else
    returnText = "Connection successful";
    } catch (Exception e) { returnText = returnText + e; }
    return returnText;
    Thanks again!

    Thanks for you help
    I created the package and I get this error this time:
    javax.servlet.ServletException: bean test not found within scope
         org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:822)
         org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:755)
         org.apache.jsp.login_jsp._jspService(login_jsp.java:68)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:268)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:277)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:223)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

  • What jar file contains oracle.ifs.beans and oracle.ifs.clients classes?

    I am trying to build some code which needs oracle.ifs.beans and oracle.ifs.clients packages and classes. I have downloaded the following:
    OracleAdministrativeClientUtility
    OracleApplicationServer
    OracleContentManagementSDK
    OracleIIOPClientLibrary
    OracleJDeveloper
    OracleRMIClientSideLibrary
    OracleSOA
    OracleWebServicesClientLibrary
    None of these appears to contain the oracle.ifs packages.

    oracle.ifs.beans and oracle.ifs.clients packages are for the Oracle Internet File System. Are the following JAR files available?
    repos.jar
    adk.jar

  • Is there any difference between java Beans and general class library?

    Hello,
    I know a Java Bean is just a java object. But also a general class instance is also a java object. So can you tell me difference between a java bean and a general class instance? Or are the two just the same?
    I assume a certain class is ("abc.class")
    Second question is is it correct that we must only use the tag <jsp:useBean id="obj" class="abc.class" scope="page" /> when we are writng jsp program which engage in using a class?Any other way to use a class( create object)? such as use the java keyword "new" inside jsp program?
    JohnWen604
    19-July-2005

    a bean is a Java class, but a Java class does not have to be a bean. In other words a bean in a specific Java class and has rules that have to be followed before you have a bean--like a no argument constructor. There are many other features of beans that you may implement if you so choose, but read over the bean tutorial and you'll see, there is a lot to a bean that is just not there for many of the Java classes.
    Second question: I'll defer to someone else, I do way to little JSP's to be able to say "must only[\b]".

  • My 2008 macbook will not turn on. the light on the corner is on. not flashing but on. its fully charged and has lion on it. please help! my classes start Monday and i need it before then!!

    my 2008 macbook will not turn on. the light on the corner is on. not flashing but on. its fully charged and has lion on it. please help! my classes start Monday and i need it before then!! It will turn on for a coupe seconds, and then turn off.

    Take it into an Apple store for evaluation.

  • Hi frnds i want to help in servlet,java bean and JSP

    hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
    so pls give me a title about that
    NOTE: I develop a project in group(2 persons there)
    my email id is : [email protected] , [email protected] , [email protected]

    You cannot pair your iPod to a cell phone, so forget about it.
    The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve....

  • Setting path and class path help

    I am a complete beginner who is currently starting a cd based tutorial!I have downloaded jdk1.1.6 which is the nearest developement kit to the one used in the tutorial.I use windows 98.When I try to set my path or class path as instructed in the docs, I cannot find any thing in the autoexec file at all.I have opened using notepad/Run and DOS edit but all three open an empty file.Where will I need to set up the path and class paths.My system must run these from somewhere else perhaps due to an update.

    Hi,
    Put the following statements in your autoexec.bat.
    <homepath> = Path of your JDK folder on the drive. e.g. c:\jdk
    SET CLASSPATH=;.;<homepath>\lib\tools.jar; .... continue with other jar files on the same line and seperate the entries by a semicolon.
    SET PATH=C:\WINDOWS\;C:\<homepath>\BIN\;
    This autoexec.bat must be on c:\. i.e. U can open it in notepad by giving c:\autoexec.bat in the File Open Dialog. It is possible for this file to be empty. Simply add the commands on the last line.
    Regards ,
    Karan

  • Message Driven Bean and Distributed transaction

    Hi ALL
    I am developing an asynchronous application using MDB. My application flow is as follows:
    1. From MDB onMessage i am calling a method MethodA that
    a. calls a simple pojo1 where I am getting a Connection on XA enable datasource1 and executing Stored Procedure1 of DatabaseSchema1.
    b. In that pojo without committing m closing the connection and coming back in MethodA.
    c. Again from MethodA m calling a different pojo2 where I am getting a new Connection on XA enable datasource2 and executing Stored Procedure2 of
    DatabaseSchema1. In this pojo also without committing m closing the connection and coming back in MethodA.
    d. Again from MethodA m calling pojo1 where I am getting a new Connection on XA enable datasource1 and executing a different function of Stored Procedure1 of DatabaseSchema1.
    Public class MDB{
    Public void onMessage(��.)
    Try{
    Method1();
    Catch(Exception x)
    mdbcontext.setRollbackOnly();
    Private void MethodA()
    Call pojo1;
    Call pojo2
    Pojo1
    Public void CallSP1()
    Get connection from Datasource1 (shema1,user1, pwd1);
    Call sp1();
    //return without commit;
    Pojo2
    Public void CallSP2()
    Get connection from Datasource2 (shema1,user2, pwd2);
    Call sp2();
    //return without commit;
    SP1:
    Insert table1
    Savepoint 1
    Insert into Table1
    Rollback to 1
    Insert a row
    End SP1 (without commit)
    SP2:
    Insert table2
    Savepoint 2
    Update table2
    Rollback to 2
    Insert table2
    End SP2 (without commit)
    In ejb-jar.xml
    Transaction type is Container
    Transaction attribute is Required for all
    Now problem is:
    Case 1: success case when no exception is there at Java layer
    SP1 works fine I mean there is only 2 inserts in Table 1
    But In SP2 there are 3 inserts
    Case 2: if an exception comes at Java layer
    SP1 is fine
    Rollback is not happening in SP2
    In ejb-jar.xml transaction attributes is Required for all methods and transaction type is Container.
    Backend is Oracle 10g and init.xa has already been run on that.
    Will be very obliged if can have a single hint of the problem.
    Both datasource are XA enable
    Backend is Oracle 10g
    Application server is WAS 6.0
    Queue is WAS MQ 6.0
    Thanks

    {color:#008000}Hi Friends,
    Thought of updating the answers for my questions in case somebody else would find it helpful.
    {color}
    {color:#999999}{color:#00ccff}I'm trying to make message driven bean and use the OnListener method.
    But since I'm doing this for the first time I have very limited knowledge.
    The following are my doubts :
    1. Should I have a main function while using the MDB?{color}
    {color:#008000} There is no need for any main function.{color}
    {color:#00ccff}2. Is it mandatory to have JNDI setup done?
    {color} {color}{color:#008000} There is no need for any JNDI setup done. But you need to configure the details on the
    Websphere by creating valid entries inside Resources namely -
    Queue Connection Factory, Queues and Listener Ports under the server.
    Thanks,
    Arun Prithviraj{color}

  • Javax.servlet.jsp.JspException: Exception creating bean of class ProdFormFB

    Hi I am trying to deploy a struts based web application using "DynaActionForms"
    When I am trying to access the jsp page I am getting the following error.
    I am providing as much as details as it can help full to u.
    Thank u.
    FormBean class ProdFormFB.java
    ========================================================================
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    public class ProdFormFB extends DynaActionForm
    public void reset(ActionMapping mapping, HttpServletRequest request)
         System.out.println("reset() called. . . . ");
    set("prodId", new Integer(10));
         set("prodName", new String("XYZ"));
         set("price", new Float(22.25));
    public ActionErrors validate(ActionMapping mappings, HttpServletRequest request)
    System.out.println("=== validate() called ===");
    ActionErrors aes=new ActionErrors();
         System.out.println("aes.size() ===> "+aes.size());
         String prodName = (String)get("prodName");
         if( prodName==null || prodName.equals("") )
              System.out.println("Adding prodName.req error . . . . . . .");
              aes.add("prodName",new ActionError ("prodName.req.error"));
    return aes;
    ========================================================================
    Action Class ProdAction.java
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.struts.action.*;
    public class ProdAction extends Action
       public ActionForward execute(ActionMapping mapping,ActionForm form, HttpServletRequest request,HttpServletResponse response)throws Exception
          ProdFormFB fb = (ProdFormFB)form;
          System.out.println("fb.get('prodId')==> "+fb.get("prodId"));
          System.out.println("fb.get('prodName')==> "+fb.get("prodName"));
          System.out.println("fb.get('price')==> "+fb.get("price"));
           return mapping.findForward("dres");
    }========================================================================
    jsp page : npform.jsp
    <%@ taglib uri = "/tags/struts-html" prefix="html"%>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <html:html>
      <head>
         <title>Product Form</title>
      </head>
      <body>
              <html:form action="/pAction">
              <center>
                <br><br>
                <center> <font color="green" style="bold" size=5>Product Form using Struts</font></center><br><br>
                <table>
                <tr>
                   <td>
                          <b> Product ID : </b>  <html:text property="prodId"/> </td><td><font color="red" style="bold"><html:errors property="prodId"/> </font>
                 </td>
             </tr>
               <tr>
                   <td>
                          <b> Prod Name : </b> <html:text property="prodName"/>  </td><td> <font color="red" style="bold"> <html:errors property="prodName"/> </font>
                 </td>
              </tr>
    <!--           <tr>
                   <td>
                          <b> Price : </b> <html:text property="price"/>  </td><td> <font color="red" style="bold"> <html:errors property="price"/> </font>
                 </td>
              </tr> -->
               <tr  colspan="2" align="center">
                   <td>
                      <html:submit property="submit" value="Store"/>
                </td>
              </tr>
              </table>
                          </center>
           </html:form>
      </body>
    </html:html>========================================================================
    Configuration in struts-config.jsp
        <form-beans>
             <form-bean name="NewProdForm" type="ProdFormFB">
                  <form-property name="prodId" type="java.land.Integer"/>
                    <form-property name="prodName" type="java.land.String"/>
                  <form-property name="price" type="java.land.Float"/>
            </form-bean>
    </form-beans>
    <action-mappings>
           <action name="NewProdForm" path="/pAction" type="ProdAction" input="/npform.jsp" validate="true" scope="request">
                  <forward name="dres" path="/dres.jsp"/>
           </action>
    </action-mappings>========================================================================
    After deploying successfully I am I am entering the following URL
    http://localhost:7001/oursapp/npform.jsp
    The following Exception on Browser: and also on the server console ......
    javax.servlet.jsp.JspException: Exception creating bean of class ProdFormFB: {1}
         at org.apache.struts.taglib.html.FormTag.initFormBean(FormTag.java:463)
         at org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:433)
         at jsp_servlet.__npform._jspService(__npform.java:178)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
         at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
         at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6718)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
         at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)     
    Plz... Help me out is solving the problem .......
    my email :   [email protected]

    I never used DynaActionForm, what I have noticed here is, don't you need to declare the form bean? I may be wrong.
    <form-beans>
    <form-bean name="newProdForm" type="com.package.form.NewProdForm"></form-bean>
    </form-beans>

  • Javax.servlet.ServletException: Cannot create bean of class

    People,
    HELP!! I am getting desperate!!!
    I am a newbie when it comes to TOMCAT, but i have been using Blazix before.
    My current system is using APACHE/TOMCAT on a Solaris machine and I keep hitting the same problem. I have gone through the archives but the only thing it states is to check the directory which i have done.
    I keep getting:
    Error 500
    Internal Error
    javax.servlet.ServletException: Cannot create bean of class MyClass
    The code used to work on the Blazix server so i am assuming it is something to do with a config parameter somewhere - but i do not know where. I have checked the directory/package structure and they seem to work. It even serves it when they are html pages not jsp, but obviously wont use the bean. :(
    I can post code if necessary.
    Please help
    Steve

    The FormData.class file is in examples/WEB-INF/classes/ directory.
    Is this wrong? then should it be in a package called examples.steve???
    <TITLE> Poc </TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <META NAME="Generator" CONTENT="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
    <META NAME="Author" CONTENT="Steve Brodie">
    <META NAME="Proof of Concept order entry system" CONTENT="">
    <META NAME="PROOF OF CONCEPT ORDER ENTRY SYSTEM " CONTENT="">
    </HEAD>
    <%@ page import="steve.FormData" %>
    <jsp:useBean id="user" class="steve.FormData"/>
    <jsp:setProperty name="user" property="*"/>
    <FORM METHOD=POST ACTION="SaveDetails.jsp">
    <CENTER>
    <H1>     
    POC CNS demo <BR>
    POC Order Entry System <BR></H1>
    <H2><CENTER>PROOF OF CONCEPT ORDER ENTRY SYSTEM <BR>
    in order to illustrate the use of an new product<BR></H1>
    </CENTER>
    <BODY>
    Please enter the following details: <BR>
    Second name <INPUT TYPE=TEXT NAME=secondName SIZE=20><BR>
    First name <INPUT TYPE=TEXT NAME=firstName SIZE=20><BR>
    Address <INPUT TYPE=TEXT NAME=address1 SIZE=20><BR>
    Address <INPUT TYPE=TEXT NAME=address2 SIZE=20><BR>
    Post Code <INPUT TYPE=TEXT NAME=postCode SIZE=10><BR>
    Phone NO. <INPUT TYPE=TEXT NAME=phone SIZE=10><BR>
    <BR>
    Credit Card<INPUT TYPE=TEXT NAME=credit SIZE=15><BR>
    <BR>
    Quality of Service:
    <SELECT TYPE=TEXT NAME="QoS">
    <OPTION SELECTED TYPE=TEXT NAME=Gold>Gold <BR>
    <OPTION TYPE=TEXT NAME=Silver>Silver <BR>
    <OPTION TYPE=TEXT NAME=Bronze>Bronze <BR>
    </SELECT>
    <BR>
    <BR>
    <INPUT TYPE=RESET>
    <P><INPUT TYPE=SUBMIT>
    <BR>
    <BR>
    <IMG SRC=../images/Cisco.gif>
    </FORM>
    </BODY>
    </HTML>
    package steve;
    * @author Steven Brodie
    * @date
    * @version 0.0
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    public class FormData {
         String secondName = null;
         String firstName = null;
         String address1 = null;
         String address2 = null;
         String postCode = null;
         int credit = 0;
         int phone = 0;
         String qos = null;
         String file = "out";
         String filex = "xout";
         PrintWriter pout = null;
         PrintWriter xout = null;
         FormData() {
              try {
                   pout = new PrintWriter(new BufferedWriter(new FileWriter(file + ".txt")));
                   xout = new PrintWriter(new BufferedWriter(new FileWriter(filex + ".xml")));
              xout.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
              xout.println("<OrderEntry xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
              xout.println("xsi:noNamespaceSchemaLocation=\"http://machine2.com:8080/xml/xsd/OrderEntry.xsd\">");
              } catch (IOException ioe) {
                   System.err.println("DataFileWriter error ioe on init");
                   ioe.printStackTrace();
                   System.exit(1);
    public void setFirstName( String value ) {
    firstName = value;
              System.out.println(firstName);
              pout.println(firstName);
              xout.println("<firstname value= \"" + firstName + "\"/>");
    public void setSecondName( String value ) {
    secondName = value;
              System.out.println(secondName);
              pout.println(secondName);
              xout.println("<secondname value= \"" + secondName + "\"/>");
    public void setAddress1( String value ) {
    address1 = value;
              System.out.println(address1);
         pout.println(address1);
              xout.println("<address1 value= \"" + address1 + "\"/>");
    public void setAddress2( String value ) {
    address2 = value;
              System.out.println(address2);
              pout.println(address2);
              xout.println("<address2 value= \"" + address2 + "\"/>");
    public void setPostCode( String value ) {
    postCode = value;
              System.out.println(postCode);
              pout.println(postCode);
              xout.println("<postCode value= \"" + postCode + "\"/>");
    public void setCredit( int value ) {
    credit = value;
              System.out.println(credit);
              pout.println(credit);
              xout.println("<creditCard value= \"" + credit + "\"/>");
         public void setPhone( int value) {
              phone = value;
              System.out.println("0" + phone);
              pout.println("0" + phone);
              xout.println("<phoneNo value= \"0" + phone + "\"/>");
    public void setQoS( String value ) {
    qos = value;
              System.out.println(qos);
              pout.println(qos);
              xout.println("<QoS value= \"" + qos + "\"/>");
              xout.println("</OrderEntry>");
              pout.flush();
              pout.close();
              xout.flush();
              xout.close();
    public String getFirstName() {
              return firstName;
    public String getSecondName() {
              return secondName;
    public String getAddress1() {
              return address1;
    public String getAddress2() {
              return address2;
    public String getPostCode() {
              return postCode;
    public int getCredit() {
              return credit;
         public int getPhone() {
              return phone;
         public String getQoS() {
              return qos;

  • Stateless session beans and idle timeouts (weblogic 10.3.1)

    Need clarification about stateless session beans and the idle-timeout-seconds setting.
    Situation is this – we have a process that is timing out due to an API call to a very slow Authentication server.
    I am trying to resolve this with a code change, but need to further other understand what the server is actually doing.
    We have a session bean which calls another which is calling a util class that does all the work and returns the results back up to the initial session bean. I have left out the ejbName in these examples (it’s irrelevant here).
    Example:
    SessionBean1 // basically called just once a day
    @Session(defaultTransaction = Constants.TransactionAttribute.SUPPORTS,
    enableCallByReference = Constants.Bool.TRUE,
    type = Session.SessionType.STATELESS,
    transTimeoutSeconds = "0",
    initialBeansInFreePool = "0",
    maxBeansInFreePool = "20")
    Methods
    @RemoteMethod() public boolean getUserList(String adminGroup) {
    Map usrList = getUserList(adminGroup);
    Private Map getUserList(String adminGroup) {
         return SessionBean2.getUsers(adminGroup);
    SessonBean2
    @Session(defaultTransaction = Constants.TransactionAttribute.SUPPORTS,
    enableCallByReference = Constants.Bool.TRUE,
    type = Session.SessionType.STATELESS,
    transTimeoutSeconds = "0",
    initialBeansInFreePool = "3",
    maxBeansInFreePool = "20")
    Method
    @RemoteMethod() public Map getUsers(String adminGroup) throws RemoteException {
    return javaUtilClass.getUsers(adminGroup);
    JavaUtilClass
    Method
    public Map getUsers(String adminGroup) throws RemoteException {
         // This is where the work happens, calling the Authentication server to get a complete
         // list of users for an admin group. When the user list is around 1500 entries, this can
         // take an hour. Did I mention this server is very slow? It’s about this threshold of 1500
         // that causes the timeout.
         return Map of users
    First thought, just bump the idle-timeout-seconds setting for the session beans (from the default 600), but that would be a temporary solution until the user list grew larger.
    Second thought, refactor the call to the Authentication Server API to get the user list in blocks of data (say 400 at a time) and decreasing the call/response time between the method getUsers and the API call. This would still occur in the JavaUtilClass, so I am unsure this would make a difference. The session beans would still be idle and subject to timeout, correct?
    Would setting initialBeansInFreePool to 1 in SessionBean1 make any difference?
    Or should I be looking at replicating the re-factored method from the JavaUtilClass in SessionBean1 where the user list is being used so that the API calls come back to it and keep it 'active'?
    Thanks for any advice you could give me on this.

    Hi
    regarding timeouts, there are two ways:
    1.- Changing the settings in the JTA WebLogic domain , called "Timeout Seconds". This will affect globally to all EJB deployed in the domain.
    or
    2.- Specified directly in the bean with a weblogic annotation, like this:
    @TransactionTimeoutSeconds(value = 300)I hope this will help you.
    Regards.
    Felipe

  • BI Bean and iPlanet server

    Hi,
    I am trying to deploy BI Bean on iPlanet web server 6.0 The beans work within jDeveloper (using embedded OC4Jserver) and I am able to view the output in IE. But when I deploy to the web server, I get BIB exception. I assumed the config file refered to in error is the connection XML file which is also deployed. Can anyone help? Thanks. Here is the exception.
    Platform:
    MS Windows 2K
    Oracle 9i 9.0.2
    Jdeveloper 9i Rel.2
    [18/Sep/2002:13:00:11] info ( 1460): oracle.dss.appmodule.client.BISessionException: BIB-1004 No configuration file specified or specified configuration file cannot be found.
    at oracle.dss.appmodule.client.BISession.connect(BISession.java:422)
    at oracle.dss.addins.jspTags.BIThinSession.setupObjectFactory(BIThinSession.java:249)
    at oracle.dss.addins.jspTags.BIThinSession.getMetadataManager(BIThinSession.java:199)
    at oracle.dss.addins.jspTags.BIThinSession.getQueryManager(BIThinSession.java:226)
    at oracle.dss.addins.jspTags.BIThinSession.loadView(BIThinSession.java:126)
    at oracle.dss.addins.jspTags.PresentationTag.createThinObject(PresentationTag.java:142)
    at oracle.dss.addins.jspTags.BIBaseTag.getThinObject(BIBaseTag.java:76)
    at oracle.dss.addins.jspTags.PresentationTag.doStartTag(PresentationTag.java:225)
    at jsps.cweb._viewerJSP_jsp._jspService(_viewerJSP_jsp.java:107)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:897)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:464)
    [18/Sep/2002:13:00:11] config ( 1460): [Loaded oracle.dss.util.BIExceptionSupport$Enumerator]
    [18/Sep/2002:13:00:11] failure ( 1460): Internal error: servlet service function had thrown ServletException (uri=/cweb/viewerJSP.jsp): javax.servlet.ServletException: BIB-1004 No configuration file specified or specified configuration file cannot be found.
    , stack: javax.servlet.ServletException: BIB-1004 No configuration file specified or specified configuration file cannot be found.
    at jsps.cweb._viewerJSP_jsp._jspService(_viewerJSP_jsp.java:41)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:897)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:464)
    , root cause: javax.servlet.jsp.JspException: BIB-1004 No configuration file specified or specified configuration file cannot be found.
    at jsps.cweb._viewerJSP_jsp._jspService(_viewerJSP_jsp.java:67)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.iplanet.server.http.servlet.NSServletRunner.invokeServletService(NSServletRunner.java:897)
    at com.iplanet.server.http.servlet.NSServletRunner.Service(NSServletRunner.java:464)
    ***********************************************

    You will want to post this question on the following more appropriate forum:
    Products > Developer Suite > BI Beans
    However, after reading the error message please make sure that the configuration file is indeed deployed along with BI Beans application classes to the WEB-INF/classes directory. WEB-INF/classes should be there in all J2EE compliant servers.

Maybe you are looking for

  • Planned cost & actual cost are same in process order.

    hi, I have created new order type for process order. when i made process order & i  going for  confirmation in cor6n , on screen fixed & variable overheads values are coming which system had taken from receipe. when i did changes in that values which

  • Error:  cannot read:  HelloApp.java

    Having written the HelloApp.java file and placed it in the bin with javac.exe, I can't seem to get it to compile. Use of the files from the demos directory doesn't work either, same error. I assume the path is set up okay since javac runs, so can you

  • Adobe photoshop cs5 extended always asks me for a serial key every time i open it.pls help

    pls help

  • Slow Computer

    Ok...so my MacBook is less than six months old, and it started becoming increasingly slow. It would take over 30 seconds to start an application, and the F12 button would take atleast 1 minute to actually start. So I took it to the Apple store, and t

  • 100$ gift card usage

    I got the card printed out and stuff but I have absolutely no idea where I have to type it in so I can use it online on the apple store. Im sorry if this is in the wrong question i just need this answered quickly