Can we deploy EJB 3.x as a separate jar from war (No EAR) on JBoss EAP 6.4 for container managed transactions? - cdi

I have application in which we do distributed deployment means restws.war, serverEjb.jar and Dao.jar separately and war has there dependency in jboss-deployment-structure.xml.
We are using RestEasy (2.3.10.Final), EJB3 and Spring JDBC Template (4.3.0.RELEASE).
Structure is:
Rest.war
Ejb.jar
DAO.jar
With jboss-deployment-structure.xml
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<dependencies>
<module name="deployment. Ejb.jar"/>
<module name="deployment.DAO.jar"/>
</dependencies>
</deployment>
</jboss-deployment-structure>
We have stateless Local session bean with CMT, there is no error in the log while deployment but when we access EJB method no rollback is happening on runtime exception rather each sql statement commits after the execution.
EJB File looks like
#Stateless
public class ProductService {
#Inject
ProductDAO productDAO;
public Product getProduct() {
Product product =productDAO.getProduct();
return product;
}
public Product createProduct(Product product) {
return productDAO.createProduct(product);
}
}
RestEasy Service looks like
#Path("/json/product")
public class ProductService {
#Inject
ProductService productService;
#GET
#Path("/get")
#Produces("application/json")
public Product getProduct() {
return productService.getProduct();
}
#POST
#Path("/post")
#Consumes("application/json")
public Response createProduct(Product product) {
product=productService.createProduct(product);
String result = "Product created : " + product;
return Response.status(201).entity(result).build();
}
}
If I combine these jar in as WAR using same compiled jar by removing the MANIFEST.MF Dependencies then EJB behavior is as expected and truncation rollback.
<pre>
War Structure:<br>
Rest.war<br>
META-INF<br>
WEB-INF<br>
classes<br>
lib<br>
ejb.jar<br>
DAO.jar<br>
…. Third party jar<br>
beans.xml<br>
web.xml<br>
</pre>
I used same/similar code base to build a ear fine then also it works.
<pre>
Ear Structure:<br>
ear-application-1.0.ear<br>
lib<br>
DAO.jar<br>
…. Third party jar<br>
META-INF<br>
application.xml<br>
ejb.jar<br>
web.war<br>
</pre>
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application 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/application_6.xsd" version="6">
<display-name>ear-application</display-name>
<module>
<web>
<web-uri>web.war</web-uri>
<context-root>/rest</context-root>
</web>
</module>
<module>
<ejb> ejb.jar</ejb>
</module>
<library-directory>lib</library-directory>
</application>
Please help me understanding and resolving this issue.

Related

WildFly does not run my LiquibaseProcucer CDI

I'm trying to run my LiquibaseProducer in WildFly 9.0.2. This is my Producer class:
package nl.itris.mjop.database;
import liquibase.integration.cdi.*;
import liquibase.integration.cdi.annotations.*;
import liquibase.resource.*;
import **********
#Singleton
#Startup
#Dependent
public class LiquibaseProcducer {
#Resource(lookup="java:jboss/datasources/PostgresDS")
private static DataSource myDataSource;
#Produces #LiquibaseType
public CDILiquibaseConfig createConfig() {
System.out.println("============= liquibase createConfig entry =============");
CDILiquibaseConfig config = new CDILiquibaseConfig();
config.setChangeLog("liquibase/parser/core/xml/simpleChangeLog.xml");
System.out.println("============= liquibase createConfig exit =============");
return config;
}
#Produces #LiquibaseType
public DataSource createDataSource() throws SQLException {
System.out.println("============= liquibase createDataSource entry =============");
return getDataSource();
}
#Produces #LiquibaseType
public ResourceAccessor create() {
System.out.println("============= liquibase create entry =============");
return new ClassLoaderResourceAccessor(getClass().getClassLoader());
}
public static DataSource getDataSource() {
if (myDataSource == null) {
/* Workaround for failing #Resource(lookup="java:jboss/datasources/PostgresDS") */
try {
System.out.println("============= liquibase datasource lookup via initial context workaround =============");
InitialContext ctx = new InitialContext();
myDataSource = (DataSource) ctx.lookup("java:jboss/datasources/PostgresDS");
} catch(NamingException ne) {
ne.printStackTrace();
}
}
return myDataSource;
}
}
When I (re) deploy my WAR file in WildFly, this producer is not doing anything! I do not see any error messages in my log files, I do not see any system.out messages that I put in the producer methods.
The producer class seems to be loaded and recognized by WildFly hence this log fragment:
2016-11-30 10:58:53,662 INFO [org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor] (MSC service thread 1-7) JNDI bindings for session bean named LiquibaseProcducer in deployment unit deployment "mjop-elements.war" are as follows:
java:global/mjop-elements/LiquibaseProcducer!nl.itris.mjop.database.LiquibaseProcducer
java:app/mjop-elements/LiquibaseProcducer!nl.itris.mjop.database.LiquibaseProcducer
java:module/LiquibaseProcducer!nl.itris.mjop.database.LiquibaseProcducer
java:global/mjop-elements/LiquibaseProcducer
java:app/mjop-elements/LiquibaseProcducer
java:module/LiquibaseProcducer
I'm out of options. Why is my producer not executed? What am I doing wrong?
Any help is appreciated!
My beans.xml is like this:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
</beans>

