The requested resource is not available error in Eclipse - eclipse

Hi all I am working on Eclipse 6.0.36 and using tomcat server.I am having an error said "The requested resource is not available" error 404.I had seen other post on same question and this is the common error that many solution that I could find on google. But still cannot solve my problem.. I am also still new working on eclipse.If there any information that you need just ask me, before vote down.. there are so long codes that I need to show..
some says this might be caused by servlet command.My servlet,from web_bkup.xml files looks like this:
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>SourceCodeServlet</servlet-name>
<url-pattern>*.source</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
surely there is lack of information that I give and you all can ask for it. But if there any solution that you all can shared.Hopefully can solve my error

Since you have only given little information, I try to answer under a few assumptions.
The 404 tells you that Tomcat could not find the resource e-system.jsp. I now assume that you have a project PM_Portal in Eclipse that you have successfully deployed to the Tomcat server, meaning there were no severe errors in the Tomcat log files which stopped the web application from starting. I also assume that PM_Portal is the root context of your application.
From that information, getting a 404 after successfull deployment means that there either is no JSP file e-system.jsp in the /WebContent folder of the Eclipse PM_Portal project or the Deployment Assembly configuration for you project lacks a mapping for the /WebContent folder. In order to check this, you can right-click on the project folder and choose Properties. Open the Deployment Assembly property and check that /WebContent is mapped to the root folder / of the target deployment.
Hope this is helpful.

Related

No project can be run from eclipse on Tomcat

When trying to create Dynamic Web project or even using old one( which used to work before) and running it on the tomcat(v8.0.35) server from my eclipse (mars.2 v4.5.2) I started getting Http status code 404 when accessing the recourse:
Here is my 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>hello</display-name>
<servlet>
<display-name>LoginServlet</display-name>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>com.javawebtutor.controller.LoginServlet</servlet-class>
</servlet>
<servlet>
<display-name>RegisterServlet</display-name>
<servlet-name>RegisterServlet</servlet-name>
<servlet-class>com.javawebtutor.controller.RegisterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>RegisterServlet</servlet-name>
<url-pattern>/RegisterServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
</web-app>
For reference, I have done everything step by step in this tutorial:
http://www.javawebtutor.com/articles/hibernate/mvc-appliction-using-servlet-jsp-and-hibernate.html
Java I'm using for the project is jdk1.8. For server - jre1.8
I'm 99% sure I've not deviated from the tutorial and something wrong must be with my Tomcat installation. As I mentioned it worked before on other projects I have not modified and it stopped working as well.
I have tried cleaning projects, cleaning Tomcat server, work directory, remove tomcat server, restart eclipse, add tomcat server again. I've even converted project into Maven project and tried to build with clean and install goals. Nothing helped.
Here is server location snippet:
Related answer here: Tomcat is not deploying my web project from Eclipse
And yes, I did try everything in there.
If it helps I'm developing on Win10
EDIT:
Project topology:
With the limited amount of info, I suggest you do the following:
Check if you have a login.jsp directly under your webapp or webContent(your tutorial uses this), because your welcome file in web.xml specifies this as your home page.
Try access http://localhost:8080/ instead of http://localhost:8080/hello/
Please provide your complete expanded project tree if the above does not solve your problem.
Also, here is one of my youtube video introducing how to set up a running java-web app with eclipse and tomcat. It is only a couple of minutes.
Following this tutorial makes sure you have a minimal java web project running, you can start from there if your problem cannot be fixed.

HTTP Status 404 when running simple RESTful web service in Java using Jersey

