cdi

@ManagedBean annotation doesnt work, but @Named works

匆匆过客 提交于 2019-12-12 09:19:45
问题 I had some troubles. Class with @Named works: @Named @SessionScoped public class UserBean { @Autowired UserBo userBo; public void setUserBo(UserBo userBo) { this.userBo = userBo; } public String printMsgFromSpring() { return userBo.getMessage(); } } but this is doesnt work and generates error: javax.servlet.ServletException javax.faces.webapp.FacesServlet.service(FacesServlet.java:606) root cause java.lang.NullPointerException com.mkyong.UserBean.printMsgFromSpring(UserBean.java:24)

Jetty: adding <resource-env-ref> programmatically

心已入冬 提交于 2019-12-12 09:18:38
问题 I have a standalone application with embedded Jetty and Wicket. I'd like to use CDI for injection. So I've found http://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#d0e5286 and now I'm trying to add this programatically, but it's quite complex. How do I code that? Other sources I've found are: http://osdir.com/ml/java.jetty.support/2007-02/msg00198.html http://docs.codehaus.org/display/JETTY/JNDI So far I have: Server server = new Server( 8080 ); Context ctx = new Context

Using CDI without a Servlet Container

落花浮王杯 提交于 2019-12-12 08:29:27
问题 I want to write a simple Java Desktop Application using Java Swing. Usually I use Spring Framework to do the dependency injection and build the whole class structure. However, I've seen that CDI is becoming more and more popular and want to give it a try. I would like to do the Dependency Injection of my project using CDI, but I don't know if this is possible without a Servlet container (as it is using Spring). Every single tutorial seems to be related with servlet containers or application

javax.ejb.NoSuchEJBException after redeploying EJBs

蹲街弑〆低调 提交于 2019-12-12 08:10:35
问题 Using Glassfish 3.0.1 ... If I have a web application accessing EJBs in another application remotely, and the remote application containing the EJBs is redeployed, I get a javax.ejb.NoSuchEJBException (see stacktrace below). Shouldn't this work? I can see that the EJB in question was successfully deployed, using the exact same JNDI name. Is there any other way to fix this than to restart the web application? It should be noted that in this particular example that the stacktrace is from, I'm

Illegal Syntax for Set Operation

断了今生、忘了曾经 提交于 2019-12-12 07:13:41
问题 I have a problem in connecting My xhtml page to the managed bean, the action on the commandButton works but when it comes to passing values it doesn't work. here is my jsf code: <h:form id="form" class="form-signin"> <p:panel id="panel" header=" Authentification" style="" > <h:panelGrid columns="2" rowClasses="3"> <h:outputLabel for="login" value="Nom d'utilisateur :" styleClass=""/> <p:inputText id="login" value=" #{authenticationBean.profil.login }" required="true" label="login" > <f

Can I create a request-scoped object and access it from anywhere, and avoid passing it around as a parameter in JAX-RS?

安稳与你 提交于 2019-12-12 06:36:25
问题 Say I have a web service / a REST resource that is called with some HTTP header parameters. The resource method builds a complex data object (currently a POJO) and eventually returns it to the client (via Gson as JSON, but that doesn't matter). So I have this call hierarchy: @Path(foo) ProjectResource @GET getProject() -> new Project() -> new List<Participant> which contains lots of new Participant()s -> new Affiliation() If I want the Affiliation object to be e.g. populated in English or

Select certain CDI event observer

房东的猫 提交于 2019-12-12 06:17:11
问题 I have a few classes that observe some CDI event. Is it possible to declare which class should be used in different cases? For example I have class that produce events: class Producer { @Inject private Event<SomeEvent> event; public void fire() { event.fire(new SomeEvent()); } } And I have two consumer classes: class ConsumerA { public void onEvent(@Observes SomeEvent event); } class ConsumerB { public void onEvent(@Observes SomeEvent event); } How can I use ConsumerA instances in one case

CDI bean List in datatable is null on submit from JSF

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-12 05:56:02
问题 Please note: This question is about CDI scopes as we are using CDI scopes in the app and not JSF scopes. 1) Controller Bean (TestController.java) which is in RequestScoped (enterprise context) is called index_cut.xhtml, when we come for first time on this page. 2) On button “Load”, we load the following method to populate the sapFinancialPeriodList which works fine and displays the data 3) After changing the content on the page and submitting, the sapFinancialPeriodList appears as NULL in the

Caused by: javax.naming.NameNotFoundException - Name [Class/object] is not bound in this Context

落爺英雄遲暮 提交于 2019-12-12 05:34:24
问题 have a problem that am dealing with since 6 hours but don't get to solve it. Am developping a Dynamic web project using JSF/Tomcat 7/ Maven/Java 7 Everytime I run the project on the server I get this: javax.naming.NameNotFoundException: Name [....ProjectManagement/service] is not bound in this Context. Unable to find [de.hhn.team3.artzpraxismanagement.ProjectManagement]. at org.apache.naming.NamingContext.lookup(NamingContext.java:820) at org.apache.naming.NamingContext.lookup(NamingContext

JSF2 form submit " Target Unreachable, identifier 'myModel' resolved to null ONLY on submit

China☆狼群 提交于 2019-12-12 05:27:23
问题 I have a very strange problem where a bean is not resolved but ONLY on submit. It works fine on view but on submit, it errors out saying that the identifier is null My JSF <h:form id="edit" styleClass="form"> <rich:panel> <f:facet name="header"> <h:outputText value="Edit Data" /> </f:facet> <rich:graphValidator value="#{myModel}" id="gv"> <rich:messages for="gv" /> <rich:messages id="goal-messages" globalOnly="true" /> <!-- form fields that reference #{myModel.fields} --> <h:commandButton id=