Prettyfaces, it's not been resolved? - java

I'm trying to build custom URL as prettyfaces tells that it do, but after setup it, it gives me this error:
Referenced file contains errors (http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd). For more information, right click on the message in the Problems View and select "Show Details..."
This is how my web.xml setup:
<?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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>BRAINSET</display-name>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</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>*.xhtml</url-pattern>
</servlet-mapping>
<filter>
<filter-name>Pretty Filter</filter-name>
<filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>Pretty Filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
</web-app>
And my pretty-config.xml :
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ocpsoft.org/prettyfaces/3.3.3
http://ocpsoft.org/xml/ns/prettyfaces/ocpsoft-pretty-faces-3.3.3.xsd">
<url-mapping id="home">
<pattern value="/home" />
<view-id value="/index.xhtml" />
</url-mapping>
With this error I can't even deploy my app in Glassfish:
Could not publish to the server.
java.lang.NullPointerException
Any idea how to fix this ? Or should I look for another tool similar to prettyfaces ?
update

I don't think that this error is caused by PrettyFaces. The XML schema works fine in my Eclipse setup and I don't get any of these errors. And I'm pretty sure that the XSD file is valid.
You should have a look at the Eclipse log file (WORKSPACE/.metadata/.log) to have a look if there is any exception thrown.
BTW: You could also try to remove the schemaLocation element from your pretty-config.xml and check if this helps. PrettyFaces doesn't use the XSD schema when parsing the file. Something like this:
<pretty-config xmlns="http://ocpsoft.org/prettyfaces/3.3.3">
...
</pretty-config>

Finally figured this out.... so the reason this XSD isn't valid is because the document has this:
<?xml version="1.0" encoding="UTF-8" ?>
instead of:
<?xml version="1.0" encoding="UTF-8"?>
If anyone knows how to get ahold of Lincoln to fix this, that'd be great!

Related

Regarding filter mapping and servlet mapping in web.xml [duplicate]

Why my filtering does not work for me and how to setup it to work?
There is my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<servlet>
<display-name>GameServlet</display-name>
<servlet-name>GameServlet</servlet-name>
<servlet-class>ajaxdemo.action.GameServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>GameServlet</servlet-name>
<url-pattern>/gameservlet</url-pattern>
</servlet-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
On this configuration GameServlet does not receive anything and web server reports that there are no action mapping for /gameservlet URL.
If I comment filter-mapping this servlet works fine by this URL.
How to get working Struts filters and servlet filter simultaneously, the point is servlet should work only with /gameservlet URL, all others should be processed by Struts. I cannot understand how to create URL patterns for my case.
You should add excludePattern constant to struts.xml to exclude servlet mapping URL from Struts processing.
<struts>
<constant name="struts.action.excludePattern" value="/gameservlet/?.*"/>
...
</struts>

Error 404 when accessing a resource in a Java Dynamic Web Project

