Session bean behaves as ask the Bean

Hello, I met this stange behavior in my Application (JDeveloper 10.1.3.3).
I have a jsp page that contains an element of SelectOneChoice:

+ < af:selectOneChoice inlineStyle = "margin: 10.0pt +;
autoSubmit = "true" simple = "false".
unselectedLabel = "sΘlectionner".
+ Binding = "#{backing_page.versionsSelectOne}" +.
+ id = 'Refresh' label = 'Versions' / > +.

As you can see, this article is bound to a field in the bean of support for this page (which we will call the)
Bean "PageBean"). The binding object is:

+ private CoreSelectOneChoice versionsSelectOne; +

"PageBean" is a session, stated in faces - config.xml bean:

+ < managed-bean > +.
+ < managed-bean-name > backing_page < / managed-bean-name > +.
+ < managed-bean-class > mypackage. PageBean < / managed-bean-class > +.
+ session < managed-bean-scope > < / managed-bean-scope > +.
+ < / managed-bean > +.

In the constructor of 'PageBean', I create a new Istance of the component:

+ Application apps = FacesContext.getCurrentInstance () .getApplication (); +
+ versionsSelectOne = (CoreSelectOneChoice) apps.createComponent (CoreSelectOneChoice.COMPONENT_TYPE); +

The bean of support (in a method called by a button), I dynamically fill the CoreSelectOneChoice with the
components (CoreSelectItem) I want to display in the drop-down list.

Everything works fine BUT the "PageBean' is now recreated to * each request * (despite that it is a * Session * Bean).
If I remove the CoreSelectOneChoice creation in the costructor, it still behaves like a Sesison Bean.
This behavior is very strange, and it seems to be somehow connected to the CoreSelectOneChoice component.
even if I see no Exception in my application.
Does anyone have an idea on what is happening?

Hi Antonio,.

>
(1) usually when I create a page, I can creata a support for the page bean. Can I keep the information contained in
the bean for 4 different extended (zero, request, session, application), let'say that I am interested in session and demand.
I thought that the components of support where like that, and JDev encourage to put then in a backing bean
using "automatically expose UI components in a new Managed Bean. So my idea of a support of the bean internally who can manage the
components of the user interface on the session's not going, and I have to do a new design for this application...
Well, JDeveloper is incredibly bad on this part, so why this option is not hidden and disabled by default in 11g, unlike the step of creating the standard and active in 10 g. Normally, you very rarely use the JSF binding attribute unless the refresh PPR component, allows you to wire the values in place like EL:





// The classes
public class MyDataBean
{
    private String name;

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }
}

public class MyControllerBean
{
    private MyDataBean data;

    public String save()
    {
        // Call the model layer to save the data in MyDataBean
        return "success";
    }

    public MyDataBean getData()
    {
        return data;
    }

    public void setData(MyDataBean data)
    {
        this.data = data;
    }
}



  data
  MyDataBean
  session


  controller
  MyControllerBean
  request
  
    
    MyDataBean
    #{data}
  

(2) I'm not here. If the component (for example CoreSelectOneChoice) class is not a managed bean of JSF,.
How can we instantiate frame it? In any case, I had a nullpointexception if I try to set a property of the
component (CoreSelectOneChoice) in the bean to support, without the first instantiation of it.
You must set the properties in the binding Set accessor method:

public class BackingBean
{
    private CoreSelectOneChoice choice;

    public CoreSelectOneChoice getChoice()
    {
        return null; // safer than returning choice in case 2 pages binds on the same bean
    }

   public void setChoice(CoreSelectOneChoice choice)
   {
       this.choice = choice;
       this.choice.setLabel("Foo"); // Here, in the setter, NOT in the constructor so JSF instantiate the component, not you.
   }
}

(3) ok I can do it by hand, but it reminds me of something that it is done automatically by spring.
Thanks for your reply.
JSF 2.0 and JSR-299 allow injection using the annotation, but Spring does not automatically, you must configure the spring to do, same goes for the JSF.

Kind regards

~ Simon

Tags: Java

