-
1. Re: JBoss AS 6 - EJB and CDI beans not injected
jaikiran Jun 16, 2011 10:55 PM (in response to osnetwork)If you have a web.xml, what does its xsd declaration look like?
-
2. Re: JBoss AS 6 - EJB and CDI beans not injected
osnetwork Jun 17, 2011 5:56 AM (in response to jaikiran)The web.xml is the same for both and it looks like that:
<web-app 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">
I have also tried to add CDI, so I have added the beans.xml files, and in the web application it looks like that:
<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://docs.jboss.org/cdi/beans_1_0.xsd">
</beans>
in the REST application is different:
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:weld="http://jboss.org/schema/weld/beans"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://docs.jboss.org/cdi/beans_1_0.xsd http://jboss.org/schema/weld/beans http://jboss.org/schema/weld/beans_1_1.xsd">
<weld:scan>
<weld:include name="org.rest.business.**" />
<weld:include name="org.rest.service.**" />
</weld:scan>
</beans>
Note: I have tried also to remove the beans.xml from the web application with no luck. On the REST application, instead I have tried to modify the beans.xml, even removing the weld:scan tags, but still nothing works
Luca
-
3. Re: JBoss AS 6 - EJB and CDI beans not injected
jaikiran Jun 17, 2011 6:07 AM (in response to osnetwork)Please post the entire contents of the web.xml and also the code from your servlet.
-
4. Re: JBoss AS 6 - EJB and CDI beans not injected
osnetwork Jun 17, 2011 8:49 AM (in response to jaikiran)Here is the web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>pn-web</display-name>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<security-role>
<role-name>admin</role-name>
</security-role>
<security-role>
<role-name>user</role-name>
</security-role>
<security-constraint>
<web-resource-collection>
<web-resource-name>IndexManagement</web-resource-name>
<url-pattern>/secure/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>IndexManagement</web-resource-name>
<url-pattern>/report/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>IndexManagement</web-resource-name>
<url-pattern>/index.jsp</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<login-config>
<auth-method>FORM</auth-method>
<form-login-config>
<form-login-page>/login.jsp</form-login-page>
<form-error-page>/loginfail.jsp</form-error-page>
</form-login-config>
</login-config>
<error-page>
<error-code>403</error-code>
<location>/accessdenied.jsp</location>
</error-page>
<servlet>
<description></description>
<display-name>getTestList.do</display-name>
<servlet-name>getTestList.do</servlet-name>
<servlet-class>org.web.controller.getTestList</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>getTestList.do</servlet-name>
<url-pattern>/secure/getTestList.do</url-pattern>
</servlet-mapping>
</web-app>
and here is the getTestList servlet
public class getTestList extends HttpServlet {
@EJB
private TestBeanLocal beanService;
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
try {
// Paging options
int start = 0;
int pageSize = 10;
String begin = request.getParameter("start");
String limit = request.getParameter("limit");
if (begin != null && begin.length() > 0) {
start = Integer.parseInt(begin);
}
if (limit != null) {
pageSize = Integer.parseInt(limit);
}
PagedListDTO complete = beanService.getOpenList(start,
pageSize);
JSONArray jsonArray = JSONOutput.createDataArray(complete
.getEntries());
response.setContentType("text/html; charset=UTF-8");
String output = JSONOutput.createPagedOuput(jsonArray,
complete.getTotalCount());
log.debug(output);
response.getWriter().write(output);
} catch (Exception e) {
errorJsonResponse(response, e);
}
}
}
and the beanService is null.