Lose alredy created session bean

Hi all!
I have a problem with useBean and session. I use a OrderCartBean and this object contain an
ArrayList of OrdeBeans. I can add an OrderBean to OrderCartBean ArrayList. But next time I try to add an OrderBean to same OrderCartBean's ArrayList it does not work.
The problem is that I don't use the same OrderCartBean from session. The jsp-page seems to create a new
OrderCartBean instead of using the one in session and put the next OrderBean to the new OrderCartBean ArrayList
I looked around in many pages on the internet but i can't see what i'm doing wrong?
Thanx in advance...
Here is my code:
ode]
[orderCart.jsp]
<jsp:useBean id="orderCart" scope="session" class="bean.OrderCart"/>
<html>
<body>
<form method="post" name="order" action="orderCart.jsp">
<table border=0 cellspacing=2 cellpadding=5 width=400>
<input name="action" type="hidden" value="addItemToOrder" />
<tr>
<td><label>Art.no</label>
<input type="text" name="artNo"></td>
<td><label>Name</label>
<input type="text" name="artName"></td>
<td><label>Quantity</label>
<input type="text" name="quantity" size="4"></td>
</tr>
<tr>
<td colspan=2 align=left><input type="submit" value="Add to order" name="AddValue"></td>
</tr>
<%
     String action = request.getParameter("action");
     if (action != null && action.equals("addItemToOrder")) {
     //Set values to OrderBean
%>
<jsp:useBean id="order" class="com.easy.bean.Order" scope="request" />
<jsp:setProperty name="order" property="*" />
<%
     //I got different orderCart every time. Not the same from session?
     System.out.println(orderCart);
     //Add order to OrderCart ArrayList
     orderCart.addOrderToArray(order);
     //Get orders from OrderCart array
     Iterator iter = orderCart.getOrderArr().iterator();
     while(iter.hasNext()){
     com.easy.bean.Order tmpOrder = (com.easy.bean.Order)iter.next();
%>
<tr>
<td><B>Art.no.</B></td>
<td><B>Name</B></td>
<td><B>Antal</B></td>
</tr>
<tr>
<td><%=tmpOrder.getArtNo()%></td>
<td><%=tmpOrder.getArtName()%></td>
<td><%=tmpOrder.getQuantity()%></td>
</tr>
<%}%>
</table>
</form>
</body>
</html>
[OrderCart.java]
package com.easy.bean;
import java.util.ArrayList;
public class OrderCart {
ArrayList<Order> orderArr = new ArrayList<Order>();
public OrderCart() {}
public ArrayList<Order> getOrderArr() {return this.orderArr;}
public void setOrderArr(ArrayList<Order> orderArr) {this.orderArr = orderArr;}
public void addOrderToArray(Order order) {this.orderArr.add(order);     }
public void removeOrderFromArray(Order order) {     this.orderArr.remove(order);}
[Order.java]
package com.easy.bean;
public class Order {
int artNo;
int quantity;
String artName;
public Order() {}
public String getArtName() {return this.artName;}
public void setArtName(String artName) {this.artName = artName;}
public int getArtNo() {     return this.artNo;}
public void setArtNo(int artNo) {this.artNo = artNo;}
public int getQuantity() {return this.quantity;}
public void setQuantity(int quantity) {this.quantity = quantity;}

So a stateless bean could hold the value of the key throughout its lifetime and each separate method call would have access to it?

Similar Messages

  • Error when Create Session Bean in JDeveloper

    Hi All,
    I followed the steps in the SRDemo tutorial to create Session bean SRPublicFacade. I used Create Session Bean wizard. Step 1 was ok. Step 2 when it's supposed to show all the POJOs and all methods (from Queries) it hang there, and skipped to Step 3 and so on... As a result I had an empty Session Bean with only class name and no methods in it. I do have correct database connection, and I have another project with similar Session Bean sucessfully. I just don't know what happened to this project or the way I created session bean this time. Any conflict when create Session Bean to the same database or something(?) Anyone has any idea please let me know.
    Thank you very much,
    John

    Frank,
    Yes, I compiled the project before building the session facade. I used JDeveloper 10.1.3.3.0
    The thing is I once created successfully the session facade in another project, like SRdemo. Now I would like to repeat that in another project say SRdemo2, then it went wrong. It skipped step 2 in the wizard and look like it cannot detect the tables and named queries.
    Thanks,
    John

  • Create session bean using interfaces, not implementation classes

    Hi,
    I'm using interfaces and session beans for my persistence/data layer in my adf application.
    I've created a data control for my session bean and during creation of this data control, javabean.xml files are created for the different interfaces that are used in my session bean.
    If I create bindings on these methods, interfaces in jspx-documents I will get errors because he can't find the impl-classes that implement these interfaces.
    When using interfaces in your session bean (as return values or parameters) instead of classes you need to manually create javabean.xml files for the implementation classes.
    It's required by the databindings/datacontrol that the implementation-classes are described in a javabean-format as well? Is this a spec we need to adhere to?
    Could someone verify that you need to create javabean.xml-files for as well the interfaces as the classes when you're working with interfaces in your session beans?
    regards,
    Nathalie

    A patch was released by Oracle to be able to work with Interfaces and so it's not required to work with implementation-classes.
    Patch for 5726754(Base bug 5657179)

  • Creating Session Bean Facade Methods Off EJB QL

    Hello,
    I'm trying to follow the documentation for creating a Session Bean that has facade methods for various Entity Beans. When I add a named query:
    @NamedQuery(name = "Debtor.findDebtorById", query = "select o from Debtor o where o.debtorId = ?1")
    I end up with the following facade method:
    /** <code>select object(o) from Debtor o where o.DEBTOR_ID = ?1</code> */
    public List<Debtor> queryDebtorFindDebtorById(Object p1) {
    return em.createNamedQuery("Debtor.findDebtorById").setParameter(0, p1).getResultList();
    I see two issues here:
    1) The type of the input parameter is supposed to be a long, as the Entity Bean field looks like:
    @Id
    @Column(name="DEBTOR_ID", nullable = false)
    private Long debtorId;
    2) The parameter being set is '0' instead of '1'.
    Is there a known issue with generating this code in JDev? Or am I doing something wrong?

    another strange problem.
    i have an APplication server added ( JBOSS ).
    when i create deployment profile (EAR ) application server is showed in the ComboBox .
    But when i create Java Test Client for some EJB and when i check " Connect Remote Application server" there is 2 comboboxes
    J2EE Application
    App Server Connection.
    first combo is ok there is EJB applicaiton
    Secound is empty .. but i Have App Server.
    Another think is that when i create EJB 3.0 its BAD to see J2EE app it must be J EE 5 app or just Java EE app

  • I have got problem to create Session Bean

    Hi
    I am new in j2ee. I have installed the eclipse 3.1, j2sdk1.4.2_07 and tomcat 5.0. I have created a ejb with a session bean and it gives me a error the program doesn't find the class javax.ejb.SessionBean. My question is Can this error happen because I don't have installed J2EE 1.4 SDK and Sun Java System Application Server Platform Edition 8.1?
    thank you

    Hi
    I have tried to put the classpath with j2ee in eclipse but it happens the same. it doesn't find the package javax.ejb.SessionBean.
    I am going to explain i have done from the beginning. Maybe I am wrong in something. I think which is that.
    I have create a proyect with Dynamic Web Proyect after i create a proyect with ejbModule. I attempt to create a file with session bean. In last proyect acceded to Run->Run here i select Apache Tomcat and Tomcat v5.0 Server _ localhost and i select the classpath in "bootstrap entries" i insert the file j2ee.jar. And I' ve got the same error.
    is it fine? I am bored trying to find the problem.
    thanks in advanced

  • Question about the Create Session Bean Wizard

    Hi,
    I'm using the Session Bean Wizard to generate a session facade in EJB 3.0. In step 2 «choose methods to expose through this facade», I only see 2 methods generated for each entity: findAll and remove.
    When I click Help on this page, the documentation specify the following:
    «Use the tree control to specify the core methods and entity methods you want to generate. Core Facade Methods Theese methods are used for basic CRUD (create, read, update, delete) functionality. »
    So why is the wizard only offering to generate findAll and remove?
    Also the remove method generated does not seem to delete anything as in the following :
    public void removeDcaRole(DcaRole dcaRole) {
    final EntityManager em = getEntityManager();
    try {
    final EntityTransaction et = em.getTransaction();
    try {
    et.begin();
    dcaRole = em.find(DcaRole.class, new DcaRolePK(dcaRole.getDcaNo(), dcaRole.getTRoleCode()));
    et.commit(); // where is the delete ???
    } finally {
    if (et != null && et.isActive()) {
    et.rollback();
    } finally {
    if (em != null && em.isOpen()) {
    em.close();
    Can I use the remove method as a starting point to an update ?
    Any comment on this would be appreciated.

    There are update and insert methods under the "core" section/
    See this image : http://www.oracle.com/technology/obe/obe1013jdev/10131/10131_ejb_30/images/b20105.gif
    You might want to follow this tutorial to see how it works:
    http://www.oracle.com/technology/obe/obe1013jdev/10131/10131_ejb_30/ejb_30.htm#t4

  • Help creating session bean

    Hi, I am trying to create a stateful session bean which connects to a database and returns the result set from a table. Can you please give me some steps to 1. How to create a stateful session bean 2. How to connect to a database 3.write a query 4. Display the result set 4. How to deploy it on the EJB server. It will be very helpful for me if there is any example. Thanks.

    Return types and parameters types of an EJB mothod must implement java.io.Serializable interface, and java.sql.ResultSet doesn't implements this interface.So you cant use it as an EJB method's return type.
    Fil

  • Creating and deploying ejb 3.0 session bean with annotated pojo

    I try to create and deploy a EJB 3.0 stateless session bean (and associated webservice) with the following steps:
    1) Create Interface "Repository"
    package de.xxx.config;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import javax.jws.WebMethod;
    import javax.jws.WebService;
    @WebService
    public interface Repository extends Remote {
         @WebMethod(operationName = "findCampaignByChannel")
         public String findCampaignByChannel(String channelName) throws RemoteException;
    2) create dummy "RepositoryImpl"
    package de.xxx.config;
    import java.rmi.RemoteException;
    import javax.ejb.Stateless;
    import javax.jws.WebService;
    @WebService(endpointInterface="de.xxx.config.Repository")
    @Stateless
    public class RepositoryImpl implements Repository {
         public String findCampaignByChannel(String channelName) throws RemoteException {
              return null;
    3) The two class files are packaged into a jar without any further descriptors
    4) The jar is deployed with admin_client into the oc4j instance using the commands:
    -deploy -file <jarfile> -deploymentName <name>
    Result:
    An ear was constructed and started but no session bean or webservice is found (using the console). But according to to the docs a jar file without a ejb-jar.xml should be recognized as a EJB 3.0 ejb-jar file and the necessary steps to create session bean and expose webservice should be done automatically.
    My question:
    Which step do i miss here ?
    Tools used:
    Eclipse 3.2 for the jar file
    SoaSuite 10.1.3.1 for oc4j

    another strange problem.
    i have an APplication server added ( JBOSS ).
    when i create deployment profile (EAR ) application server is showed in the ComboBox .
    But when i create Java Test Client for some EJB and when i check " Connect Remote Application server" there is 2 comboboxes
    J2EE Application
    App Server Connection.
    first combo is ok there is EJB applicaiton
    Secound is empty .. but i Have App Server.
    Another think is that when i create EJB 3.0 its BAD to see J2EE app it must be J EE 5 app or just Java EE app

  • Creation of session bean

    Hi all,
    I am trying to create a DC webservice, while creating the stateless session bean in package, I am getting the error "Not able to create session bean".
    How can I solve this issue?
    Basically the problem is with the ejb-jar.xml.
    Thanks
    Vivek

    Hi Sriram,
    I have created another webservice locally and in that I am able to create the session bean. I am getting the problem only while creating the bean in the EJB module in DC.
    Thanks
    Vivek

  • Problem when running session bean

    Hi all,
    I am a new comer to jdeveloper11g and weblogic10.In these days i am trying to create session bean in jdeveloper. but i got this error when i am try to run the program using new sample client.
    mapped name=New-SessionEJB
    package=project1
    Remote interface=NewSession
    SessionBean=NewSessionBean
    javax.naming.NameNotFoundException: While trying to lookup 'New-SessionEJB#project1.NewSession' didn't find subcontext 'New-SessionEJB#project1'. Resolved '' [Root exception is javax.naming.NameNotFoundException: While trying to lookup 'New-SessionEJB#project1.NewSession' didn't find subcontext 'New-SessionEJB#project1'. Resolved '']; remaining name 'New-SessionEJB#project1/NewSession'
         at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:234)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
         at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
         at weblogic.jndi.internal.ServerNamingNode_1030_WLStub.lookup(Unknown Source)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:392)
         at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:380)
         at javax.naming.InitialContext.lookup(InitialContext.java:392)
         at project1.NewSessionClient.main(NewSessionClient.java:16)
    Caused by: javax.naming.NameNotFoundException: While trying to lookup 'New-SessionEJB#project1.NewSession' didn't find subcontext 'New-SessionEJB#project1'. Resolved ''
         at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:1139)
         at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:247)
         at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:182)
         at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:206)
         at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:589)
         at weblogic.rmi.cluster.ClusterableServerRef.invoke(ClusterableServerRef.java:230)
         at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:477)
         at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
         at weblogic.security.service.SecurityManager.runAs(Unknown Source)
         at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:473)
         at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Process exited with exit code 0.
    Here is my client program
    public class NewSessionClient {
    public static void main(String [] args) {
    try {
    final Context context = getInitialContext();
    NewSession newSession = (NewSession)context.lookup("New-SessionEJB#project1.NewSession");
    } catch (Exception ex) {
    ex.printStackTrace();
    private static Context getInitialContext() throws NamingException {
    Hashtable env = new Hashtable();
    // WebLogic Server 10.x connection details
    env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
    env.put(Context.PROVIDER_URL, "t3://localhost:7101");
    return new InitialContext( env );
    If anybody know what the problem is please tell me.
    thanks.......
    (tcr)

    I ran into the EXACT same problem described by Tracy, and I assembled my .ear file manually.
    According the error message, it would appear that the server is looking for the EJB remote interface in the ../temp/__session_bean_rpc directory when it is trying to generate its session bean wrapper class. As Tracy notes, when the file Hello.class is copied into the directory, the problem goes away. Furthermore, once the wrapper class has been generated, Hello.class is no longer needed and can be deleted from the directory.
    Better still, I found a way to deploy the web services web module and make the error go away. I created the ejbws.war file with a copy of the remote interface Hello.class in the WEB-INF/classes directory. This makes the class available when the wrapper class is generated.
    The WebServicesAssembler tool doesn't copy the EJB remote interfaces into the .war web module, which would appear to be
    necessary.
    Hope this helps.

  • Need urgent help: how to avoid concurrent calls on statefull session beans

    Hi,
    I need a little advice in designing a EJB session facade using JSPs, servlets, session and
    entity beans.
    My current design is:
    - JSP pages: here are only getMethods for the session bean used. All set-methods are handled by a
    - servlet: I have got one servlet handling several JSP pages. The servlet basically takes the
    form fields and stores them in the session bean and than dispatches to the next JSP-page
    - stateful session bean: here is, where all the business logic is conducted. There is one session
    bean per servlet using several
    - CMP entity beans: to talk to the database (Oracle 8i)
    The application server is JBoss 3.0.3.
    My problem is, if a user clicks on a submit button of a JSP page more than once before the next
    page builds up, I may get a "javax.ejb.EJBException: Application Error: no concurrent calls on
    stateful beans" error. I already synchronized (by the "session") the code in the servlet, but
    it happens in the JSP pages as well.
    I know, that Weblogic is able to handle concurrent calls, by JBoss isn't and it's clearly stated
    in the spec, that a user should avoid to have concurrent calls to a stateful bean.
    The big question is now: How can I avoid this? How can I prohibit the user to submit a form several
    times or to ignore anything, which arrives after the first submit?
    Thanks for any help,
    Thorsten.

    Synchronizing on the session is probably your best bet.
    You'll need to do all the data access and manipulation in the servlet. Cache any data you need using request.setAttribute() and then not access the EJB on the JSP page.
    If performance is an issue, you may also want to use create a user transaction to wrap all the EJB access in, otherwise each EJB call from the servlet is a new transaction. Just make sure you use a finally block to properly commit/rollback the transaction before you redirect to the JSP.
    UserTransaction utx    = null;
    synchronized (request.getSession())
      try {
        Context ctx = new InitialContext();
        utx = (UserTransaction) ctx.lookup("javax/transaction/UserTransaction");
        utx.begin();
        // ... Create session bean ...
        request.setAttribute("mydata", sessionBean.getMyData());
        try {
          utx.commit();
        catch (Exception ex) {
          log.warn("Transaction Rolled Back (" + ex.getClass().getName() + "): "
            + ex.getMessage(), ex);
        utx = null;
      } // try
      finally {
        if(utx != null)
          try {
            utx.rollback();
          catch (Exception e) {
            log.warn(e.getMessage(), e);
          } // catch
        } // if
      } // finally
    } // syncrhonized(session)

  • JDeveloper 10.1.3 EA 1 Session Bean Problems

    Hello,
    it seems there are some problems in JDeveloper 10.1.3 EA1 related to Session EJBs:
    1) The Create Session Bean Wizard doesn't work correctly. After finishing the Wizard, JDeveloper only creates the ejb-jar.xml and orion-ejb-jar.xml, but not the Session EJB classes/interfaces themselves (Bean, Remote, Home). So I had to develop the Session Bean in JDeveloper 10.1.3 Developer Preview. That worked fine. I finally migrated the project to 10.1.3 EA1.
    2) When I try to run my JSF/EJB application with the Session Bean in 10.1.3 EA1, the following error occurred:
    05/10/24 17:31:15 Error instantiating application 'current-workspace-app' at file: <a file path>...oc4j-app.xml:
    Error initializing ejb-modules:
    Error loading module file: <a file path>.../Model/classes/:
    Syntax error in source or compilation failed in:
    <a file path>...\Software\JDeveloper\jdevj2eebase1013\jdev\system\oracle.j2ee.10.1.3.34.12\embedded-oc4j\application-deployments\current-workspace-app\Umfragesystem02_Model_0\generated\CommandHandlerSession_StatelessSessionBeanWrapper0.java
    I have no idea how to solve this problem. Does anybody have a solution?
    Regards,
    Matthias

    Tested Session Bean and Entity Bean.<br>
    The bean class and the deployment descriptors get<br>
    generated.<br>
    The remote/local, home/local home interfaces do not<br>
    get generated.<br><br>
    Thanks. The Session Bean Creation Wizard problem is a problem I could solve using a workaround. But the problem that really stems me is the error I receive when I try to run my webapp using the Session Bean and some more classes and JavaServer Faces files:<br>
    <br>
    Error instantiating application 'current-workspace-app' at file: ...oc4j-app.xml: <br>Error initializing ejb-modules: <br>
    Error loading module file: .../Model/classes/: <br>
    Syntax error in source or compilation failed in:<br> ...\Software\JDeveloper\jdevj2eebase1013\jdev\system\oracle.j2ee.10.1.3.34.12\embedded-oc4j\application-deployments\current-workspace-app\Umfragesystem02_Model_0\generated\CommandHandlerSession_StatelessSessionBeanWrapper0.java <br>
    <br>
    What goes wrong with JDeveloper or the application?

  • Desperate!! Netbeans and Configuring Session Beans

    Hello,
    I have been put on a project to port our application to EJBs. I have decided to check out NetBeans. How do I create Session Beans in Netbeans. ? How do I configure that the session beans state, transaction type, component interfaces etc.? Does Netbeans not come with some wizard to do this ? I have tried the netbeans forums, mailing lists, docs etc but nothing. I am developing using JBoss 3.0.
    Oh please help me. I need to figure this out soon.
    Thanks you so much.
    Joyce

    Netbeans (as downloaded) does NOT support EJB development. There are many others that do - both paid-for and for varying definitions of "free."

  • Using only one method in session bean to create web service

    Hi all,
    I hhave a scenario where i am inserting and retrieving data from dict table using web service.
    For this i have created a session bean and a wrapper class.
    The session bean has two methods: insertRecords(), and viewRec().
    so while creating a web service i need to include two methods.
    I want to have only one method where i can pass a parameter as operation and if it is "I", then i can call the insert method and if it is "S" i can call view method.
    I tried doing that bt i am stuck up with the return type.
    Insert method has return type as array of wrapper class and
    view method has wrapper class as return type ...
    Is this scenario possible..??
    or is there any other way to do this???
    Plz let me knw..
    Thankls n regards,
    Ankita

    Hi Siddharth,
    Im really sorry..
    i cudnt  get u ..
    Actually these r methods:
    public DemoDicModel[] viewRecords()
    and
    public DemoDicModel insertRecords(
              String title,
              String desc,
              String status)
    and im trying this:
    public DemoDicModel[] getMethods(String operation,String title,String desc, String st)
    DemoDicModel[] demoModel =null;
    DemoDicModel model = new DemoDicModel();
    if(operation == "show")
          demoModel = viewRecords();
    if(operation == "ins")
          model = insertRecords(title,desc,st);
          model.setMsg("RECORDS GENERATED");
          demoModel=
    return demoModel;
    im stuck up with insert operation.
    can  u plz explain me in detail.
    thanks,
    ankita

  • Creating EJB 3.0 Session Bean under JDeveloper 10g.

    Hello im using JDeveloper 10 g all up 2 date.
    when i create EJB 2.x EJB everythink is ok .. there is a Wizzard(Designer) from which i can add methods variables and etc.
    all methods are become added to the session bean / remote interefeis etc.
    My Problem is when i create EJB 3.0
    when i do it the Bean class is created and the Remote interfeis with @remote is created too its ok BUT I CANT see Remote interfeis in my Application Naviagation its fine under 2.1 i cannot see remote interfeis and home interfeis too but inder 2.1 there is a wizzard(Designer) under 3.0 there is nothink.
    what am i wrong ? how can i make designer to work under 3.0 or how can i make Jdeveloper to show me all content of the EJBs

    another strange problem.
    i have an APplication server added ( JBOSS ).
    when i create deployment profile (EAR ) application server is showed in the ComboBox .
    But when i create Java Test Client for some EJB and when i check " Connect Remote Application server" there is 2 comboboxes
    J2EE Application
    App Server Connection.
    first combo is ok there is EJB applicaiton
    Secound is empty .. but i Have App Server.
    Another think is that when i create EJB 3.0 its BAD to see J2EE app it must be J EE 5 app or just Java EE app

Maybe you are looking for