I have setup Javamelody in my Tomcat container to view the statistics of my currently used website.
My website is configured in server.xml as follows and is not deployed as war but the classes and the jsp files are manually copied to "/dun/student/webapps" location as shown in the mapping:
<Context path="/stud" docBase="/dun/student/webapps" crossContext="false" debug="0" reloadable="true">
</Context>
I have copied the jar files javamelody.jar and jrobin-1.5.9.1.jar in the lib directory of my web-app.
Now I have modified the web.xml of my web-app to have the following lines and I have pasted it above my servlet declarations.
<filter>
<filter-name>monitoring</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>monitoring</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
I have restarted tomcat as well.
Now I'm trying to access my java melody statistics using the url:
http://student.studentgrade.com:8080/stud/monitoring
But I'm getting a 404 status saying requested resource is not available.
Now my web app which has many jsp files which were working fine too cannot be accessed and there too I'm getting a 404 error.
http://student.studentgrade.com:8080/stud/hello.jsp
But if I remove those lines which I added for javamelody in the web.xml file my jsp can be accessed.
What am I doing wrong here.
Please advice how I can fix this.
Do you add
net.bull.javamelody.SessionListener
into your web.xml?
Related
I'm trying to deploy a second web application to a Wildfly server currently hosting a single application. I've made the following modifications to standalone.xml (see Accessing Multiple web applications on Jboss7 or Wildfly - my need is essentially the same):
Under <subsystem xlmns="urn:jboss:domain:undertow:8.0>, added
<server name="dispatch-server">
<http-listener name="default" socket-binding="dispatch"/>
<host name="dispatch-host" default-web-module="Dispatch.war" alias="Dispatch.com">
</host>
</server>
Next, under <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">, added
<socket-binding name="dispatch" port="${jboss.https.port:8081}"/>
Finally, under <Deployments>, added
<deployment name="Dispatch.war" runtime-name="Dispatch.war">
<fs-archive path="${jboss.home.dir}/standalone/deployments/Dispatch.war" />
</deployment>
web.xml content for the deployed Dispatch.war:
<servlet>
<servlet-name>DispatchServlet</servlet-name>
<servlet-class>blah.blah.blah.DispatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DispatchServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
I wrote a little application to test connecting to the servlet, using "http://localhost:8081", but I get an HTTP 404 error. I've tried additionally with "http://localhost:8081/DispatchServlet" with no changes.
I found other tutorials mentioning the need for a jboss-web.xml file bundled with Dispatch.war, so I added a barebones one that looks like:
<jboss-web>
<context-root>/</context-root>
</jboss-web>
It didn't impact the behavior I was seeing. I also tried changing the context-root to "DispatchServlet" and then hitting "http://localhost:8081/DispatchServlet" with nothing.
Is there something obvious I'm goofing on?
I think you are over complicating the issue. If you want to deploy multiple web apps, just drop ear war within the deployments directory. When they deploy the log shows their context path, then access any content relative to that path, e.g
/war1/DispatchServlet
/war2/DispatchServlet
If using different paths is not acceptable, then in order to do as you are trying, you need to follow the guides that explain how to use ROOT.war files and the associated changes to standalone-full.xml to disable the inbuilt default
I had configured virtual directories in glassfish3.x over which I could write filters.
For an example I could access files at c:/web from http://localhost/TestApp/web over which I could also place a filter at my web app's web/xml file with
<filter-mapping>
<filter-name>dir_filter</filter-name>
<url-pattern>/web/*</url-pattern>
</filter-mapping>
Unfortunately Tomcat 8.0 is not allowing me to write a filter above that. It simply ignores the filters and shows the content in the web directory.
The problem is anybody can access all of the files in the "web" folder.
Any how can we place filter over the virtual directories.
FYI - i have made the web app named "TestApp" and the virtual config is located at "$tomcat_dir/conf/Catalina/localhost" directory with the file name "TestApp#web.xml" file and having the content
<?xml version='1.0' encoding='utf-8'?>
<Context docBase="C:/web" debug="0" privileged="true"></Context>
Regards
The context XML file TestApp#web.xml is mapping requests to /TestApp/web/... to the webapp. In the webapp, paths are relative to that, so /TestApp/web/x.txt is path /x.txt to the webapp, and will serve file C:/web/x.txt.
Change the filter to /*, so all requests are filtered, incl. the request for /x.txt.
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.
Here are my relevant files.
POM file: http://pastebin.com/ZPTWifys
web.xml file: http://pastebin.com/7kd8Et6Y
JAX-RS resource: http://pastebin.com/ddwDEwNK
I do a mvn clean install - works fine. I point my browser to localhost:8080/firstjersey. I get the "Hello World" index page. Then I try pointing my browser to localhost:8080/firstjersey/resources/test, and I get nothing. I try localhost:8080/resources/test, and get nothing. The problem is that I am simply unable to access my resource. I don't know if it's even being scanned by the servlet container. But everything in my configuration looks right. What's wrong?
I appreciate all help in advance.
Your servlet mapping should include a wildcard:
<servlet-mapping>
<servlet-name>My Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
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!