HELP!: problem setting up Primefaces

UI Components for JSF
Post Reply
rhume
Posts: 21
Joined: 07 Feb 2010, 07:30

07 Feb 2010, 07:42

I'm trying to get a hello world PrimeFaces example going. I'm using Eclipse, MyFaces 1.2.7 and Tomcat 6.

I have web project set up with MyFaces so the following JSF works:

Code: Select all

<h:outputText value="Hello1"/>
I added primefaces-1.0.0.RC.jar to the WEB-INF/lib folder, and added this line to the jsp:

Code: Select all

<p:colorPicker ></p:colorPicker>
When I run the app, I see the Hello1 and a button with a button for the color picker that does not appear to be rendered correctly. It's just a plain button with a black square on it.

When I add this XML to the web.xml, I get an error ...

Code: Select all

<!-- PRIME FACES BEGIN -->
  <servlet>
  	<servlet-name>Resource Servlet</servlet-name>
  	<servlet-class>org.primefaces.ui.resource.ResourceServlet</servlet-class>
  	<load-on-startup>2</load-on-startup>
  </servlet>
  <servlet-mapping>
  	<servlet-name>Resource Servlet</servlet-name>
  	<url-pattern>/primefaces_resources/*</url-pattern>
  </servlet-mapping>
<!-- PRIME FACES BEGIN -->
... here's the error:

Code: Select all

javax.servlet.ServletException: Servlet.init() for servlet faces threw exception
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	java.lang.Thread.run(Thread.java:637)
root cause

java.lang.IllegalStateException: No Factories configured for this Application. This happens if the faces-initialization does not work at all - make sure that you properly include all configuration settings necessary for a basic faces application and that all the necessary libs are included. Also check the logging output of your web application and your container for any exceptions!
If you did that and find nothing, the mistake might be due to the fact that you use some special web-containers which do not support registering context-listeners via TLD files and a context listener is not setup in your web.xml.
A typical config looks like this;
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
	javax.faces.FactoryFinder.getFactory(FactoryFinder.java:106)
	javax.faces.webapp.FacesServlet.init(FacesServlet.java:105)
	org.apache.myfaces.webapp.MyFacesServlet.init(MyFacesServlet.java:94)
	org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
	org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
	org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
	java.lang.Thread.run(Thread.java:637)
Please help! Any information is greatly appreciated.

rh

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Feb 2010, 12:26

Please see the user's guide for the setup, you have the wrong configuration, it should be;

Code: Select all

  <servlet>
     <servlet-name>Resource Servlet</servlet-name>
     <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
  </servlet>
  <servlet-mapping>
     <servlet-name>Resource Servlet</servlet-name>
     <url-pattern>/primefaces_resource/*</url-pattern>
  </servlet-mapping>
And make sure you have p:resources on page and f:view.

rhume
Posts: 21
Joined: 07 Feb 2010, 07:30

07 Feb 2010, 16:41

Thanks for the help. I did what you said and now I get the following error.

I know I'm doing something simple incorrectly, but I can't see what. I appreciate any help you can provide.

Code: Select all

An Error Occurred:
/index.jsp(14,0) No tag "colorPicker " defined in tag library imported with prefix "p"
Caused by:
org.apache.jasper.JasperException - /index.jsp(14,0) No tag "colorPicker " defined in tag library imported with prefix "p"

javax.faces.FacesException: /index.jsp(14,0) No tag "colorPicker " defined in tag library imported with prefix "p"
	at org.apache.myfaces.context.servlet.ServletExternalContextImpl.dispatch(ServletExternalContextImpl.java:347)
	at org.apache.myfaces.application.jsp.JspViewHandlerImpl.buildView(JspViewHandlerImpl.java:486)
I'll include my complete index.jsp and web.xml below.

index.jsp:

Code: Select all

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://primefaces.prime.com.tr/ui" prefix="p" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<p:resources/>
</head>
<body>
<f:view>

<p:colorPicker />

</f:view>
</body>
</html>
web.xml:

Code: Select all

<?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" id="WebApp_ID" version="2.5">
  <display-name>primefaces1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <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>*.jsf</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
  </context-param>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <description>
	This parameter tells MyFaces if javascript code should be allowed in
	the rendered HTML output.
	If javascript is allowed, command_link anchors will have javascript code
	that submits the corresponding form.
	If javascript is not allowed, the state saving info and nested parameters
	will be added as url parameters.
	Default is 'true'</description>
    <param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <description>
	If true, rendered HTML code will be formatted, so that it is 'human-readable'
	i.e. additional line separators and whitespace will be written, that do not
	influence the HTML code.
	Default is 'true'</description>
    <param-name>org.apache.myfaces.PRETTY_HTML</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
    <param-value>false</param-value>
  </context-param>
  <context-param>
    <description>
	If true, a javascript function will be rendered that is able to restore the
	former vertical scroll on every request. Convenient feature if you have pages
	with long lists and you do not want the browser page to always jump to the top
	if you trigger a link or button action that stays on the same page.
	Default is 'false'
</description>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
    <param-value>true</param-value>
  </context-param>
  <servlet>
    <servlet-name>faces</servlet-name>
    <servlet-class>org.apache.myfaces.webapp.MyFacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>faces</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <servlet-mapping>
    <servlet-name>faces</servlet-name>
    <url-pattern>*.faces</url-pattern>
  </servlet-mapping>
  <listener>
    <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
  </listener>
  

<servlet>
	<servlet-name>Resource Servlet</servlet-name>
	<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
	<servlet-name>Resource Servlet</servlet-name>
	<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
  
</web-app>

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

07 Feb 2010, 16:56

Weird, how about this;

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<f:view>
<head>
   <p:resources/>
</head>
<body>


<p:editor />

</body>
</f:view>
</html>

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 42 guests