can someone tell me how to setup my project structure and my web.xml?
In my dynamic web project in the java resources folder i have a servlet (class name: RestFulService) which delivers a JSON file.
The web pages are in the WebContent-folder, for example index.jsp.
The project is published with a glassfish server.
This is my current 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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>RestFulService</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.javasrc, com.jersey.jaxb, com.fasterxml.jackson.jaxrs.json</param-value>
</init-param>
<init-param>
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>RestFulService</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
The link to access the JSON works well (http://localhost:8080/BCode/liveHelp/getText) but if i want to access the index.jsp via "http://localhost:8080/BCode/index.jsp" all i get is an error 404 page.
Can anyone please tell me where the problem is an what i have to change to get it working?
I guess the problem is in the web.xml but I don't have any idea what to change.

migrating to facelets 2.0 from facelets 1.x

I'm building a web App using JSF 2.0 and had a jaf-facelets.1.1.10 jar in my WEB-INF > lib folder, so now I'm trying to remove that so I can use the built int facelets 2.0 I was reading through this Question which balusC answered and I've done that, except teh part where it saysI need to replace FaceletViewHandler by ViewHandlerWrapper. for that I saw this question, but I don't have any faceletViewhandler classes in my project.
as of now, my webxml looks like this ( please check taht I didn't miss anything, or I'm referencing something I shouldn't:
<?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_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>miloWeb</display-name>
<welcome-file-list>
<welcome-file>faces/pages/index.xhtml</welcome-file>
</welcome-file-list>
<listener>
<listener-class>com.bravo.listeners.ServletListener</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>/faces/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>PdfServlet</servlet-name>
<servlet-class>com.bravo.servlets.PdfServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>PdfServlet</servlet-name>
<url-pattern>/PdfServlet</url-pattern>
</servlet-mapping>
<filter>
<filter-name>MyFacesExtensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>MyFacesExtensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<context-param>
<description>
This is to Have separated faces.config files
</description>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/pages/history/faces-config.xml,
/pages/contactInformation/faces-config.xml,
/pages/childHealthRecord/faces-config.xml,
/pages/dashboard/faces-config.xml,
/pages/insurance/faces-config.xml,
/pages/search/faces-config.xml,
/pages/labs/faces-config.xml,
/pages/patient/faces-config.xml,
/pages/physical/faces-config.xml,
/pages/notes/faces-config.xml,
/pages/scheduler/faces-config.xml,
/pages/settings/faces-config.xml,
/pages/orderEntry/faces-config.xml,
/pages/vitals/faces-config.xml
</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>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
</web-app>
And as you can see, I have quite a few faces-configs I removed the
<application>
<view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
</application>
And now it looks like this ( I know some features I don't need like the navigation, but does it really hurt to keep it taht way?):
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_2_0.xsd"
version="2.0">
<managed-bean>
<managed-bean-name>vitalsBB</managed-bean-name>
<managed-bean-class>com.bravo.vitals.VitalsBB</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>vitals</from-outcome>
<to-view-id>/pages/vitals/vitals.xhtml</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
after doing some changes and leaving it like that, I run the project on tomcatv7 and get this error:
java.lang.NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config
com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:452)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:140)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
Does that look like an error I would get for having my files like this? because all I did was remove the jar-facelets.1.1.10.jar and now I'm getting this Error. But teh App works fine b4 I remove the facelets jar, so what is the relationship between these two jars??
I tried adding the jstl.jar but that doesn't work, it just shows me this:
The error suggest include jstl-1.2.jar available here in the same folder where your jsf jars are.
There is no need for facelets 2.0 jar, because JSF 2.0 adopted facelets as its default View Declaration Language (VDL), and now it is bundled inside jsf jars (for both MyFaces and Mojarra)
To solve this issue, I had to Add the jstl-impl.jar and jstl-api.jar and update to the latest jsf-impl.jar and jsf-api.jar. That fixed it.
Don't really know why it never complained about it when the facelets.1.10.jar was there.

remove .py from the jython based web application url

This is the follow up of this question how to remove .py from the url in jython , I couldnt get it solved till now, and hope to get some more suggestions for it.
Here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
<servlet>
<servlet-name>PyServlet</servlet-name>
<servlet-class>org.python.util.PyServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>PyServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>NewJythonServlet</servlet-name>
<servlet-class>NewJythonServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>NewJythonServlet</servlet-name>
<url-pattern>/NewJythonServlet</url-pattern>
</servlet-mapping>
</web-app>
any ideas please?
Try:
<servlet-mapping>
<servlet-name>PyServlet</servlet-name>
<url-pattern>/serv/*</url-pattern>
</servlet-mapping>
I think the url had to start with something that isn't a wildcard

Cause of "Error deploying configuration descriptor" on Tomcat 7.0.12

When I try to deploy a WAR file by dropping it into webapps directory, I get following message in the console:
04.05.2011 19:34:07 org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying configuration descriptor xyz.war
I didn't find any hints about the detailed cause of this in the logs.
Where can I find out the details (e. g. the stack trace) about this failure?
Here's the 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"
id="WebApp_ID" version="2.5">
<display-name>myapp</display-name>
<context-param>
<description>
Vaadin production mode</description>
<param-name>productionMode</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Project Control Center Application</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<description>
Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>at.mycompany.myapp.ProjectControlCenterApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Project Control Center Application</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<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>
<listener>
<listener-class>at.mycompany.myapp.impl.persistence.DatabaseStartStopServletContextListener</listener-class>
</listener>
<session-config>
<session-timeout>480</session-timeout>
</session-config>
</web-app>
I found the answer. The cause of the problem was a malformed context.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" ...>
<welcome-file-list>
<welcome-file>
...
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>info</servlet-name>
<servlet-class>servlets.info.Properties</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Properties</servlet-name>
<!-- Here I forget to change the servlet name to info -->
<!-- So, the reason is invalid web.xml file -->
<url-pattern>/Properties</url-pattern>
</servlet-mapping>
</web-app>
Double-check your web.xml file.

Categories