Websphere liberty profile error: 404 SRVE0190E - java

What could be the reason for the error: Error 404: SRVE0190E: File not found: /SimpleServletPath
I am deploying in websphere liberty profile server.
I can't reach my admin console login page
I can reach my welcome page on my websphere liberty profile server but can't do so after creating a servlet. That's when the above 404 error comes up.
There are similar posts online that advice to change com.ibm.ws.webcontainer.invokefilterscompatibility=true . I can't find how to set this parameter because I can't hit the websphere admin console login.
I installed websphere through eclipse marketplace.
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" 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">
<display-name>ServletExplore</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app

By default, your app's context root will default to the name of the application. You can change it (including setting it to /) by looking at the server on the Servers tab and editing its configuration. You can make changes in the GUI or directly in the server.xml.
If your app is called my app, I suspect localhost:9080/myapp/SimpleServletPath is where your servlet is currently living.

You are probably using annotation #WebServlet in your servlet, but you have web.xml file. Remove web.xml file from your project and run again.

Related

Context root "/" set URL to localhost:8080//

I have a java spring web application running on a local widlfly. Until now it was always the case that I called the webapp via the URL "localhost:8080/myapp". Now I have set my context root in the jboss-web.xml to "/". My assumption would be that I can now call the website via localhost:8080/. But this redirects me to the Widlfly welcome content. I can only call my webapp via "localhost:8080//". Can I set the context root so that I reach the webapp via "localhost:8080"?
Thanks for your help.
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="10.0"
xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_10_0.xsd">
<context-root>/</context-root>
</jboss-web>
You need to disable the default welcome app

Tomcat websocket echo app

