Witam,
Mam pewien problem z JSF. Podczas klikania w button, powinna zostać wywołana akcja (przetworzenie metody i przejście na inną stronę). Tym czasem dostaję komunikat błędu NullPointerException. Dodam tylko, że błąd ten pojawiać się zaczął w momencie gdy do projektu dodałem biblioteki RichFaces oraz zarejestrowałem je w web.xml
Poniżej przedstawiam kod:
- web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<!-- Making the RichFaces skin spread to standard HTML controls -->
<context-param>
<param-name>org.richfaces.CONTROL_SKINNING</param-name>
<param-value>enable</param-value>
</context-param>
<!-- Defining and mapping the RichFaces filter -->
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.sun.faces.config.ConfigureListener</listener-class>
</listener>
</web-app>
W google znalazłem, że dodanie ConfigureListenera powinno rozwiązać problem. W moim przypadku jednak tak nie jest. Pracuje na serwerze Tomcat 6.0 oraz używam Eclipsa Helios.
W pliku index.jsp robię przekierowanie <% response.sendRedirect("nbarFilteringNetworkTraffic.jsf"); %> Strona się ładuje a jej kod wygląda w następujący sposób.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>JSF 2.0: Bean Properties for Request Parameters</title>
</h:head>
<h:body>
<div align="center">
<h:form>
<fieldset>
<legend>NbarFilteringNetworkTraffic</legend>
<h:commandButton value="Show NBAR statistics" action="#{nbarFilteringNetworkTraffic.showNbarStatistics}"/>
</fieldset>
</h:form>
</div>
</h:body>
</html>
Kliknięcie buttona nie wywołuje metody klasy nbarFilteringNetworkTraffici zwraca błąd w postaci NullPointerException. Czym jest spowodowany ten błąd? Wydaje mi się, że kod wygląda poprawnie. Wszystkie niezbędne biblioteki znajdują się w libie a consola serwera nie wyświetla błędów.
Proszę o pomoc
Pozdrawiam