Reputation: 1262
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>springsecuritydemo</display-name>
<!-- <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list> -->
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/DispatcherServlet</url-pattern>
</servlet-mapping>
</web-app>
offers-sevlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:component-scan base-package="com.spring.security.web"></context:component-scan>
<mvc:annotation-driven></mvc:annotation-driven>
<bean name="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsps/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>
what is wrong here? i cannot access home.jsp. i am actually watching a tutorial in spring 3.0 and i have done exactly shown in video. can anyone point my mistake here?
Upvotes: 15
Views: 324796
Reputation: 19
I just solved this problem within my project. Turned out my connection string had a typo and differed from the valid database auth. credentials. Dumb mistake on my part, hopefully somebody else saves time by reading this.
Upvotes: 0
Reputation: 1
If you have error the origin "server did not find a current representation for the target resource or is not willing to disclose that one exists."
Then check the file position given here:
Upvotes: 0
Reputation: 1204
The website was running fine then suddenly it started to display this same error 404 message (The origin server did not find a current representation for the target resource or is not willing to disclose that one exists), Perhaps because of switching servers back and forward from Tomcat 9 to 8 and 7
In my case, i only had to update the project which was causing this error then restart the specific tomcat version. You may also need to Maven Clean and Maven Install after the "Maven Update Project"
Upvotes: 0
Reputation: 312
Was following one of training with Spring webmvc 4.2.3, while I'm using Spring webmvc 5.2.3 they suggested to create a form
<form:form modelAttribute="aNewAccount" method="get" action="/accountCreated">
that was causing the "disclose" error.
Altered as below to make it work. Looks like method above was the culprit.
<form:form modelAttribute="aNewAccount" action="accountCreated.html">
in fact, exploring further, method="post" in form annotation would work if properly declared:
@RequestMapping(value="/accountCreated", method=RequestMethod.POST)
Upvotes: 0
Reputation: 1
I had the same problem and spent about 6 hours to solve it. I didn't find that answer for exactly my situation so maybe it could be useful for somebody.
When I created project, I pointed GroupId in pom.xml as "myproject.myapp" but I didn't create first "prime" package with that name in the project, where would be other packages inside of this main package (like /src/main/app etc). When I created prime package "myproject.myapp" and moved other packages inside of it, the problem was solved.
Upvotes: 0
Reputation: 1
In case of springboot app on tomcat, I needed to create an additional class as below and this worked:
@SpringBootApplication
public class SpringBootTomcatApplication extends SpringBootServletInitializer {
}
Upvotes: 0
Reputation: 2692
I added yellow highlighted package and now my view page is accessible. in eclipse when we deploy our war it only deploy those stuff mention in the deployment assessment.
We set Deployment Assessment from right click on project --> Properties --> Apply and Close....
Upvotes: 4
Reputation: 12170
I was running the project through Intellij and this got this error after I stopped the running server and restarted it. Killing all the java processes and restarting the app helped.
Upvotes: 1
Reputation: 21
There is one more way to solve this problem. 1)Go to Project Explorer. Go to the target folder of your project, right-click and delete the target folder. 2)Right-click on your project, select run as Maven Build. 3)After you get Build Success on the console; right click on the project folder and select refresh. After performing the above steps, try to run your project.Your problem should be solved now.
Upvotes: 1
Reputation: 11
I had this problem in InteliJ. I went to: Edit -> Configuration -> Deployment -> EditArtifact:
Then there where yellow problems, I just clicked on fix two times and it works. I hope this will help someone.
Upvotes: 1
Reputation: 2063
I had missing application context in the Tomcat Run\Debug configuration:
Adding it, solved the problem and I got the right response instead of "The origin server did not find..."
Upvotes: 6
Reputation: 1
org.glassfish.jersey.servlet.ServletContainer.class
here remove .class
org.glassfish.jersey.servlet.ServletContainer now you wont get
Upvotes: 0
Reputation: 1262
the problem is in url pattern of servlet-mapping.
<url-pattern>/DispatcherServlet</url-pattern>
let's say our controller is
@Controller
public class HomeController {
@RequestMapping("/home")
public String home(){
return "home";
}
}
when we hit some URL on our browser. the dispatcher servlet will try to map this url.
the url pattern of our serlvet currently is /Dispatcher
which means resources are served from {contextpath}/Dispatcher
but when we request http://localhost:8080/home
we are actually asking resources from /
which is not available.
so either we need to say dispatcher servlet to serve from /
by doing
<url-pattern>/</url-pattern>
our make it serve from /Dispatcher by doing /Dispatcher/*
E.g
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID"
version="3.1">
<display-name>springsecuritydemo</display-name>
<servlet>
<description></description>
<display-name>offers</display-name>
<servlet-name>offers</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>offers</servlet-name>
<url-pattern>/Dispatcher/*</url-pattern>
</servlet-mapping>
</web-app>
and request it with http://localhost:8080/Dispatcher/home
or put just /
to request like
http://localhost:8080/home
Upvotes: 14