how to make spring mvc 4 and angular run in WebSphere 8
<p>I have an application which runs perfectly on TomCat 8 but it crashes when deployed to Websphere Liberty 8.5. </p>

<p>The first Websphere error was org.springframework.web.servlet.view.tiles3.TilesConfigurer$CompositeELResolverImpl missed then I added tiles dependency even though the application doesn't use tiles as far as I can see. After I added tiles dependency, the error message desapear but the application keeps crashed in Websphere. I can open the well-come page (an Angular table) but when I clicked in Add nothing happens. I don't get an error message in Eclipse console as well (I am debuging it).</p>

<p>All application can be downloaded from here <a href="http://websystique.com/springmvc/spring-mvc-4-angularjs-example/" rel="nofollow">http://websystique.com/springmvc/spring-mvc-4-angularjs-example/</a> (future readers might take advantage to know that I have to fix two issues in such example before running in Eclipse: 1 Open the Navigator view, expand the .settings folder, open the file org.eclipse.wst.common.project.facet.core.xml and manually set the Java version and jst.web 2 Add compile java version in pom.xml).</p>

<p>I could add the entire applcation here but I understand there is nothing wrong with such application otherwise it wouldn't run in Tomcat 8. Probably I am missing something related to Websphere. I am using war because I am sure that Websphere Liberty Profile accepts war (Production versions only accept EAR)</p>

