Web-app version is overridden when launching Tomcat 7 from Eclipse - eclipse

I'm developping a web application that is using web-fragment.xml files.
AFAIK, the web-framgent.xml files of the JAR in WEB-INF/lib should be merged and resolved to an effective web.xml.
So, I activate the logEffectiveWebXml option of my Tomcat 7 server to see the resulting file.
Hereby the beginning of the effective web.xml file:
Case 1: When the application is deploy on a standalone Tomcat 7:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="3.0"
metadata-complete="true">
Case 2: When the application is deploy on a Tomcat 7 in Eclipse IDE:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
version="2.5"
metadata-complete="true">
You notice that the version attribute is replaced with "2.5".
Besides, the effective web.xml is correct when deploying the app on the standalone Tomcat (the content of web-fragments.xml files are merged) whereas these contents are absent when launching Tomcat from Eclipse.
I think this is due to the version override.
Do you know why the version attribute is overriden when launching in Eclipse?
I inspect Eclipse configuration, projects configuration (they all use dynamic web module 3.0) and workspace directory ".metadata.plugins\org.eclipse.wst.server.core" but I don't manage to find something wrong...
NOTE: I also notice that the version is overridden even if I don't deploy my application (= fresh Tomcat install).
Thanks for your help.

Related

eclipse webapp welcome file display error

I m new to eclipse and facing difficulties at the beginning of a new webapp.
index.jsp doesnt display.
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">
<display-name>PizzaOrderApp</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
I already tryed with http://localhost:8080/PizzaOrderApp/index.jsp and http://localhost:8080/PizzaOrderApp/jsp/index.jsp
after remove-readd tomcat server:
Have you tried putting the .jsp file directly in the WebContent folder rather than creating a folder for the JSP pages?
You did not define the Spring dispatcher servlet in web.xml. You can either copy index.jsp outside of WEB-INF directory (into webcontent), or you should have a deep look into the Spring MVC documentation.
I also faced this problem but what i was doing wrong is, I created
Dynamic project in eclipse with Dynamic Web Module version 3.0. It
won't give you Web.xml file.I added Web.xml file from other project
but still Welcome File is not getting.
Then i deleted the project and i created the project with Dynamic Web
Module Version 2.4 and it given me Web.xml file. I again Configure the
Welcome File in the Web.xml file, After that its working fine.Server
which i am using is Tomcat 7 and java 1.7,Eclipse Luna.

Problems with eclipse and maven war plugin overlay

I have a project where I am replacing out the web.xml and other files using a war overlay in maven. Everything works great and then I try to import into eclipse and have all kinds of problems.
To start with I use mvn eclipse:eclipse to generate my Eclipse files. This works but the imported project does not contain the Dynamic Web facet.
Once the Dynamic Web facet (version 2.5) is added, the project still recognizes the deployment descriptor as 2.4 and gives me errors anyway even though it is;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<web-app version="2.5" 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_5.xsd">
Has anyone struggled through this type of thing before?

Eclipse Helios Java EE 6: Target Unreachable, identifier 'bean' resolved to null

I read through the answers on Java EE 6: Target Unreachable, identifier 'helloBean' resolved to null about identifier being resolved to null. I am facing the similar issue here. My development environment is Eclipse Helios and tomcat 7.0.
I actually have both faces-config.xml and web.xml made compliant to JSF2.0, however, that doesn't solve the issue. It works when I have the faces-config to include the bean. Once I took it off, even though I am having the #ManagedBean annotation, it just doesn't work. I don't see and error or warning in tomcat startup console messages and logs.
Appreciate if anyone can assist.
The faces-config.xml I am using:
<?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>userManagedBean</managed-bean-name>
<managed-bean-class>UserManagedBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
</faces-config>

How can I deploy a web app with sbt 0.11?

it seems that both the jetty-run and jetty commands are missing from SBT 0.11. Either that or I am doing something very wrong. I am simply running sbt, then trying to run jetty-run. I have defined a web.xml file in src/main/webapp/WEB-INF/web.xml which contains the following information:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"> </web-app>
I am simply trying to deploy a blank web-app using the latest SBT. I cannot find any documentation or updated examples for doing so. Any ideas?
Thank you in advance.
Starting from sbt 0.8 (xsbt branch), if I remember correctly, web support goes as a standalone plugin. Here you can find instructions on how to install and use it. In general, this new plugin fully supports the regular workflow of a legacy SBT (e.g., jetty-run, jetty-reload, etc.).

How to set a custom 404 page in JBoss 5?

How to set a custom 404 page in JBoss 5?
In general handling custom error pages is more to do with the servlet spec rather than the actual application container. Consequently, the most common place to put this is in your web.xml, like this:
<error-page>
<error-code>404</error-code>
<location>/my-404.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/my-500.jsp</location>
</error-page>
If the above still does not work, verify that you have the correct XSD in your web.xml, it's easy to use an old one that causes JBoss to fall back to an older version of the servlet API which doesn't recognise the above tags. In general, this one works for me with servlet 2.5:
<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">
Out of interest, the JBoss 5.0.x and 5.1.0, the global web.xml file is located at server/<your server>/deployers/jbossweb.deployer/web.xml, and ROOT.war is at server/<your server>/deploy/ROOT.war. This will allow you to make custom error pages for all applications within the server.