JasperException: Absolute uri cannot be resolved - java

I have been getting the following JasperException when trying to use an XML schema for my web.xml, instead of the deprecated DOCTYPE declaration:
HTTP Status 500 - The absolute uri: http://java.sun.com/jsp/jstl/core
cannot be resolved in either web.xml or the jar files deployed with this
application
If I use this web.xml, the application compiles:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
However, if I use this web.xml, I get the JasperException:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1">
<display-name>CourseManagementJDBC</display-name>\
</web-app>
Any idea why only a deprecated format would work?
NOTE: This is for a Maven project, and the JSTL dependency has been correctly declared, as well as the tag library in the JSP:
pom.xml:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
JSP:
<%# taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
They're all correct; what gives?

I finally came upon the solution. By default, for some reason (and I'd like to know why), Maven generates a Dynamic Web Module as version 2.3. DTD was of course the standard for Servlet 2.3 and was probably unable to parse or evaluate my XML-based web.xml file.
I'm still not 100% clear as to why changing web.xml to XSD caused the JasperException with respect to JSTL, though I think it has something to do with JSTL being integrated with JSP at some point after Servlet 2.3 - someone please correct or elaborate on this if possible.
See this: https://stackoverflow.com/a/4928309/2879303
Now for the solution:
Right-click on your Maven project and select Properties
Navigate to Project Facets and untick Dynamic Web Module. Apply
changes.
From the version drop-down box, select the latest version (as of
writing, this is 3.1). Re-select Dynamic Web Module. Apply changes.
Right-click on your Maven project and select Maven -> Update
Project.
Your project should now be able to correctly interpret a web.xml
with an XSD declaration.

Related

Web.xml not compiling correctly

I recently tried to convert an Eclipse, Google Appengine Project from java7-java8 since GAE has stopped supporting java7 (or will do in the near future).
The project was working fine before starting the conversion. I am now getting this error when trying to run the project locally:
java.lang.IllegalStateException: Multiple servlets map to path: /api/add-batch-shelfsurvey: ApiShelfSurveyBatchServlet,com.imobdev.figjam.ApiShelfSurveyBatchServlet
This is the entry in web.xml for that servlet:
<servlet>
<servlet-name>ApiShelfSurveyBatchServlet</servlet-name>
<servlet-class>com.imobdev.figjam.ApiShelfSurveyBatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ApiShelfSurveyBatchServlet</servlet-name>
<url-pattern>/api/add-batch-shelfsurvey</url-pattern>
</servlet-mapping>
This is the start of the web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" 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_2_5.xsd">
I've double and triple checked /api/add-batch-shelfsurvey path is unique in web.xml but I still get this error.
The servlet mentioned in the error message changes but none of them have multiple mappings to one path.
I've found these threads that seem similar but aren't actually related:
https://github.com/dropwizard/dropwizard/issues/2107
https://bugs.eclipse.org/bugs/show_bug.cgi?id=479865
I don't know if it's relevant but this is my appengine-web.xml file:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<url-stream-handler>urlfetch</url-stream-handler>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
<property name="appengine.file.encoding" value="US-ASCII"/>
</system-properties>
<sessions-enabled>true</sessions-enabled>
<runtime>java8</runtime>
</appengine-web-app>
It is because the path
/api/add-batch-shelfsurvey
might have been registered before try to check all
<servlet-mapping>
sections in web.xml and if you have any
#WebServlet annotations then check urlPatterns={"..."}
If you have two definitions at the same time app server will not know which is the right one.
I've managed to get the project to run on the localhost and upload and run on Google App Engine. Unfortunately I don't know exactly what the problem was.
These are the steps I took:
-Removed the /* from all in web.xml file.
-Changed between version 2.5 xsd and 3.1 xsd several times, running the project on localhost each time.
-Changed back to 2.5 xsd and changed all back to ending in /*
Project then compiled and ran fine on both localhost and appengine. If anyone knows anything more about why this might happen please let me know.

read html file from JSF project root folder

I dont know how to explain it but let me try :
I have a eclipse JSF project named web-gestao
I would like to call from URL : http://www.domainxxx/simplefile.html and NOT http://www.domainxxx/web-gestao/simplefile.html
I need this for google verification purposes.
In jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<!-- URL to access the web module -->
<context-root>/</context-root>
...
...
...

JSTL Cannot be resolved error

I have seen similar questions and the answer suggested is place the JSTL jar in the classpath. I have tried both jstl.jar and jstl 1.1.jar bit My error is persistent. The Jars are coming in my web_inf/lib directory so I do not Understand what the problem is. I am using Tomcat 7
My Jsp:
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
.............
My 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">
<servlet>
......
My lib Directory After Deployment:
What Should I do I am running out of Options :P
Try using jstl-1.2.1 for Tomcat7
Download JSTL 1.2.1 jar
JSTL 1.1 also requires Standard.jar.
The standard.jar (taglib) library is used to enable the JSTL expression language in JSP page, and it’s always used together with the jstl.jar together.
Download and add it to your lib folder.
Or You can use JSTL 1.2 which does not require standard.jar and also provides performance improvements.

JSF 1.2: Navigation rules in a different config file

I am using JSF 1.2 for my application. I am trying to create a separate config file (named: navigation-config.xml) for all the navigation rules throughout my application. Below are the steps I followed for the same:
Made an entry in the web.xml file and placed it same directory where the faces-config.xml is present:
<context-param>
<param-name>javax.faces.application.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml,/WEB-INF/navigation-config.xml</param-value>
</context-param>
Below is the content of navigation-config.xml :
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE faces-config PUBLIC
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
"http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
<navigation-rule>
<description>Welcome Screen Navigation</description>
<from-view-id>/login.jspx</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/welcome.jspx</to-view-id>
</navigation-case>
</navigation-rule>
</faces-config>
When success, the navigation is not happening. If I remove the <navigation-rule> from the navigation-config.xml and add it to my faces-config.xml file then the navigation is working perfectly which means there are problems with the navigation-config.xml file navigation is having problems.
Please let me know how to resolve this, I need a separate file indicating all the navigation rules.
Try following...
make changes in web.xml file
> <context-param>
> <param-name>javax.faces.application.CONFIG_FILES</param-name>
> <param-value>/WEB-INF/faces-config.xml</param-value>
> <param-value>/WEB-INF/navigation-config.xml</param-value> </context-param>

JSP 2 and Servlet 2.4 broke my custom tags

We recently switched to Servlet 2.4 and JSP 2 on a project and our custom tags no longer work.
We have tags like:
<myTags:someTag value="${x}" />
and once in the tag we evaluated x bean and went from there. Now the evaluation happens directly in the JSP and we get a String (apparently x.toString()) set for the value attribute.
There are not a lot of tags and I could adapt them in a few days but how can I do that? I could not find anything on the web (or maybe I'm not looking where I should).
How do I pass the x bean to my tag and evaluate it there and not allow it to be evaluated in the JSP?
P.S. I do not want to deactivate the EL-engine
Thank you!
If you redeclare web.xml as Servlet 2.4 as follows
<web-app
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"
version="2.4">
and the tld file as JSP 2.0 taglib as follows:
<taglib
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/web-jsptaglibrary_2_0.xsd"
version="2.0">
Then you can add <rtexprvalue>true</rtexprvalue> entries to tag attributes in the TLD file which are expecting EL values. E.g.
<attribute>
<name>value</name>
<rtexprvalue>true</rtexprvalue>
</attribute>
It namely defaults to false.

Categories

Resources