I built an angular 2 application that was communicating through a custom rest api. I modified portal-security-spring.xml to remove security from the endpoints. I was able to add/update/delete and find data. Since upgrading I receive 404 errors while trying to access my end points.
I’ve attached my web.xml and portal-security-spring.xml and other in hopes that it’ll help you figure out what broke during the upgrade.
I followed the documentation on how to use the REST API 2.
The instructions requested me to create a file call rest-dispatcher-spring.xml. I added this to the local-app.properties within the web-inf folder of app-portal. How do I know if the rest-dispatcher-spring.xml gets loaded correctly?
Can you please help me? Do you guys have a migration guide, or a good sample project that would help me identify why this worked in 6.2 but doesn’t now?
Did you change your controllers mapping when you migrated to 6.3 or their URLs started with /rest when your project was on CUBA 6.2?
I’m asking this because since v6.3 there are two dispatcher servlets. If you take a look at the web.xml you will find that requests with the /rest/* pattern are processed by the CubaRestApiServlet and other requests by the CubaDispatcherServlet. Different servlets mean different Spring contexts - so your issues may be because of that.
I went through your example and modified my project to match. I’m still getting this error when trying to access any of my endpoints.
<!DOCTYPE html>
<html>
<head>
<title>Apache Tomcat/8.0.35 - Error report</title>
<style type="text/css">H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}</style>
</head>
<body>
<h1>HTTP Status 500 - No WebApplicationContext found: no ContextLoaderListener or DispatcherServlet registered?</h1>
<div class="line"></div>
<p>
<b>type</b> Exception report
</p>
<p>
<b>message</b>
<u>No WebApplicationContext found: no ContextLoaderListener or DispatcherServlet registered?</u>
</p>
<p>
<b>description</b>
<u>The server encountered an internal error that prevented it from fulfilling this request.</u>
</p>
<p>
<b>exception</b>
</p>
<pre>java.lang.IllegalStateException: No WebApplicationContext found: no ContextLoaderListener or DispatcherServlet registered?
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:252)
</pre>
<p>
<b>note</b>
<u>The full stack trace of the root cause is available in the Apache Tomcat/8.0.35 logs.</u>
</p>
<hr class="line">
<h3>Apache Tomcat/8.0.35</h3>
</body>
</html>
In the CubaRestApiServlet.getContextConfigLocation() method the value of the cuba.restSpringContextConfig property is processed. The rest-dispatcher-spring.xml must be specified in this property