Hi everybody.
I am new to TomEE and am having problems with the very basics of getting
a simple CDI Application to work from Netbeans 7.2. I have added TomEE
Plus 1.5.0 as a server via the Tools->Servers->Add Server... steps. The
problem I have is as follows:
I create a simple Web Application with Context and Dependency Injection
enabled and server-supplied JSF 2.1 implementation activated. I proceed
to adding a very simple WelcomeBean.java file that looks like this:
package beans;
import java.io.Serializable;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;
/**
*
* @author kuw
*/
@Named(value = "welcomeBean")
@SessionScoped
public class WelcomeBean implements Serializable {
private int counter;
/**
* Creates a new instance of WelcomeBean
*/
public WelcomeBean() {
}
public String getMessage() {
return super.toString() + String.format(" You called me %d
times", ++counter);
}
}
and then access that bean from the index.xhtml page like this:
<h:body>
<h:form>
Message is: <h:outputText value="#{welcomeBean.message}"/>
</h:form>
</h:body>
When I run the project, the page simply shows this: "Message is:" and
the nothing. I can't see anything in the project files that is missing.
I have the empty shell of beans.xml file to enable CDI, web.xml is
fairly standard only that I changed the url-pattern for the Faces
Servlet. Here's the complete 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">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
So my question now is: what is going on? I don't see any obvious error
messages in the different Output tabs in Netbeans.
Btw. If I target the project to the Glassfish server, it works as expected:
Message is: beans.WelcomeBean@77431c1f You called me 3 times
(after reloading page two times).
Anyone here have any idea what I am missing? It has to be something
essential.
Thanks,
Kay
--
------------------------------
The information in this e-mail is confidential and is intended solely for
the addressee(s). Access to this email by anyone else is unauthorized. If
you are not an intended recipient, you may not print, save or otherwise
store the e-mail or any of the contents thereof in electronic or physical
form, nor copy, use or disseminate the information contained in the email.
If you are not an intended recipient, please notify the sender of this
email immediately.