Interceptors don't work with JSF managed beans?

I am decide to try interceptors My first interceptor binding annotation is
#Inherited
#InterceptorBinding
#Target({TYPE})
#Retention(RUNTIME)
public #interface WithLog {
// No parameters required
}
And interceptor class is
#Interceptor
#WithLog
public class LogInterceptor {
#AroundInvoke
private Object logMethod(InvocationContext context) throws Exception {
System.out.println("Method " + context.getMethod().getName() +
" of class " + context.getTarget().getClass().getName() + " was called.");
return context.proceed();
}
#PostConstruct
private void construct(InvocationContext context) {
System.out.println("#Postconstruct of " +
context.getMethod().getDeclaringClass().getName() + " started.");
}
}
So, I want to add simple logging for JSF managed bean:
#ManagedBean(name = "departmentRootMB")
#ViewScoped
#WithLog
public class DepartmentRootMB implements Serializable {
long serialVersionUID = 0L;
// . . . properties, methods
}
I read, that to enable interceptors I need to create beans.xml. I created one in the WEB-INF directory:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="annotated">
<interceptors>
<class>ru.edu.pgtk.weducation.interceptors.LogInterceptor</class>
</interceptors>
</beans>
I rebuild project and no effect. Where is the mistake? What I did wrong? I use glassfish 4.1 with it standard components (WELD, EclipseLink, JSF 2.2.7)
Thanks for your time and best regards.
Interceptors don't work with JSF managed beans?
Correct.
Replace JSF bean management facility by CDI bean management facility.
In other words, replace #ManagedBean and friends by #Named and friends. The JSF bean management facility is on the schedule to be deprecated in favor of CDI in a future Java EE version anyway. This is a good opportunity to migrate now you can.
See also:
Backing beans (#ManagedBean) or CDI Beans (#Named)?

CDI cross BDA bean injection in Wildfly 8.1

I have an EAR file with the following structure:
lib
jar.jar
Test1
Test2
ejb.jar
Test1Impl
war.war
Test2Impl
TestServlet
The jar.jar contains two interfaces
Test1
Test2
The TestServlet injects Test1 which resolves to Test1Impl only if I have a manifest Class-Path entry in war.war to ejb.jar.
Test1Impl injects Test2 which resolves to Test2Impl only if I have a manifest Class-Path entry in ejb.jar to war.war.
The tip entry Matching the classloader structure for the deployment of the Weld documentation explains why I need the manifest entries.
How is this cross BDA injection supposed to work normally? Adding Class-Path manifest entries seems a bit stupid because actually I don't want the implementations to be visible. I only want that the beans from other subdeployments to be visible. Is there any way to do that?
Here the implementations
public class Test1Impl implements Test1 {
#Inject
private Test2 test2;
public void hello() {
System.out.println(test2.getString());
}
}
public class Test2Impl implements Test2 {
public String getString() {
return "Hello";
}
}
#WebServlet(urlPatterns = "/test")
public class TestServlet implements Servlet {
#Inject
private Test1 test;
public void init(ServletConfig config) throws ServletException {
}
public ServletConfig getServletConfig() {
return null;
}
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
test.hello();
}
public String getServletInfo() {
return null;
}
public void destroy() {
}
}
And here the application.xml
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/application_7.xsd"
version="7">
<description>The EAR</description>
<display-name>ear</display-name>
<module>
<ejb>ejb.jar</ejb>
</module>
<module>
<web>
<web-uri>war.war</web-uri>
<context-root>/</context-root>
</web>
</module>
<library-directory>lib</library-directory>
</application>
As described in the CDI reference in the section Using CDI Beans from outside the deployment a jboss-deployment-structure.xml with the appropriate dependencies is required.
Although doing this fixed my problems, I think that the CDI spec should define a portable way for doing this for enterprise applications.