Similar Questions

  • To access the Session Bean?

    Hello

    With the help of Jdev 11.1.1.7.0. mrequirement is I need to access session Bean on the Module of the Application.


    so I use this way in my implementation of the application module class .

    SessionBeanClassName sessionBeanClassObject is JsfUtils.getManagedBean ("recorded in the adfc-config sessionBeanName").

    I can able to access via the module of the application.

    My question is:

    1. is this good sense?

    2. No Impact on this approach?

    3. is this a good practice?

    4 is one way to access the variable from Session Bean on the application module.

    Thank you.

    Q2) the impact is that you break the mvc pattern and therefore the model of coupling to the display. Later, this can be a problem because your application doesn't fit. Add pass you ui state model (am) you might encounter problems when querying comes into play.

    Sample of Q4) Chris did not access to a bean in scope session leave an application module, but how to get there from an another view layer bean.

    Joel Ramamoorthy-Oracle and Cvele_new_account and myself you asked before, without a real use case all we can say is: don't access scope the model layer session bean.

    Timo

  • [ADF, JDev12.1.3] Scope of session bean: it can contain attributes related to the Value property of user interface components?

    Hallo,

    I have a defined session bean in which I put a string attribute that is bound to the Value property of an InputText in my testPage.

    public class SessionClass {
    
      private String text;
    
      public void setText(String text) {
        this.text = text;
      }
    
      public String getText() {
        return text;
      }
    }
    

    When I run the testPage, it is not displayed.

    Perhaps this kind of linking is not possible?

    Thank you

    Federico

    Never use prefix in scope to the standard servlet scopes (request, session, application)

    So it would be: #{sessionClass.text}

    Dario

  • Error during the generation of session bean

    Hi all

    EPCO: 12.1.1.1.0

    I created the entities JPA through the Assistant of "JPA entities from Tables" for employees and departments.
    Now, I want to create the bean in session using the Wizard "Session Bean of JPA entities.
    I give it a name and select all of the available features and click on "Finish". Then I got the following error:
    Error running the session bean generation task.
    In the console error log, I see the following:
    org.eclipse.core.commands.ExecutionException: 
         at oracle.eclipse.tools.webtier.ui.wizards.existing.EJBProjectFromExistingDataModelOperation.execute(EJBProjectFromExistingDataModelOperation.java:67)
         at oracle.eclipse.tools.adf.view.ui.internal.wizard.datamodel.NewSessionBeanFromEntitiesWizard.addEJBFacetOperation(NewSessionBeanFromEntitiesWizard.java:249)
         at oracle.eclipse.tools.adf.view.ui.internal.wizard.datamodel.NewSessionBeanFromEntitiesWizard.createNewServiceDefnAndGenBeans(NewSessionBeanFromEntitiesWizard.java:219)
         at oracle.eclipse.tools.adf.view.ui.internal.wizard.datamodel.NewSessionBeanFromEntitiesWizard.doFinish(NewSessionBeanFromEntitiesWizard.java:169)
         at oracle.eclipse.tools.adf.view.ui.internal.wizard.datamodel.NewSessionBeanFromEntitiesWizard.access$0(NewSessionBeanFromEntitiesWizard.java:160)
         at oracle.eclipse.tools.adf.view.ui.internal.wizard.datamodel.NewSessionBeanFromEntitiesWizard$1.run(NewSessionBeanFromEntitiesWizard.java:133)
         at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
    Caused by: org.eclipse.core.runtime.CoreException: 
         at oracle.eclipse.tools.webtier.ui.wizards.existing.EJBProjectConverter.convert(EJBProjectConverter.java:281)
         at oracle.eclipse.tools.webtier.ui.wizards.existing.EJBProjectFromExistingDataModelOperation.execute(EJBProjectFromExistingDataModelOperation.java:61)
         ... 6 more
    Caused by: java.lang.NullPointerException
         at org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider.hasValidRuntime(J2EEModuleFacetInstallDataModelProvider.java:213)
         at org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider.propertySet(J2EEModuleFacetInstallDataModelProvider.java:162)
         at org.eclipse.jst.j2ee.internal.ejb.project.operations.EjbFacetInstallDataModelProvider.propertySet(EjbFacetInstallDataModelProvider.java:137)
         at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelImpl.internalSetProperty(DataModelImpl.java:182)
         at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelImpl.setProperty(DataModelImpl.java:172)
         at org.eclipse.wst.common.frameworks.internal.datamodel.DataModelImpl.setStringProperty(DataModelImpl.java:201)
         at oracle.eclipse.tools.webtier.ui.wizards.existing.EJBProjectConverter.convert(EJBProjectConverter.java:126)
         at oracle.eclipse.tools.webtier.ui.wizards.existing.EJBProjectConverter.convert(EJBProjectConverter.java:273)
         ... 7 more
    Anyone has any idea what happened and how can I fix?

    Thank you in advance.

    Filip Huysmans.

    To work around this problem, follow these steps:
    -On the model JPA project
    RT - click on, and then select Properties
    -Select project facets
    -Unlock and deselect the facet utility Module
    -Select the facet of the EJB Module and Oracle WebLogic EJB Extensions

    Your project must be ready to perform the given operation.

  • Failed to retrieve the scope session bean

    Hello
    I'm working on JDeveloper 11.1.1.6.0.

    I use a session bean extended for the storage of information about the logged-on user. I have a page and a reading of the data of this extended session bean managed bean. It works very well. But now, I created another page also using the bean managed to read the data of the extended session bean. But he always returned null for the bean.

    Anyone has an idea why this might happen? It is not really clear to me why she is working with the first page and not with the second page, even when they both use the 'same' bean managed.

    Thanks in advance.
    Alex

    Alex,

    Kind of how convoluted to get a reference to a bean.

    Have you tried to create a managed property in the bean where is your code (set the value of the property #{SessionBean} in faces-config.) (XML)?

    John

  • How to set the session bean of backing bean variable

    Hi all -

    I have a bean with a session variable and I want to set the value of this variable to a bean of support. Could someone please suggest how to achieve this.

    I use ADF 11 g.

    Greetings-
    Rohit

    Hello

    First of all, you need get the referral of bean in the bean to support session, and call the method that sets the value of the attribute. Getting session bean reference - you can use dependency injection, which is the best way, but you must register your bean in faces-config. XML (not adfc - config.xml, see http://biemond.blogspot.com/2010/04/ejb-injection-in-jsf-managed-bean.html).
    An alternative is to search the session bean's JNDI.
    Third option involves data controls: you create a session bean data control and then expose the method to fix your attribute value, in the calling page to jspx pageDef. To do this, you can't use method that begins with 'set', because you will not be able to exhibit in the pageDef (at least not with the Visual Editor). Then, you can call this method from the bean to support using this code:

            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            OperationBinding operationBinding = bindings.getOperationBinding("yourSessionBeanMethodExposedInPageDef");
            operationBinding.execute();
    

    I hope this helps.
    Pedja

  • Why the method in the several times called session bean

    Hello
    I work with Jdev 11 g.
    I created an example Web J2ee Application.
    In the model project, I created:
    1 - entity Bean
    2 - stateless session bean (which contains a method that get the list of username == > em.createNamedQuery("OsaUser.findAll").getResultList ();)

    In the view controller project I created:
    1 - managed bean, session scope, a getter that calls the session bean and retrieve the result of the query.
    2 - a JSF page with af:table element with the value bound to the list in the managed bean.

    When I run the application, the data is displayed, but since I put system.out message I get this message several times.
    When I try to debug the application the breakpoints on the managed bean and session bean are available several times.

    Can you please advice why this happens.
    Concerning
    Emile BITAR

    Hello

    partially, it's the cycle of life and partially a known bug. The method is called during ApplyRequest and RenderResponse. If you check this in your output, so you see that make answer calls at least three times, which is the bug that we set. As a temporary work around, set a flag within the scope of the request (since your bean's scope of session that you use a requestScope attribute). The first time you run, you set the attribute flag. So every time its called again, you check to see if the indicator exists and if ignore the request. Because the flag is set to request scope, you needn't clean it explicitly

    Frank

  • Jdev 11 g, error when you try to run the session bean

    Hello

    I created a session façade for my entity beans. I don't know what happened but when I try to launch it I get the error below. I restarted my computer.

    Someone has an idea?
    Thank you.


    Redeploy the Application...
    < 7 May 2009 22:27:22 CEST > < WARNING > < hats > < BEA-149124 > < failures have been detected all introducing deploy task for application 'wd_tickets '. Error is: "[Deployer: 149164] modification of domain lock belongs to another session in exclusive mode - where the deployment operation cannot continue." >
    weblogic.management.ManagementException: [Deployer: 149164] modification of domain lock belongs to another session in exclusive mode - where the deployment operation cannot take place.
    # Incomplete deployment. # May 7, 2009 16:27:23
    oracle.jdeveloper.deploy.DeployException
    at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:247)
    at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.deployImpl(Jsr88RemoteDeployer.java:157)
    at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
    at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
    at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
    at oracle.jdeveloper.deploy.common.BatchDeployer.deployImpl(BatchDeployer.java:82)
    at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
    at oracle.jdevimpl.deploy.fwk.WrappedDeployer.deployImpl(WrappedDeployer.java:39)
    at oracle.jdeveloper.deploy.common.AbstractDeployer.deploy(AbstractDeployer.java:94)
    at oracle.jdevimpl.deploy.fwk.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:436)
    at oracle.jdeveloper.deploy.DeploymentManager.deploy(DeploymentManager.java:209)
    at oracle.jdevimpl.runner.adrs.AdrsStarter$ $5 1.run(AdrsStarter.java:1365)
    Caused by: oracle.jdeveloper.deploy.DeployException
    at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.redeployApplications(Jsr88DeploymentHelper.java:561)
    at oracle.jdevimpl.deploy.weblogic.common.Jsr88WeblogicDeploymentHelper.redeployApplications(Jsr88WeblogicDeploymentHelper.java:259)
    at oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer.doDeploymentAction(Jsr88RemoteDeployer.java:222)
    ... 11 more
    Caused by: oracle.jdeveloper.deploy.DeployException: deployment failed
    at oracle.jdevimpl.deploy.common.Jsr88DeploymentHelper.redeployApplications(Jsr88DeploymentHelper.java:542)
    ... 13 more
    # Failed executing wd_tickets request because of the deployment error to DefaultServer.

    Published by: amcgator on May 7, 2009 13:38

    Once you start your weblogic Server

    Enter the URL: http://127.0.0.1:7101 / console

    username: weblogic
    password: weblogic

    hope this helps,

    Thank you

  • Session Bean vs Entity Bean?

    We have a contractor who joined us recently. He is our specialist in the ADF. We don't know much about ADF. He said the layer of data model in the ADF, he must choose between the session beans and entity beans. I am especially ignorant of these things and their implications. I come to know objects entity and visualization of objects from access DB. Can someone give me an idea of what these are? Why not just create entity objects and some objects view and link as I always see in the tutorials? I would ask him, but I'm eager to check what it says of a 3rd party because it seems that it may be misleading us.

    He wants to use Java Beans EJB (Enterprise), while you tell the ADF business components

    Entity Beans

    What is an entity bean?

    https://blogs.Oracle.com/Shay/entry/adf_business_components_or_top

  • [ADF, JDev12.1.3] viewScope bean can not recover sessionScope bean. Why? (How to day uploading of a session bean scope whenever a page with params is called)

    Hallo,

    to the login page of my application, I created a viewScope managed bean loginView.

    In the login page, I put a "dummy" inputText (whose value is related to dummyInitEditValue bean attr) to perform lazy loading of the page itself.

    In the initData() function I call a function of a bean sessionScope connection which should initlialize some of its attributes.

    public class LoginView {
      private Integer dummyInitEditValue;
    
      public LoginView() {
      }
    
      private void initData() {
        Login loginBean = (Login) FacesUtils.getManagedBeanInSession("login"); // loginBean = null !!!
        loginBean.initData();
        dummyInitEditValue = 1;
      }
    
      public void setDummyInitEditValue(Integer dummyInitEditValue) {
        this.dummyInitEditValue = dummyInitEditValue;
      }
    
      public Integer getDummyInitEditValue() {
        // Per lazy loading
        if (dummyInitEditValue == null)
          initData();
        return dummyInitEditValue;
      }
    }
    
    
    

    The problem is that the initData() rises a null pointer exception because the bean connection is not found.

    What's not in my approach?

    I create this hoping to resolve this issue: the login page has 2 URL parameters (defined in his point of view in the config.xml file - adfc) and I have according to them I need to update some of the bean sessionScope uploading connection every time the page is called / refreshes (possibly with new values for the parameters).

    BdW I do not know if there is a better alternative you can advice me.

    Thank you

    Federico

    Well, you need to instantiate bean connection somehow.

    You can try to link an attribute of connection bean to the page and see if this will help or you can try to resolve expression programmatically (something like #{connection}).

    Or you can try adding session bean defined as managed property for your bean view extended (something like this: http://umeshagarwal24.blogspot.ba/2012/09/using-managed-property-to-evaluate.html).

    Dario

  • Does container managed entity manager is thread-safe in stateless session bean?

    Hello

    I have read JEE6 doc and confused with

    Manager managed entity containing does (injected by PersistenceContext annotation) is thread-safe in bean of stateless session in env mutiple-thread?

    See code below, if there are 2 requests to stateless session bean in 2 concurrent threads, is it using the same Instance of the managing body or not?

    @Stateless (name = "HRFacade", mappedName = "HR_FACES_EJB_JPA-HRFacade-HRFacade")

    / public class HRFacadeBean implements HRFacade, HRFacadeLocal {}

    @Resource

    SessionContext sessionContext;

    @PersistenceContext (unitName = "HRFacade")

    Private EntityManager em;

    public places (places sites) persistLocations {}
    EM. Persist (rentals);
    return places;
    }

    public places (places sites) mergeLocations {}
    Return em.merge (rentals);
    }

    {} public void removeLocations (places sites)
    location = em.find (Locations.class, locations.getLocationId ());
    EM. Remove (rentals);
    }

    / * < code > o selection of the places where < code > * /.
    @TransactionAttribute (TransactionAttributeType.NOT_SUPPORTED)
    public list < location > getLocationsFindAll() {}
    Return em.createNamedQuery ("Locations.findAll", Locations.class) .getResultList ();
    }

    }

    Yes its safe. Stateless beans would be useless if it wasn't the case. That's the bit of "controlled container" description, as long as you leave the container do its job, you don't have to worry about such details.

  • Access EJB session bean in JSF managed bean

    Components of the project: Weblogic 11 G + 12 c, 12 c EJB3 JPA 2 Jdeveloper-ADF

    I need to access EJB session bean in JSF managed bean and some methods of execution by program

    Work method and return EJB below
    Is this fair? Another way

    public static Object getEjbForDataControl (String name) {}
    BindingContainer DCBindingContainer = (DCBindingContainer) BindingContext.getCurrent () .getCurrentBindingsEntry ();
    DCDataControl cDataControl = bindingContainer.findDataControl (name);
    Return cDataControl.getDataProvider ();
    }

    Thank you

    Mohsen

    Hi Isabelle,.

    I assumed that his Session EJB bean has not been exposed as a data control (my bad, didn't read any of the discussion).

    Antonis

  • NullPointerException when trying to data Get Session Bean in scope in an another ManagedBean

    Hello

    I used to access some data in my session bean brought a request bean so when I try to get all this data, I get

    com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection
    on managed bean
    «discussionlaoder»


    at the end of the exception, there are

    Caused by: java.lang.NullPointerException at Hiber.discussionlaoder.init(discussionlaoder.java:35)



    This is my code:

    1 - the scope application bean

    @ManagedBean
    @RequestScoped
    public class discussionlaoder {}

    private MyadmninHelper halper;

    @ManagedProperty(value="#{serviceBean}")
    Private ServicesBean serviceBean;
    @PostConstruct
    public void init() {}
    Halper = getServiceBean () .getHalper ();  line 35

    }

    code Seter and Giraudeau

    }

    2 - the scope sessions bean

    @ManagedBean (impatient = true)
    @SessionScoped
    public class ServicesBean {}



    private MyadmninHelper halper;

    code Seter and Giraudeau

    }

    uses the glassfish 3.1 Server

    Thanks for the help

    Oky this is work I just put the attribute like this name

    @ManagedBean (impatient = true, name = "serviceBean")
    @SessionScoped
    public class ServicesBean {}

    private MyadmninHelper halper;

    code Seter and Giraudeau

    }

  • Stateful session bean store module in EJB?

    Hello

    I want to use my EJB Stateful Session Bean (SFSB) module. But it seems that I can't use it because I should not inject my SFSB to a managed bean, or message driven bean (because if I do, the SFSB is communicated to all customers)

    I found that the proposed solution is to store SFSB in HttpSession.

    I'm doing this way, but I have null pointer exception.
    HttpSession session = (HttpSession) facesContext.getExternalContext().getSession(true); 
    So, how can I do this in the EJB module?

    Thank you

    Well me: hardly. Generally there is a web layer involved with a perfectly good session (or conversation) in what state can be maintained.

    Alas, you don't want to not seem to really say what is on your mind with or without my eyes so I'll offer just a hunch I have. A stateless bean remains "active" that as long as you keep a connection active IE. the reference that you are looking for or inject into your client code. The 'storage in the session bean' you refer to your first post is the Act of perpetuating the bean; as long as the reference is stored in the session you can continue to use it for the same customer without being cleaned by the container. However: when you are working from a web layer there is not a lot of use for a stateful bean because you can simply use the session itself directly to keep the substance. His personal preference if you use them or not really.

    Where you were going wrong in your initial post, is that you get the the HTTP session object in your EJB code. But you probably already figured out for yourself.

  • Cluster server: Replication Session bean

    I use JDeveloper 11.1.1.6.0

    I am currently developing our application for a clustered environment, and I was following section 20.4.3 the following document: http://docs.oracle.com/cd/E23943_01/web.1111/b31974/web_getstarted.htm#CHDIJCIE

    The document mentions that I need to make the beans of sight, pageflow and session as "serializable" and this bean pageflow view range shall be marked as dirty when they are updated. However, session bean did not have to be marked. I have to do something else in order to ensure that changes to the scope of the session is replicated in the cluster? ADF or somehow detect that there is a change and manage this replication for me?

    Thank you.

    The reason why you only need to do this for the beans to view range and pageflow is the way in which they are stored. These scopes are stored as cards in the scope of the session. If you change a bean inside the scope of session card don't know it because she knows that the reference and value.
    Changes to the session scope objects are tracked by the framework.

    Timo

Maybe you are looking for