<p>So my straight question: what must I do in order to run Spring MVC 4 + Angular in Websphere 8 with Java 7? (Please don't compare server options: I must use Websphere or give up of any no Websphere compliance framework)</p>

<p>I remenber sometime ago facing certain issue with json functionalities in websphere and it was fixed after added some feature but I don't remenber exactly which one and that case there wasn't Angular at all.</p>

<p>A last comment, I installed certain Angular Extension in Chrome and it shows property undefined. I read answers around but I don't think they are related to my scenario. I am almost sure that there must be some extra configuration/plugin/jar/etc missed in Websphere.</p>

<p>Error in Scope Inspector (Chrome)</p>

<pre><code>"Cannot read property '__proto__' of undefined"
stack
:
(...)
get stack
:
get stack()
set stack
:
set stack()
__proto__
:
Error
</code></pre>

<p>server.xml</p>

<pre><code>&lt;server description="new server"&gt;
    &lt;!-- Enable features --&gt;
    &lt;featureManager&gt;
        &lt;feature&gt;javaee-7.0&lt;/feature&gt;
        &lt;feature&gt;localConnector-1.0&lt;/feature&gt;
    &lt;/featureManager&gt;
    &lt;!-- Automatically expand WAR files and EAR files --&gt;
    &lt;applicationManager autoExpand="true"/&gt;
    &lt;applicationMonitor updateTrigger="mbean"/&gt;
    &lt;webApplication id="Spring4MVCAngularJSExample" location="Spring4MVCAngularJSExample.war" name="Spring4MVCAngularJSExample"/&gt;
    &lt;httpSession idLength="28"&gt;&lt;/httpSession&gt;
&lt;/server&gt;
</code></pre>

<p>Features of Websphere Liberty 8.5 Java EE 7 (wlp-javaee7-8.5.5.9). It is showed when right-clicked in websphere and then clicked in Product Info:</p>

<pre><code>appClientSupport-1.0 [1.0.0]
appSecurity-2.0 [1.0.0]
appSecurityClient-1.0 [1.0.0]
batch-1.0 [1.0.0]
beanValidation-1.1 [1.0.0]
bluemixUtility-1.0 [1.0.0]
cdi-1.2 [1.0.0]
collectiveMember-1.0 [1.0.0]
concurrent-1.0 [1.0.0]
distributedMap-1.0 [1.0.0]
ejb-3.2 [1.0.0]
ejbHome-3.2 [1.0.0]
ejbLite-3.2 [1.0.0]
ejbPersistentTimer-3.2 [1.0.0]
ejbRemote-3.2 [1.0.0]
el-3.0 [3.0.0]
federatedRegistry-1.0 [1.0.0]
j2eeManagement-1.1 [1.1.0]
jacc-1.5 [1.0.0]
jaspic-1.1 [1.0.0]
javaMail-1.5 [1.5.0]
javaee-7.0 [7.0.0]
javaeeClient-7.0 [1.0.0]
jaxb-2.2 [1.0.0]
jaxrs-2.0 [1.0.0]
jaxrsClient-2.0 [1.0.0]
jaxws-2.2 [1.0.0]
jca-1.7 [1.0.0]
jcaInboundSecurity-1.0 [1.0.0]
jdbc-4.1 [1.0.0]
jndi-1.0 [1.0.0]
jpa-2.1 [1.0.0]
jsf-2.2 [1.0.0]
json-1.0 [1.0.0]
jsonp-1.0 [1.0.0]
jsp-2.3 [1.0.0]
ldapRegistry-3.0 [1.0.0]
localConnector-1.0 [1.0.0]
managedBeans-1.0 [1.0.0]
mdb-3.2 [1.0.0]
monitor-1.0 [1.0.0]
requestTiming-1.0 [1.0.0]
restConnector-1.0 [1.0.0]
servlet-3.1 [1.0.0]
sessionDatabase-1.0 [1.0.0]
ssl-1.0 [1.0.0]
wasJmsClient-2.0 [1.0.0]
wasJmsSecurity-1.0 [1.0.0]
wasJmsServer-1.0 [1.0.0]
webCache-1.0 [1.0.0]
webProfile-7.0 [7.0.0]
websocket-1.1 [1.0.0]
</code></pre>

<p>Pom</p>

<pre><code>&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
    &lt;groupId&gt;com.websystique.springmvc&lt;/groupId&gt;
    &lt;artifactId&gt;Spring4MVCAngularJSExample&lt;/artifactId&gt;
    &lt;packaging&gt;war&lt;/packaging&gt;
    &lt;version&gt;1.0.0&lt;/version&gt;
    &lt;name&gt;Spring4MVCAngularJSExample Maven Webapp&lt;/name&gt;

    &lt;properties&gt;
        &lt;springframework.version&gt;4.2.0.RELEASE&lt;/springframework.version&gt;
        &lt;jackson.version&gt;2.5.3&lt;/jackson.version&gt;
    &lt;/properties&gt;

    &lt;dependencies&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
            &lt;artifactId&gt;tiles-extras&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
            &lt;scope&gt;compile&lt;/scope&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
            &lt;artifactId&gt;tiles-api&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
            &lt;artifactId&gt;tiles-core&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.apache.tiles&lt;/groupId&gt;
            &lt;artifactId&gt;tiles-jsp&lt;/artifactId&gt;
            &lt;version&gt;3.0.0&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
            &lt;version&gt;${springframework.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;org.springframework&lt;/groupId&gt;
            &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
            &lt;version&gt;${springframework.version}&lt;/version&gt;
        &lt;/dependency&gt;

        &lt;dependency&gt;
            &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;
            &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;
            &lt;version&gt;${jackson.version}&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
            &lt;artifactId&gt;javax.servlet-api&lt;/artifactId&gt;
            &lt;version&gt;3.1.0&lt;/version&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
            &lt;groupId&gt;javax.servlet&lt;/groupId&gt;
            &lt;artifactId&gt;jstl&lt;/artifactId&gt;
            &lt;version&gt;1.2&lt;/version&gt;
        &lt;/dependency&gt;


    &lt;/dependencies&gt;


    &lt;build&gt;
        &lt;pluginManagement&gt;
            &lt;plugins&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
                    &lt;version&gt;3.1&lt;/version&gt;
                    &lt;configuration&gt;
                        &lt;source&gt;1.7&lt;/source&gt;
                        &lt;target&gt;1.7&lt;/target&gt;
                    &lt;/configuration&gt;
                &lt;/plugin&gt;
                &lt;plugin&gt;
                    &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
                    &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
                    &lt;version&gt;2.4&lt;/version&gt;
                    &lt;configuration&gt;
                        &lt;warSourceDirectory&gt;src/main/webapp&lt;/warSourceDirectory&gt;
                        &lt;warName&gt;Spring4MVCAngularJSExample&lt;/warName&gt;
                        &lt;failOnMissingWebXml&gt;false&lt;/failOnMissingWebXml&gt;
                    &lt;/configuration&gt;
                &lt;/plugin&gt;
            &lt;/plugins&gt;
        &lt;/pluginManagement&gt;

        &lt;finalName&gt;Spring4MVCAngularJSExample&lt;/finalName&gt;
    &lt;/build&gt;
&lt;/project&gt;
</code></pre>

<p>Spring Configurations:</p>

<pre><code>package com.websystique.springmvc.configuration;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewResolverRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "com.websystique.springmvc")
public class HelloWorldConfiguration extends WebMvcConfigurerAdapter{

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/views/");
        viewResolver.setSuffix(".jsp");
        registry.viewResolver(viewResolver);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/static/**").addResourceLocations("/static/");
    }

}
</code></pre>

<p>and</p>

<pre><code>package com.websystique.springmvc.configuration;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;


public class CORSFilter implements Filter {

    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
        HttpServletResponse response = (HttpServletResponse) res;
        response.setHeader("Access-Control-Allow-Origin", "*");
        response.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE");
        response.setHeader("Access-Control-Max-Age", "3600");
        response.setHeader("Access-Control-Allow-Headers", "x-requested-with, Content-Type");
        chain.doFilter(req, res);
    }

    public void init(FilterConfig filterConfig) {}

    public void destroy() {}

}
</code></pre>

<p>Spring Initializer:</p>

<pre><code>package com.websystique.springmvc.configuration;

import javax.servlet.Filter;

import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

public class HelloWorldInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {

    @Override
    protected Class&lt;?&gt;[] getRootConfigClasses() {
        return new Class[] { HelloWorldConfiguration.class };
    }

    @Override
    protected Class&lt;?&gt;[] getServletConfigClasses() {
        return null;
    }

    @Override
    protected String[] getServletMappings() {
        return new String[] { "/" };
    }

    @Override
    protected Filter[] getServletFilters() {
        Filter [] singleton = { new CORSFilter() };
        return singleton;
    }

}
</code></pre>

<p>**** Edited in 02/May/2016 at 10PM Brazilia time</p>

<p>I was guessing the issue was about some missed configuration related to websphere, so I tried:</p>

<pre><code>&lt;featureManager&gt;
    &lt;feature&gt;javaee-7.0&lt;/feature&gt;
    &lt;feature&gt;localConnector-1.0&lt;/feature&gt;
    &lt;feature&gt;jsp-2.3&lt;/feature&gt;
    &lt;feature&gt;jaxrs-2.0&lt;/feature&gt;
    &lt;feature&gt;json-1.0&lt;/feature&gt;
    &lt;feature&gt;managedBeans-1.0&lt;/feature&gt;
    &lt;feature&gt;beanValidation-1.1&lt;/feature&gt;
    &lt;feature&gt;servlet-3.1&lt;/feature&gt;
&lt;/featureManager&gt;
</code></pre>

<p>Nevertheless, none of them was the issue. Sily as it can be, I didn't note that there was some hard code port number on it.</p>

<pre><code>App.factory('UserService', ['$http', '$q', function($http, $q){
    return {
            fetchAllUsers: function() {
                    return $http.get('http://localhost:8080/Spring4MVCAngularJSExample/user/')
...
</code></pre>

<p>Hopefully, it can be one day be usefull to someone. 
To sum up, there is nothing wrong with default features of Websphere Liberty Profile. I didn't note some hard code port numbers.</p>