Configuration problem

Splash Forums PrettyFaces Users Configuration problem

This topic contains 7 replies, has 2 voices, and was last updated by  Christian Kaltepoth 6 years ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #18025

    saprobionte
    Participant

    Hi all,

    I just discover PrettyFaces this morning, and it do exactly what I need … But I get some errors …

    I follow the “Get Started” guide from this site. I download each libraries (i do not use maven), put them into lib folder (in WEB-INF). Then I modify my web.xml :

    <?xml version=”1.0″ encoding=”UTF-8″?>

    <web-app version=”2.5″ xmlns=”http://java.sun.com/xml/ns/javaee&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd“>

    <context-param>

    <param-name>javax.faces.PROJECT_STAGE</param-name>

    <param-value>Production</param-value>

    </context-param>

    <context-param>

    <param-name>primefaces.THEME</param-name>

    <param-value>none</param-value>

    </context-param>

    <filter>

    <filter-name>Pretty Filter</filter-name>

    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>Pretty Filter</filter-name>

    <url-pattern>/*</url-pattern>

    <dispatcher>FORWARD</dispatcher>

    <dispatcher>REQUEST</dispatcher>

    <dispatcher>ERROR</dispatcher>

    </filter-mapping>

    <mime-mapping>

    <extension>jnlp</extension>

    <mime-type>application/x-java-jnlp-file</mime-type>

    </mime-mapping>

    <mime-mapping>

    <extension>jar</extension>

    <mime-type>application/java-archive</mime-type>

    </mime-mapping>

    <error-page>

    <exception-type>javax.faces.application.ViewExpiredException</exception-type>

    <location>/login.xhtml</location>

    </error-page>

    <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>/faces/*</url-pattern>

    </servlet-mapping>

    <session-config>

    <session-timeout>

    10

    </session-timeout>

    </session-config>

    <welcome-file-list>

    <welcome-file>faces/login.xhtml</welcome-file>

    </welcome-file-list>

    <resource-ref>

    <description>pacsdb</description>

    <res-ref-name>jdbc/pacsdb</res-ref-name>

    <res-type>javax.sql.DataSource</res-type>

    <res-auth>Container</res-auth>

    <res-sharing-scope>Shareable</res-sharing-scope>

    </resource-ref>

    <filter>

    <filter-name>restrict</filter-name>

    <filter-class>com.pigemedical.tablebean.RestrictPageFilter</filter-class>

    </filter>

    <filter-mapping>

    <filter-name>restrict</filter-name>

    <url-pattern>*.xhtml</url-pattern>

    </filter-mapping>

    </web-app>

    and I create the pretty-config.xml :

    <pretty-config xmlns=”http://ocpsoft.com/prettyfaces/3.3.0&#8243;

    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;

    xsi:schemaLocation=”http://ocpsoft.com/prettyfaces/3.3.0

    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.0.xsd“>

    <url-mapping id=”index”>

    <pattern value=”/index/” />

    <view-id value=”/faces/index.xhtml” />

    </url-mapping>

    <url-mapping id=”login”>

    <pattern value=”/login/” />

    <view-id value=”/faces/login.xhtml” />

    </url-mapping>

    </pretty-config>

    But when I run my project, I got those errors :

    java.lang.ClassNotFoundException: com.ocpsoft.pretty.PrettyFilter

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)

    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)

    at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)

    at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)

    at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)

    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:252)

    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)

    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)

    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4542)

    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5220)

    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5215)

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

    at java.util.concurrent.FutureTask.run(FutureTask.java:138)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

    at java.lang.Thread.run(Thread.java:662)

    13 sept. 2011 10:34:07 org.apache.catalina.core.StandardContext filterStart

    GRAVE: Exception au démarrage du filtre Pretty Filter

    javax.servlet.ServletException: Error configuring Pretty Faces, could not parse the configuration.

    at com.ocpsoft.pretty.PrettyFilter.init(PrettyFilter.java:136)

    at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:273)

    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:254)

    at org.apache.catalina.core.ApplicationFilterConfig.setFilterDef(ApplicationFilterConfig.java:372)

    at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:98)

    at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4542)

    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5220)

    at org.apache.catalina.core.StandardContext$2.call(StandardContext.java:5215)

    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)

    at java.util.concurrent.FutureTask.run(FutureTask.java:138)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

    at java.lang.Thread.run(Thread.java:662)

    Caused by: org.xml.sax.SAXParseException: Premature end of file.

    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1231)

    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)

    at com.ocpsoft.shade.org.apache.commons.digester.Digester.parse(Digester.java:1887)

    at com.ocpsoft.pretty.config.DigesterPrettyConfigParser.parse(DigesterPrettyConfigParser.java:45)

    at com.ocpsoft.pretty.config.PrettyConfigurator.feedWebAppConfig(PrettyConfigurator.java:228)

    at com.ocpsoft.pretty.config.PrettyConfigurator.configure(PrettyConfigurator.java:110)

    at com.ocpsoft.pretty.PrettyFilter.init(PrettyFilter.java:125)

    … 12 more

    I’m using Primefaces 3.0 (JSF 2.2 I think), tomcat 7 in Netbeans 7. Could someone tell me what i’m doing wrong ?

    #21340

    saprobionte
    Participant

    It seems it was problem from my Netbeans. I restart it, and I do not get these errors, but PrettyFaces seems not working. I get this url :

    http://localhost:9084/eView/faces/login.xhtml

    and I want :

    http://localhost:9084/eView/login.xhtml

    How could I know prettyfaces is working ? What could be wrong in my website ?

    #21341

    Did you add an URL pattern for this view? If so, could you post it? If you didn’t add any pattern yet, you should do so. See this section of the documentation for details:

    http://ocpsoft.com/docs/prettyfaces/3.3.0/en-US/html/Configuration.html

    #21342

    saprobionte
    Participant

    I do not understand your question, sorry ^^. I’ve put a pattern value :

    <pretty-config xmlns=”http://ocpsoft.com/prettyfaces/3.3.0&#8243;

    xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221;

    xsi:schemaLocation=”http://ocpsoft.com/prettyfaces/3.3.0

    http://ocpsoft.com/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.0.xsd“>

    <url-mapping id=”index”>

    <pattern value=”/index/” />

    <view-id value=”/faces/index.xhtml” />

    </url-mapping>

    <url-mapping id=”login”>

    <pattern value=”/login/” />

    <view-id value=”/faces/login.xhtml” />

    </url-mapping>

    </pretty-config>

    But this does not change the url. Could it be my other filter in web.xml that interfere with it ?

    I also use in my bean some redirection like that :

    resp.sendRedirect(“faces/login.xhtml”);

    Should I modify them ?

    #21343

    Yes, you should definitively change the sendRedirect() call to:

    resp.sendRedirect( request.getContextPath() + "/login/" );

    Otherwise you are sending the user to the JSF page direct and bypass PrettyFaces. :)

    #21344

    saprobionte
    Participant

    Hi,

    I’ve tested your idea, and it partially worked. I get the correct URL, but my css are not displayed anymore. Is there something to change in css ?

    #21345

    saprobionte
    Participant

    I continue my test, and I got another question … I have a servlet, I call it with javascript using :

    window.location=args.uri;

    And my uri is like that :

    “servletView?IUID=” + get_iuid();

    I pass iuid parameter to the servlet. How could I bypass that with prettyfaces ?

    #21346

    The changed redirect shouldn’t have any impact on your CSS. Why is it not working? Does the browser get 404 errors? Anything special in you CSS? Something like url(..)?

    Regarding your servlet: You could use a rewrite rule to change the URL of the servlet.

    Something like this:

    <rewrite match="^/view/(d+)$" substitute="/servletView?IUID=$1" redirect="chain"/>

    This way a URL like /view/12345 will internally translated to /servletView?IUID=12345.

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Comments are closed.