managed-bean

NullPointerException while trying to access @EJB bean in managed bean constructor

跟風遠走 提交于 2019-12-02 12:35:07
问题 I've an EJB service. @Stateless public class SomeService {} I'd like to inject this in a viewscoped bean and initialize with it: @ManagedBean @ViewScoped public class ViewBean implements Serializable { @EJB private SomeService someService; public ViewBean() { System.out.println(someService.getEntity()); } } However, it throws the following exception: com.sun.faces.mgbean.ManagedBeanCreationException: Cant instantiate class: com.example.ViewBean. at com.sun.faces.mgbean.BeanBuilder

Eclipse won't autocomplete bean methods in EL when I use javax.annotation.ManagedBean

感情迁移 提交于 2019-12-02 07:07:46
问题 I created an application using JSF and Spring and I used the annotations @repository, @service @component and @autowired but when I am coding the Facelet file the beans cannot show up, can any one help me faces-config.xml: <?xml version="1.0" encoding="utf-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0

Eclipse won't autocomplete bean methods in EL when I use javax.annotation.ManagedBean

混江龙づ霸主 提交于 2019-12-02 06:40:07
I created an application using JSF and Spring and I used the annotations @repository, @service @component and @autowired but when I am coding the Facelet file the beans cannot show up, can any one help me faces-config.xml: <?xml version="1.0" encoding="utf-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <application> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>

CDI beans injection

烂漫一生 提交于 2019-12-02 05:43:53
Is this a correct approach to inject @ApplicationScoped bean in @SessionScoped bean? will this lead my application scoped bean to be stored in the session of every user? I have an application scoped bean that contains some values we share among all the system users, and now I need to get that values within a method in a session bean. Tarik Injecting a bean of the same or a broader scope in another bean is completely legal and correct either in JSF or CDI beans, like the example you provided. The difference between CDI beans and JSF managed beans regarding that is when you try to inject a bean

JSF injection with managed property, good pattern?

十年热恋 提交于 2019-12-02 04:36:13
问题 I'm quite new to JSF and not really "used" to the different thinking so I'm struggling on what (I assume) is basic. Lets say I have a class User, which is a session bean. Lets say I have a controller of 10000 objects, say Factory, that needs to be able to set some of them as "locked", in our case it means that the "locked" field does not become null anymore but reference a "LockedItem" object. This is where I can't get things working : LockedItem, when you instanciate it, is supposed to

JBoss 7.1 Weld finds Managed Bean in a jar in the ear, but the war does not

爱⌒轻易说出口 提交于 2019-12-02 03:15:54
jboss-as-7.1.1, dynamic web module 3.0, JSF 2.0 (Mojarra), Eclipse Indigo sr2 I have an EAR, Ynale.ear, which contains a YnaleImpl.jar and a Ynale.war: Ynale.ear |-YnaleWeb.war | |-META-INF | | |-MANIFEST.MF: | | Manifest-Version: 1.0 | | Class-Path: deployment.Ynale.ear.YnaleImpl | | | |-WEB-INF | | |-beans.xml | | | (empty) | | | | | |-faces-config.xml: | | | <?xml version="1.0" encoding="UTF-8"?> | | | <faces-config version="2.0" | | | xmlns="http://java.sun.com/xml/ns/javaee" | | | xmlns:xi="http://www.w3.org/2001/XInclude" | | | xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | | |

@ManagedBean(name=“foo”) not available by its name in EL #{foo}

半城伤御伤魂 提交于 2019-12-02 02:47:54
I'm trying to use an application scoped bean in JSF2, but for some reason it is always null in my request scoped bean. Here's the code I'm using: The application scoped bean: @ManagedBean(eager=true, name="applicationTracking") @ApplicationScoped public class ApplicationTracking implements Serializable { private static final long serialVersionUID = 4536466449079922778L; public ApplicationTracking() { System.out.println("ApplicationTracking constructed"); } } The request scoped bean: @ManagedBean @RequestScoped public class SearchResults implements Serializable { private static final long

ejbFacade is null

心已入冬 提交于 2019-12-01 23:07:22
I call the managedBean OverzichtAlle.java from the jsf page overzichtAlleGroepen.xhtml But when I get on this page i get the errormessage can't instantiate managedBeans.OverzichtAlle due to a Nullpointerexception... When I debug, I see that my ejbFacade is null.. this is the EJB @EJB private ProjecttypeEFacade ejbFacade; and this is my constructor: public OverzichtAlle() { projE = ejbFacade.findAll(); omvormenProjectTypes(); } projE is a List (entity-list) What am i doing wrong? @EJB s are injected after bean's construction. It's for the EJB injection manager namely not possible to call a bean

@Autowired service inside a @ManagedBean @Component class is null during JSF request [duplicate]

帅比萌擦擦* 提交于 2019-12-01 18:13:07
问题 This question already has answers here : Spring JSF integration: how to inject a Spring component/service in JSF managed bean? (3 answers) Closed 2 years ago . I tried union Spring 3(MVC) with JSF 2. I have some experience in Spring and JSF, but never tried to join them before. In the end I have 2 files @ManagedBean(name = "userBean") @Scope @Component public class someBean { @Autowired private TestService testService; public void printString() { System.out.println(testService.getString()); }

@Autowired service inside a @ManagedBean @Component class is null during JSF request [duplicate]

旧时模样 提交于 2019-12-01 17:56:00
This question already has an answer here: Spring JSF integration: how to inject a Spring component/service in JSF managed bean? 3 answers I tried union Spring 3(MVC) with JSF 2. I have some experience in Spring and JSF, but never tried to join them before. In the end I have 2 files @ManagedBean(name = "userBean") @Scope @Component public class someBean { @Autowired private TestService testService; public void printString() { System.out.println(testService.getString()); } } and @ManagedBean(name = "studentBean") @Scope @Component public class StudentBean { @Autowired private TestService