I am fairly new to websockets and am pulling my hair out. I am using the echo app as a template. I have created a project in eclipse called echo and have placed the source for EchoAnnotation.java and EchoEndpoint.java (http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/WEB-INF/classes/websocket/echo/) in the appropriate place.
I have also created an echo.xhtml file and placed it there as well (http://svn.apache.org/viewvc/tomcat/trunk/webapps/examples/websocket/echo.xhtml?view=log).
I had to find the web.xml here: Tomcat 8 Examples: Missing Configuration Step and am using this:
<?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">
<welcome-file-list>
<welcome-file>echo.xhtml</welcome-file>
</welcome-file-list>
</web-app>
I run my ant build script to turn this into examples.war and deploy it to my tomcat 8 webaps directory. I hit this URL: http://localhost:8080/examples/echo.xhtml and the page comes up.
the problem is that as soon as I click connect, I get a message indicating the server closed the connection.
Did I miss a setup step?
Just found that someone else is having the exact same problem: How to make Tomcat 8 websocket example works?
the problem is that as soon as I click connect?
Where is your click button?
I went back to the download file for tomcat 8.05 and pulled the examples webapp out of the tarball and that is working fine. I'll just start playing with that.

What controls the first part of a Tomcat app's URL?

I'm upgrading an old web app (was Tomcat 5 and JSF 1). I'm pretty new to Tomcat.
URLs into the app are all like this: "http://localhost:8181/app/esp/..."
But, currently the only way I can get the request through to the app is to use a URL like this: "http://localhost:8181/esp/esp/...".
So, how and where do I need to configure this "/app"? (Bear in mind this was working fine in the previous version).
My current environment is Eclipse Kepler, Tomcat 7 and JSF 2. Tomcat starts fine from Eclipse and will display an html page with "Run as server", for example: "http://localhost:8181/esp/esp/logout.html"
But this page has a link to "http://localhost:8181/app/esp/main" which results in a message "HTTP Status 404 - /app/esp/main - The requested resource is not available." If I overwrite the "app" with "esp" the request is handled.
My web.xml (stripped down by now) is like this:
<?xml version="1.0" encoding="UTF-8"?>
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
ESP
<servlet>
<display-name>ESPServlet</display-name>
<servlet-name>ESPServlet</servlet-name>
<servlet-class>ch.eds.esp.controller.ESPServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ESPServlet</servlet-name>
<url-pattern>/esp/main/*</url-pattern>
</servlet-mapping>
Server.xml defines a Context in a Host, like this:
<Host appBase="webapps" debug="0" name="localhost" unpackWARs="true">
<Context reloadable="true" path="/app" />
</Host>
So, to cut a long story short, a URL like this ".../esp/esp/mypage..." works, and a URL like this ".../app/esp/mypage..." doesn't. And the second form is the way it needs to work.
But why? And how?
Following David99World's suggestion below, I tried changing these things.
In Eclipse I changed the "Web Project Settings/Context Root" from "esp" to "app". This produced no change when trying to "run on server" from Eclipse.
I tried exporting a WAR file from my project (using "Export...) to either a esp.war or a app.war. Putting them into /webapps and clearing away the previous stuff and restarting Tomcat.
If I use esp.war, then the usual 404 happens.
If I use app.war, I have a folder structure /webapps/app/esp etc. And requesting "http://localhost:8181/app/esp/main" seems to give an interesting result. It first redirects to "http://localhost:8181/app/esp/login.jsp" which then results in an exception "bean exceptionHeaderBean not found within scope".
So, some good progress (I'll go find that bean).
But how to get the same result from inside Eclipse?
I don't want to keep exporting a war to do each little incremental test.
Ah! You need to modify the Context Root (as noted above) - and then you need to (on the servers tab of Eclipse) "publish to server". Just stopping and starting are not enough.
Change the war file name that builds from app to esp, the first location after localhost:8080 is the deployed war application.

JBoss error report: HTTP Status 404 - Servlet is not available

I'm trying to create a very basic web project called "web" using MyEclipse and JBoss 5 as an application server. I've created one package called "pages" and inside it one servlet called "UserInterface". The problem is when I deploy the project and run the server I always get the error report: HTTP Status 404 - Servlet is not available.
This is a part of my web.xml:
<servlet>
<servlet-name>UserInterface</servlet-name>
<servlet-class>pages.UserInterface</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>UserInterface</servlet-name>
<url-pattern>/UserInterface</url-pattern>
</servlet-mapping>
and I'm navigating in the browser to: http://localhost:8080/web/UserInterface
What am I doing wrong here?
Thanks
404 means the URL you're trying to access does not point to an existing resource on your server. Check the address again, maybe the "web" (from http://localhost:8080/web/UserInterface) part is not correct because maybe the app is not deployed with that name. By default the app context name is derrived from the filename of the ".war" file such as if your file is "myApp.war", your app should be available at http://localhost:8080/myApp
Also, if you're actually deploying your war inside an .ear file that that ear file will contain an application.xml aplpication descriptor which can map your app file to a specific context, no-matter what the .war filename is, something like:
<module>
<web>
<web-uri>myApp.war</web-uri>
<context-root>theApp</context-root>
</web>
</module>
Finally, if you're autodeploying from Eclipse with the JBoss Eclipse connector, sometimes the thing bugs out and doesn't in fact deploy your app properly (even though the app itself is fine). If that's the case, trying manually deploying the .war to an application server and check it that way.
HTTP Status 404 - Servlet is not available.
The loading of the servlet has failed (if the servlet wasn't properly declared in web.xml or the URL was wrong, then you should instead have seen "404 - Resource not found"). Simply put, the <servlet-class> is wrong or the concrete class file isn't present in /WEB-INF/classes.
I still dont know what was wrong, but I've created another servlet called user, and in the web.xml I've added /servlet before the class and navigated to it in the browser (http://localhost:8080/web/servlet/User) and it worked.
<servlet>
<servlet-name>User</servlet-name>
<servlet-class>pages.User</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>User</servlet-name>
<url-pattern>/servlet/User</url-pattern>
</servlet-mapping>
Thanks everyone for your help!

Why is creating Servlets in Eclipse breaking my web.xml?

Being somewhat lazy, I was rather happy to find that I could create a new servlet source code by going New -> Servlet, instead of going New -> Class and then editing the class into a servlet.
However, I have discovered that every time I create a new servlet in Eclipse, Eclipse modifies my web.xml.
Specifically, it modifies the top element to:
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:javaee="http://java.sun.com/xml/ns/javaee"
xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
id="WebApp_ID" version="2.4">
(Linebreaks mine.)
This doesn't seem necessarily bad, but then it modifies various sub-elements by putting "javaee:" in front of their name, to indicate that these elements belong in that namespace.
For example, it changes
<display-name>ShowLifecycles</display-name>
to
<javaee:display-name>ShowLifecycles</javaee:display-name>
After which eclipse then complains about all the elements it modified, giving me notations like:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'javaee:display-name'. One of '{"http://
java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/
j2ee":icon, "http://java.sun.com/xml/ns/j2ee":distributable, "http://java.sun.com/xml/ns/j2ee":context-param, "http://
java.sun.com/xml/ns/j2ee":filter, "http://java.sun.com/xml/ns/j2ee":filter-mapping, "http://java.sun.com/xml/ns/
j2ee":listener, "http://java.sun.com/xml/ns/j2ee":servlet, "http://java.sun.com/xml/ns/j2ee":servlet-mapping, "http://
java.sun.com/xml/ns/j2ee":session-config, "http://java.sun.com/xml/ns/j2ee":mime-mapping, "http://java.sun.com/xml/ns/
j2ee":welcome-file-list, "http://java.sun.com/xml/ns/j2ee":error-page, "http://java.sun.com/xml/ns/j2ee":jsp-config, "http://
java.sun.com/xml/ns/j2ee":security-constraint, "http://java.sun.com/xml/ns/j2ee":login-config, "http://java.sun.com/xml/ns/
j2ee":security-role, "http://java.sun.com/xml/ns/j2ee":env-entry, "http://java.sun.com/xml/ns/j2ee":ejb-ref, "http://
java.sun.com/xml/ns/j2ee":ejb-local-ref, "http://java.sun.com/xml/ns/j2ee":service-ref, "http://java.sun.com/xml/ns/
j2ee":resource-ref, "http://java.sun.com/xml/ns/j2ee":resource-env-ref, "http://java.sun.com/xml/ns/j2ee":message-
destination-ref, "http://java.sun.com/xml/ns/j2ee":message-destination, "http://java.sun.com/xml/ns/j2ee":locale-
encoding-mapping-list}' is expected.
To make matters worse, when I use find and replace to delete all to "javaee:" which litters the file, Eclipse still complains about these even though they are no longer there. I must copy and paste the entire remaining file on top of itself to make these complaints go away.
I am sure Eclipse is trying to be useful, anticipating some desire or need for this namespace. How can I do either one of two things:
Make it stop doing this?
Take advantage of whatever it is trying to do, and make it work for me instead of against me?
I have never seen this before, but this indicates that your Eclipse project is really messed up. At least the web.xml root declaration makes no utter sense. It look like a mix of Servlet 2.4 and 2.5 specifications. Maybe Eclipse is getting confused because the root namespace (xmlns) is pointing to the Servlet 2.4 one (with j2ee URI) while the web project itself is set as Servlet 2.5 or newer (which should be using the one with javaee URI).
Also, when your web project is set to Servlet 3.0 during creation, by default no web.xml will be generated by Eclipse because of the new Servlet 3.0 annotations like #WebServlet, #WebFilter, etc.. which makes the web.xml superfluous. When you create new servlets by New > Servlet, Eclipse will already autogenerate those annotations. Probably you've attempted to create the web.xml yourself based on misinformation.
I'd suggest to backup some code if necessary, throw the whole project away and create a new one with the proper settings and do not touch the web.xml root declaration.
Assuming that you're using the latest Eclipse version, Helios SR1 for Java EE developers, rightclick Eclipse's Project Explorer, choose New > Dynamic Web Project and just fill the project name and keep everything default. Click Next until the last step and then tick Generate web.xml deployment descriptor checkbox to let Eclipse generate one. The root declaration should then look like this:
<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">
I was having a similar issue. I brought a web app over from an old Tomcat 6/Java 6 to Tomcat 7/Java 7. I copy and pasted existing web.xml body into the new 3.0 web.xml. Everything was fine until I added a servlet that had init-param, display-name, description and load-on-startup paramters. Eclipse flagged these params as broken with an "invalid content found at...". Thanks to stackoverflow, I found that load-on-startup had to come after init-params but only a RTFM for how they knew. My other params were still flagged as broken. This is what the web.xml header looked like when it was broken:
<?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"
version="3.0">
I changed the dtds to ns/j2ee and web-app_2_5.xsd, and Ecliupse stopped complaining. But its 2014 and we'll be moving to Tomcat 8 soon. So I dug in hard and found the docs for . In web-app 3.0 the parameters have to be in this order:
jee:descriptionGroup = any combo of 3 params: description, display-name, icon
servlet-name
chose 1: servlet-class or jsp-file
n number of init-params
load-on-startup
options: enabled, asynch-supported, run-as, security-role-ref, multipart-config
Once I put my params in order, Eclipse was happy with ns/javaee and web-app_3_0.xsd.
Move "display-name" as the first element under "servlet" tag, the validation error should go away.
Make sure the web.xml file starts with the tag followed by the tag
<?xml version="1.0" encoding="UTF-8"?>
In my case I had DOCTYPE tag and removing the DOCTYPE tag from the web.xml cleared me this error,
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >

Categories

Resources