I am getting HTTP Status 404 when running simple RESTful web service in Java using Jersey. I am following the tutorial REST with Java (JAX-RS) using Jersey. I have copied all the jars that I downloaded from Jersey download site to WEB-INF/lib folder of my project(please see the screenshot for jars).
When I run the application from eclipse development environment Eclipse Console shows that Tomcat was started successfully. My web-app is deployed and I can see index.html coming up. But hitting http://localhost:8080/com.kj.rest.jersey.first/ gives Http Status 404.
My Environment:
Spring Tool Suite as my eclipse dev environment
Jersey 2.22.2 jars
Apache Tomcat v8.0
Please note I am not using Maven in my project and I also looked at other similar questions here but none of them solved my issue.
What am I missing, where should I look for the issue, which logs?
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<!-- Register resources and providers under com.vogella.jersey.first package. -->
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.*******</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
The mistake that I was making was to not specify the service name(specified by #Path annotation) in the URL. After doing that it worked.
So essentially the URL to hit should be http://localhost:8080/com.kj.rest.jersey.first/rest/path_from_rest_class and I missed the path_from_rest_class earlier.

java.lang.IllegalArgumentException: The main resource set specified [...] is not valid

I'm having trouble starting my Tomcat server, it used to work, but I did something wrong and now it throws me this exception:
Caused by: java.lang.IllegalArgumentException: The main resource set specified [E:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\workspace\j2eeapplication\target\j2eeapplication-0.0.1-SNAPSHOT] is not valid
at org.apache.catalina.webresources.StandardRoot.startInternal(StandardRoot.java:643)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 9 more
And this is my web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>J2EE Application Example</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_REFRESH_PERIOD</param-name>
<param-value>1</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>Resources Servlet</servlet-name>
<servlet-class>org.springframework.js.resource.ResourceServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resources Servlet</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
<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>*.jsf</url-pattern>
</servlet-mapping>
<filter>
<filter-name>charEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>charEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
I looked at different solutions over the forums, but nothing worked. Final option will be uninstalling tomcat and fresh installation, cause I read that might work. Thanks for the help in advance.
Seems like you have an outdated web application referenced in your Tomcat embeded server (You are using Tomcat As within Eclipse right?).
First checkout the deployed application within you server, and check the artifact name j2eeapplication-0.0.1-SNAPSHOT and version. You may need to remove it and clean your working directory the redeploy it and you should be safe.
For me, this was caused by a file permission issue. We use a different deployment strategy where I work (not something I can change) which means the webapp exists in a completely different directory to the normal Tomcat directory structure. The above exception occurred when the Tomcat runtime didn't have permission to access that directory.
I had this error when I was starting an application that was designed for Tomcat 8 using Tomcat 7.
A maven update did the trick for me.
Right click on your maven project:
Maven > Update Project...
Select All
Check "Force Update of Snapshots/Releases"
Click Ok
Now, right click on your server:
Clean...
Just in case this might help anyone who come later, I managed to start my tomcat8 server after close and reopen the front project in:
The main resource set specified [project-to-be-reopened]
In my case, it's maven dependency that's causing me this issue, updating maven-dependency will also help.
I had a similar issue. Just if someone else runs into this problem:
For me it was caused because I had an old project deployed, then closed that project. For several weeks, everything was fine, until I used the "Clean..." command of eclipse on that tomcat server. From that point on the famous The main resource set specified [...path to deployment location of this project...] is not valid was raised every time I tried to start Tomcat.
What solved this problem for me was just removing that old project from tomcat (Right click on that entry under Tomcat Server and choose "Remove").
I had a similar issue with one of the projects. I tried all the solutions to this question. None worked for me. I then double-clicked the Tomcat server to see the actual config. In there, under the tab "Modules", there is a list of projects currently associated with the Tomcat server. I could see that the "trouble-causing project" was listed there. I clicked on that and hit remove.
Then everything started to work just fine.
In my case with Tomcat 9 and using Eclipse under Windows, I somehow removed the application from the webapp directory under the Tomcat true server and could no longer start the standalone Tomcat server service. Got the same root cause text as the initial posted question. My solution was to copy the Eclipse version of the application (from the workspace's .metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps tree) to the C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps directory.
Note that I am not using Maven in my workspace, and it was just a standard Java Web project.
For me, the cause was another:
In .metadata.plugins\org.eclipse.wst.server.core\servers.xml the "server" element had no "list" element.
I added the "list" element:
<server auto-publish-setting="1" auto-publish-time="1" configuration-id="/Servers/Tomcat v9.0 Server 9091 ASM-config" deployDir="wtpwebapps" hostname="localhost" id="Tomcat v9.0 Server 9091 ASM" jrebel.old-auto-publish-setting="2" name="Tomcat v9.0 Server 9091 ASM" runtime-id="Apache Tomcat v9.0" server-type="org.eclipse.jst.server.tomcat.90" server-type-id="org.eclipse.jst.server.tomcat.90" start-timeout="9000" stop-timeout="30" testEnvironment="true" timestamp="4">
<list key="modules" value0="adsuite-market::org.eclipse.jst.j2ee.server:adsuite-market::jst.web::2.4"/>
and restarted Eclipse. Then it worked as normal again.

Welcome file list issue in Jetty, works fine with Jboss

Issue I'm facing is as follows.
In Jboss I have web.xml as follows...
<servlet>
<servlet-name>servlet</servlet-name>
<servlet-class>com.exp.ServletExample</servlet-class>
<servlet-mapping>
<servlet-name>servlet</servlet-name>
<url-pattern>/test/hello</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>NewFile.html</welcome-file>
</welcome-file-list>
</servlet>
And when I try _http://localhost:8800/SimpleServletProject/ - [SimpleServletProject is the war file name] then my welcome file i.e. NewFile.html is getting displayed.
If I put the same war on jetty and type _http://localhost:8080/SimpleServletProject/ it doesn't work... I get 404 error saying
HTTP ERROR 404
Problem accessing /SimpleServletProject/index.jsp. Reason: not found
My war structure is as follows
SimpleServletProject.war
-META-INF
-WEB-INF
-NewFile.html
I'm struggling with this issue, any help would be much appreciated.

gwt - problem accessing servlet in inherited module

I'm trying to divide my app into modules and I'm stuck with this problem:
I have a widget MapServiceWidget in one module called "webvisualisation" that uses the RPC to get the data from MapService Rpc interface. I'm inheriting this module in another GWT module called "led" (I packed "webvis..." into jar with sources, added in module "led" deffinition). Then I try to create this widget in the second ("led") module and get message
"Problem accessing /led/mapservice reason NOT FOUND".
And sure it can't find it cause mapservice is defined in inherited "webvisualisation" module.
The question is why it's looking for this servler implementation in "led" module not in "webvisualisation" where it's defined? I checked all module definitions and web.xml files several times and consulted documentations, it seems ok.. but it's not. If my description is not clear I can post some config/source files.
This is web.xml for webvisualisation module
<!-- Servlets -->
<servlet>
<servlet-name>mapservice</servlet-name>
<servlet-class>pl.gmike.webvis.server.MapServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mapservice</servlet-name>
<url-pattern>/webvisualisation/mapservice</url-pattern>
</servlet-mapping>
And for led it's just ordinary generated sample file
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>pl.led.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/led/greet</url-pattern>
</servlet-mapping>
Seems that you're bumping into a classpath problem. Maybe check that your webvisualisation.jar is in the WEB-INF/lib directory of your web application.
I got it working. I just added servlet and servlet mapping entries to "led" modules web.xml so it look like this now:
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>pl.led.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet>
<servlet-name>mapservice</servlet-name>
<servlet-class>pl.gmike.webvis.server.MapServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/led/greet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>mapservice</servlet-name>
<url-pattern>/led/mapservice</url-pattern>
</servlet-mapping>
As You can see the mapservice servlet is mapped here to /led/mapservice URL where GWT seems to look for it, unlike in original "webvisualisation" module web.xml where it was mapped to /wevisualisation/mapservice .
I'm not very satisfied with this solution, it works but it requires adding a servlet mapping in WebApps web.xml for every servlet in inherited module that I want to use or that is used somewhere in this inherited module.
Still I would like to know why servlet definitions and mappings from inherited modules are not included in WebApps web.xml during compilation/linking... I think it should work without such hacks, so there's something I'm doing wrong.