I have built an application using Spring with Eclipse IDE. When I launch the project from Eclipse IDE everything is fine but when I package the maven project as a war file and deployed to separate tomcat I have this issue
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
This is a configuration snippet from my xml file
<!-- View Resolver -->
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/pages/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
I am trying to access this controller
@RequestMapping(value = {"/welcome", "/"})
public String defaultPage() {
return "Web Service data successfuly consumed";
}
anyone with an idea why this is failing on deployed to tomcat?
I struggled with this problem many times.
The solution I am currently using is weather the webapp(or the folder where you kept the views like jsp) is under deployment assembly.
To do so Right click on the project > Build Path > Configure Build path > Deployment Assembly > Add(right hand side) > Folder > (add your jsp
folder. In default case it is src/main/webapp
)
You could also get this error after you did everything correct but on the JSP you put the anchor tag the old fashion(I am adding this incase if it help anybody else with the same issue).
I had the following syntax on the jsp. <a href="/mappedpath">TakeMeToTheController</a>
and I kept seeing the error mentioned in the question. However changing the tag into the one shown below solved the issue.
<a href=" <spring:url value="/mappedpath" /> ">TakeMeToTheController</a>
If you are developing spring boot application add "SpringBootServletInitializer" as shown in following code to your main file. Because without SpringBootServletInitializer Tomcat will consider it as normal application it will not consider as Spring boot application
@SpringBootApplication
public class DemoApplication extends *SpringBootServletInitializer*{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(DemoApplication .class);
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication .class, args);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With