I want to run my first web application and I am getting this error
I have searched the web but I cant figure out what the problem is.
I have trying googling what nesting is but I could not understand what it is talking about
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from ServletContext resource [/WEB-INF/todo-servlet.xml]; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/todo-servlet.xml]
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
web.xml
The path to the todo-servlet is configured here.
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/todo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/spring-mvc/*</url-pattern>
</servlet-mapping>
I have created todo-servlet.xml in src/main/webapp/WEB-INF/todo-servlet.xml
but I am still getting file not found exception
Refer below link and follow step by step check configuration in xml as well as in class and file path locations.
http://websystique.com/springmvc/spring-4-mvc-helloworld-tutorial-full-example/
This usually happens in a Spring Web application, when a DispatcherServlet is set up in the web.xml for Spring MVC. By default, Spring will look for a file called exactly springMvcServlet-servlet.xml in the /WEB-INF directory of the web application.mvc-servlet.xml file that indeed exists under /WEB-INF.
or it may happen because when something in the application points to an XML resource that doesn't exist, or is not placed where it should be.
Create the file and to place it under the /src/main/resources directory of the project – this way, the file will exist on the classpath.
Related
tried adding servlet mapping in web.xml as shown below but unable to load the page.
Here is the directory structure for webapp|->html|->hello.jsp or hello.html (tried with both jsp and html)
Click here to see directory structure
web.xml file
<servlet>
<servlet-name>hello</servlet-name>
<jsp-file>/html/hello.jsp</jsp-file>
</servlet>
<servlet-mapping>
<servlet-name>hello</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping>
tried with multiple path in jsp-file tag for example /webapp/html/hello.jsp but end up with ERROR: javax.servlet.ServletException: missing jspFile:
This error at least tells servlet dispatcher is able to get the request /hello . but further its failing to load JSP or HTML page.
I'm trying to get this tutorial to work
https://avaldes.com/file-upload-example-using-restful-web-service-with-jax-rs-and-jersey/comment-page-1/#comment-319
This looks like an eclipse project. I downloaded it and imported it into eclipse. How to run it? There was no "run on server" or "run as web page". The only options available was "run as application" and "run as applet", neither of which this is. My project tree looks just like theirs except for JRE System Library, Pivotal tc Server, and Web App Libraries. I gave up.
Next I went to NetBeans and imported the eclipse project. Clicked green Run button and up popped the web page, running on tomcat. But the url showed http://localhost:8084/, not localhost:8084/RestfulFileUploadExample.
I clicked the Browse... button and grabbed a file. Then clicked Upload File button. It put the following url into the browser: http://localhost:8084/RestfulFileUploadExample/rest/files/upload but got "The requested resource is not available. Now what?
there are issue in web.xml file check this file again it should be on WEB-INF folder and then check mapping of class file is proper or not. you can use this bellow code :-
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:Beans.xml</param-value>
</context-param>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>com.demo.services</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
I am using tomcat7 and have a small Java application that needs to be deployed under ROOT. The reason for this has to do with the client's inability to specify the webapp's proper context path at this time.
I have an index.html in this webapp and my issue is that when I deploy the application under the webapp name - ${catalina_home}/mywebapp - the index.html renders without a problem when I navigate to http://localhost:8080/mywebapp.
However, when I deploy it under ROOT - ${catalina_home}/ROOT - the index.html inside does not render when I navigate to http://localhost:8080/. The error is 404 not found. Does this have anything to do with overriding tomcat's default page?
My web.xml:
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/</param-value>
</context-param>
...
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
...
Can someone explain why this is so?
Thanks in advance.
UPDATE: I see in this stackoverflow Display html page in tomcat from maven RESTEasy webapp that the issue may be that my filter says anything under /* should go to the servlet. I tried to set up a default servlet for .html pages, but that does not see to help yet...
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
How do you deploy the app as ROOT? If you package as war file, to deploy as ROOT, change the war file to ROOT.war and have the index.html under the ROOT folder. Also check the web.xml under WEB-INF to have the welcom page set to index.html as below:
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
</welcome-file-list>
I found the answer here - http://docs.jboss.org/resteasy/docs/3.0.2.Final/userguide/html_single/:
"The downside of running Resteasy as a Servlet is that you cannot have static resources like .html and .jpeg files in the same path as your JAX-RS services. Resteasy allows you to run as a Filter instead. If a JAX-RS resource is not found under the URL requested, Resteasy will delegate back to the base servlet container to resolve URLs."
I created a filter instead and I was able to serve both the static page and my regular REST resources.
I'm trying to test a war that I deployed in Tomcat 7, however it seems its missing a xml configuration:
web.xml
<servlet>
<servlet-name>StorageEngine</servlet-name>
<servlet-class>com.jpeterson.littles3.StorageEngine</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:StorageEngine-servlet.xml</param-value>
</init-param>
</servlet>
I have downloaded the StorageEngine-servlet.xml separately, to be able to satisfy this init-param where do I need put the
xml file in the \webapps\littleS3-2.3.0\WEB-INF folder, just relative to the web.xml? Or?
No, it belongs in WEB-INF/classes of your WAR file. That is always in the CLASSPATH of a Tomcat app, loaded by the app class loader.
Given the mapping it would need to be placed in the root of your classpath. Try placing it within the root of any source folder
I am migrating a Jsp-servlet based Java project that was hosted in websphere to tomcat. Following init-param is in web.xml inside a filter definition. I moved the properties file src folder which is classpath. How to change the following in the web.xml. Can I define properties file as init-param because most of the answers I saw has used context-param to define properties file. I dont think its an option to me as the existing application needs the properties file to be init-param.
<init-param>
<param-name>configPath</param-name>
<param-value>/pws/WebSphere/AppServer/properties/fyp/filterConfig/filter.properties</param-value>
</init-param>
I tried
<init-param>
<param-name>configPath</param-name>
<param-value>classpath:filter.properties</param-value>
</init-param>
It did not work.Thank you in advance,
Check your servlet implementation,you will find something like the following:
get the context root path from ServletContext;
append the property file path get from init-param;
do some file operation
As you asked,you can config the servlet as :
<init-param>
<param-name>configPath</param-name>
<param-value>filter.properties</param-value>
</init-param>
then change your code to
get the file name from init-param
open the stream this.getClass().getClassLoader().getResourceAsStream("fileName");
do some file operation