Unable to inject No-Interface EJB with security defined

I am trying to deploy an enterprise application EAR consisting of:
an EJB 3.1 module containing stateless session beans
a web module containing servlets
to Apache Geronimo V3.0 (packaged as a WebSphere Community 3.0.0.4 Server).
The beans are exposed through the #LocalBean annotation and injected into the servlets using the #EJB annotation.
Without any application security settings defined, everything works flawlessly. But, as soon as I define even the simplest security setup, injection fails with the message:
java.lang.IllegalArgumentException: Invalid method interface: LocalBean
javax.security.jacc.EJBMethodPermission$MethodSpec.checkMethodInterface(EJBMethodPermission.java:303)
javax.security.jacc.EJBMethodPermission$MethodSpec.(EJBMethodPermission.java:209)
javax.security.jacc.EJBMethodPermission.(EJBMethodPermission.java:90)
org.apache.geronimo.openejb.GeronimoSecurityService.isCallerAuthorized(GeronimoSecurityService.java:100)
org.apache.openejb.core.stateless.StatelessContainer.invoke(StatelessContainer.java:159)
org.apache.openejb.core.ivm.EjbObjectProxyHandler.synchronizedBusinessMethod(EjbObjectProxyHandler.java:255)
org.apache.openejb.core.ivm.EjbObjectProxyHandler.businessMethod(EjbObjectProxyHandler.java:235)
org.apache.openejb.core.ivm.EjbObjectProxyHandler._invoke(EjbObjectProxyHandler.java:92)
org.apache.openejb.core.ivm.BaseEjbProxyHandler.invoke(BaseEjbProxyHandler.java:284)
com.sun.proxy.$Proxy117.getSysTime(Unknown Source)
dk.danicon.servlet.Systime.doGet(Systime.java:43)
javax.servlet.http.HttpServlet.service(HttpServlet.java:575)
javax.servlet.http.HttpServlet.service(HttpServlet.java:668)
The security configuration works perfectly and prompts for credentials on servlets defined with an annotation like the one below, if they don't try to inject an EJB:
#ServletSecurity(#HttpConstraint(rolesAllowed={"admin"}))
I can make the injection work by removing the #LocalBean and implementing a #Local interface instead. But, from what I have been able to read on the subject, this should work with no-interface views as well - and I would like to avoid the added overhead from the interface.
I am attaching the relevant configuration files below and hope someone can tell me what I'm missing here?
application.xml (EAR module):
<?xml version="1.0" encoding="UTF-8"?>
<application id="Application_ID" version="6" 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/application_6.xsd">
<display-name>TestEar</display-name>
<module id="Module_1383740442312">
<web>
<web-uri>TestWeb.war</web-uri>
<context-root>test</context-root>
</web>
</module>
<module id="Module_1383741874882">
<ejb>TestEjb.jar</ejb>
</module>
</application>
geronimo-application.xml (EAR module):
<?xml version="1.0" encoding="UTF-8"?>
<app:application xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" application-name="TestEar" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers="http://java.sun.com/xml/ns/persistence" xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
<dep:environment>
<dep:moduleId>
<dep:groupId>dk.danicon</dep:groupId>
<dep:artifactId>application</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
<dep:dependencies>
<dep:dependency>
<dep:groupId>org.apache.geronimo.framework</dep:groupId>
<dep:artifactId>j2ee-security</dep:artifactId>
<dep:type>car</dep:type>
</dep:dependency>
<dep:dependency>
<dep:groupId>console.dbpool</dep:groupId>
<dep:artifactId>jdbc_ssodb</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:dependency>
</dep:dependencies>
</dep:environment>
<sec:security>
<sec:role-mappings>
<sec:role role-name="admin">
<sec:principal class="org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal" name="ADMIN"/>
</sec:role>
</sec:role-mappings>
</sec:security>
<dep:gbean class="org.apache.geronimo.security.realm.GenericSecurityRealm" name="webrealm">
<dep:attribute name="realmName">webrealm</dep:attribute>
<dep:reference name="ServerInfo">
<dep:name>ServerInfo</dep:name>
</dep:reference>
<dep:xml-reference name="LoginModuleConfiguration">
<log:loginConfig>
<log:login-module control-flag="REQUIRED" wrap-principals="false">
<log:login-domain-name>webrealm</log:login-domain-name>
<log:login-module-class>org.apache.geronimo.security.realm.providers.SQLLoginModule</log:login-module-class>
<log:option name="dataSourceName">jdbc/ssodb</log:option>
<log:option name="userSelect">SELECT username, password FROM v4.app_users WHERE username = ?</log:option>
<log:option name="groupSelect">SELECT username, group_name FROM v4.app_users WHERE username = ?</log:option>
<log:option name="digest"/>
<log:option name="encoding"/>
</log:login-module>
</log:loginConfig>
</dep:xml-reference>
</dep:gbean>
</app:application>
ejb-jar.xml (EJB module):
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar version="3.1" 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/ejb-jar_3_1.xsd">
<display-name>TestEjb </display-name>
</ejb-jar>
openejb-jar.xml (EJB module):
<?xml version="1.0" encoding="UTF-8"?>
<ejb:openejb-jar xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers="http://java.sun.com/xml/ns/persistence" xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0" xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1">
<dep:environment>
<dep:moduleId>
<dep:groupId>dk.danicon</dep:groupId>
<dep:artifactId>ejbmodule</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
</dep:environment>
</ejb:openejb-jar>
web.xml (WEB module):
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" 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-app_3_0.xsd">
<display-name>TestWeb</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<login-config>
<auth-method>BASIC</auth-method>
<realm-name>webrealm</realm-name>
</login-config>
</web-app>
geronimo-web.xml (WEB module):
<?xml version="1.0" encoding="UTF-8"?>
<web:web-app xmlns:web="http://geronimo.apache.org/xml/ns/j2ee/web-2.0.1" xmlns:app="http://geronimo.apache.org/xml/ns/j2ee/application-2.0" xmlns:bp="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:client="http://geronimo.apache.org/xml/ns/j2ee/application-client-2.0" xmlns:conn="http://geronimo.apache.org/xml/ns/j2ee/connector-1.2" xmlns:dep="http://geronimo.apache.org/xml/ns/deployment-1.2" xmlns:ejb="http://openejb.apache.org/xml/ns/openejb-jar-2.2" xmlns:jaspi="http://geronimo.apache.org/xml/ns/geronimo-jaspi" xmlns:log="http://geronimo.apache.org/xml/ns/loginconfig-2.0" xmlns:name="http://geronimo.apache.org/xml/ns/naming-1.2" xmlns:pers="http://java.sun.com/xml/ns/persistence" xmlns:pkgen="http://openejb.apache.org/xml/ns/pkgen-2.1" xmlns:sec="http://geronimo.apache.org/xml/ns/security-2.0">
<dep:environment>
<dep:moduleId>
<dep:groupId>dk.danicon</dep:groupId>
<dep:artifactId>webmodule</dep:artifactId>
<dep:version>1.0</dep:version>
<dep:type>car</dep:type>
</dep:moduleId>
</dep:environment>
<web:context-root>/test</web:context-root>
<web:security-realm-name>webrealm</web:security-realm-name>
</web:web-app>
Sample EJB:
package dk.danicon.ejb;
import javax.annotation.security.RolesAllowed;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
#Stateless
#LocalBean
#RolesAllowed({"admin"})
public class SysTime {
public SysTime() {
}
public long getSysTime() {
return System.currentTimeMillis();
}
}
Sample servlet:
package dk.danicon.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import dk.danicon.ejb.SysTime;
#WebServlet("/testsystime")
#ServletSecurity(#HttpConstraint(rolesAllowed={"admin"}))
public class TestSystime extends HttpServlet {
private static final long serialVersionUID = 1L;
#EJB
SysTime systime;
public TestSystime() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter pw = response.getWriter();
pw.println("<html><body><h3>Systime</h3>");
pw.println("<p>System time: " + systime.getSysTime() + " - " + systime.getClass().getName() + "</p>");
if(request.getUserPrincipal() != null)
pw.println("<p>Principal: " + request.getUserPrincipal().getName() + "</p>");
pw.println("</body></html>");
}
}
This appears to be an OpenEJB bug since there is no such LocalBean method interface type. That said, I am somewhat surprised that EJBMethodPermission is throwing an exception since the javadoc for that class says that implementations should be flexible enough to support unknown method interface types.

