Problem integrating with spring

Hi people!
I’m having problems integrating spring with Vaadin following the wiki IV - Configuring and Using Vaadin Spring without Spring Boot and I can’t get it to work. The error I recieve is:

INFO: No Spring WebApplicationInitializer types detected on classpath jun 01, 2015 11:07:38 PM org.apache.catalina.core.StandardContext listenerStart SEVERE: Error configuring application listener of class com.vaadinapp.vaadinapp.MyVaadinUI$MyListener java.lang.InstantiationException: com.vaadinapp.vaadinapp.MyVaadinUI$MyListener at java.lang.Class.newInstance(Class.java:359) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:138) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4733) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5291) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633) at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:657) at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:536) at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1462) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:301) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801) at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1445) at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:860) at org.apache.catalina.manager.ManagerServlet.doGet(ManagerServlet.java:357) at javax.servlet.http.HttpServlet.service(HttpServlet.java:621) at javax.servlet.http.HttpServlet.service(HttpServlet.java:728) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:581) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:936) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1004) at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744) My UI looks like this

@Theme("mytheme")
@SuppressWarnings("serial")
@SpringUI
public class MyVaadinUI extends UI implements LoginListener
{

    @WebListener
    public class MyListener extends ContextLoaderListener {   
    }
    
    @Configuration
    @EnableVaadin
    public static class MyConfiguration {
    }
    
    @Autowired
    private SpringViewProvider prov;

    @WebServlet(value = "/*", asyncSupported = true)    
    public static class Servlet extends SpringVaadinServlet {      
    }

@Override
    protected void init(VaadinRequest request) {...}
}

applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context 
                           http://www.springframework.org/schema/context/spring-context-4.1.xsd">

    <!-- See the MyConfiguration class in the previous example -->
    <bean class="com.vaadinapp.vaadinapp.MyVaadinUI.MyConfiguration" />
    <context:component-scan base-package="com.vaadinapp.domain" />
</beans>

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    id="WebApp_ID" version="3.0">

<listener>
    <listener-class>com.vaadinapp.vaadinapp.MyVaadinUI$MyListener</listener-class>
  </listener>
  <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>
</web-app>

I’m doing my final project for College based on this, so I’d be grateful if you could give a hand!
Thanks in advance.

Hi Andres,

Are you able to attach all the code here so that I can reproduce and have a look at it?

Hi Alejandro, thanks for you answer!Here you have a link to my app: https://www.dropbox.com/s/b86lacpin39ajxt/VaadinApp.zip?dl=0. I tried to upload it to GitHub, but I couldn’t… seems like I’m having a hard week with technology… haha

Thanks for your time and help!

Hi!Any clue about this?
Sorry for bothering guys, but I really need to make it work, otherwise I’ll have to start all over with other topic for my exam… :frowning:

I think
MyListener
must be
static
so that it can be instantiated:

...

public class MyVaadinUI extends UI implements LoginListener
{
    @WebListener
    public static class MyListener extends ContextLoaderListener {   
    }

...
}

Thanks Alejandro!You were right about it. I think I’m closer to make it work. Now I get HTTP 404 - Request was not handled by any registered handler. I’ll look up if I can find something about it.

Thanks again!