How to inject a CDI Bean in a ManagedBean?

I want to inject a CDI Bean in a ManagedBean either with the annotation #Inject or #Produce. The CDI Bean which I use is:
#Named
#Startup
#ApplicationScoped
public class BaseBean {
private List<String> custs;
public List<String> getCusts() {
return custs;
}
public void setCusts(List<String> emps) {
this.custs = emps;
}
public BaseBean(){
}
#PostConstruct
void init() {
custs = new ArrayList<String>();
custs.add("Cust1");
custs.add("Cust3");
custs.add("Cust2");
custs.add("Cust4");
}
}
The ManagedBean, in which I want to inject the CDI Bean is:
#SessionScoped
#ManagedBean
public class Hello implements Serializable {
#Inject
private BaseBean dBean;
private static final long serialVersionUID = 1L;
private List<String> customers;
private List<String> customersSelect;
public Hello() {
}
#PostConstruct
void init() {
// dBean = new BaseBean();
customers = dBean.getCusts();
}
public List<String> getCustomers() {
return customers;
}
public List<String> getCustomersSelect() {
return customersSelect;
}
public void setCustomersSelect(List<String> customersSelect) {
this.customersSelect = customersSelect;
}
}
In the init function however, it throws NullPointerException. If I use the annotation #Produces instead of #Inject, the result is the same: NullPointerException. Is anything wrong with the CDI Bean (improper annotations)? Do I try to inject it with a wrong way? Does my code lack of something? How can I get it work? Here is the JSF code:
<h:form id ="f">
<h:selectManyCheckbox layout="pageDirection" border="1" value="#{hello.customersSelect}">
<f:selectItems value="#{hello.customers}"></f:selectItems>
</h:selectManyCheckbox><br />
<h:commandButton action="response.xhtml" value="Click me" />
</h:form>
PS: If I use a Stateless Bean as BaseBean and I inject it with the annotation #EJB, it works with no problem.
UPDATE: I have tried it with the annotations #SessionScoped (javax.enterprise.context.SessionScoped) and #Named on the Hello class. Although I do not receive a NullPointerException, the h:selectManyCheckbox is empty. moreover, it strikes me, that when I add the beans.xml file under META-INF folder, I receive a StartException, although the file is there supposed to be. I think my application lacks the proper configuration to be capable of Dependency Injection. What is likely to need additional configuration?
UPDATE 2: This error appears when I add the beans.xml file in the WEB-INF folder. The beans.xml file is empty, it contains only the line :
<?xml version="1.0" encoding="UTF-8"?>
The error is:
Services which failed to start: service jboss.deployment.unit."JSF1.war".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."JSF1.war".PARSE: Failed to process phase PARSE of deployment "JSF1.war"
12:51:11,482 ERROR [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) {"JBAS014653: Composite operation failed and was rolled back. Steps that failed:" => {"Operation step-2" => {"JBAS014671: Failed services" => {"jboss.deployment.unit.\"JSF1.war\".PARSE" => "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"JSF1.war\".PARSE: Failed to process phase PARSE of deployment \"JSF1.war\""}}}}
What #patlov is suggesting will work if you use #Named on your CDI beans. However, if you're working in an environment that supports CDI, do not use #ManagedBean. Instead, use CDI all the way. See this answer and I'm sure you could find numerous other ones that strongly advise against what you're trying to do.
Just switch from javax.faces.bean.SessionScoped to javax.enterprise.context.SessionScoped and everything will magically work. What you may run into is the absense of #ViewScoped from CDI however, in which case use something like JBoss Seam or Apache Deltaspike that implement it for you. As an added benefit, they will also automatically replace all of the JSF scopes with CDI scopes automatically if you already have existing code written for JSF.
Update:
This should be the content of your beans.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans 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/beans_1_0.xsd">
</beans>
Make sure you have enabled CDI by putting a WEB-INF/beans.xml file in your application.
If you are using #ManagedBean use #ManagedProperty to inject properties:
#ManagedProperty(value = "#{baseBean}")
private BaseBean dBean;
// getter and setter

Resources