Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-390

Can't deploy application with Spring MVC

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Blocker Blocker
    • 1.1.3.Final
    • 1.1.0.Final
    • None
    • None

      With a same code and data source configuration used in Wildfly 8.1, when I try deploy the WAR in Wildfly 8.2 I get a error in Undertow. But the same WAR work in Wildfly 8.1.

      23:19:33,327 INFO  [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final  
      23:19:33,968 INFO  [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final  
      23:19:34,148 INFO  [org.jboss.as] (MSC service thread 1-1) JBAS015899: WildFly 8.2.0.Final "Tweek" starting  
      23:19:36,029 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found bandradios-admin.war in deployment directory. To trigger deployment create a file called bandradios-admin.war.dodeploy  
      23:19:36,076 INFO  [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http)  
      23:19:36,109 INFO  [org.xnio] (MSC service thread 1-3) XNIO version 3.3.0.Final  
      23:19:36,140 INFO  [org.xnio.nio] (MSC service thread 1-3) XNIO NIO Implementation Version 3.3.0.Final  
      23:19:36,189 INFO  [org.jboss.remoting] (MSC service thread 1-3) JBoss Remoting version 4.0.6.Final  
      23:19:36,266 INFO  [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem.  
      23:19:36,307 INFO  [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 4 core threads with 32 task threads based on your 2 available processors  
      23:19:36,321 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3)  
      23:19:36,365 INFO  [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main]  
      23:19:36,369 INFO  [org.jboss.as.connector.logging] (MSC service thread 1-4) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.9.Final)  
      23:19:36,389 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-3) JBAS010417: Started Driver service with driver-name = h2  
      23:19:36,423 INFO  [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem  
      23:19:36,490 INFO  [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem  
      23:19:36,510 WARN  [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique.  
      23:19:36,566 INFO  [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010404: Deploying non-JDBC-compliant driver class com.mysql.jdbc.Driver (version 5.1)  
      23:19:36,574 INFO  [org.jboss.as.security] (MSC service thread 1-2) JBAS013170: Current PicketBox version=4.0.21.Final  
      23:19:36,608 INFO  [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension  
      23:19:36,615 INFO  [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-1) JBAS010417: Started Driver service with driver-name = mysql  
      23:19:36,680 INFO  [org.jboss.as.naming] (MSC service thread 1-1) JBAS011802: Starting Naming Service  
      23:19:36,702 INFO  [org.jboss.as.mail.extension] (MSC service thread 1-2) JBAS015400: Bound mail session [java:jboss/mail/Default]  
      23:19:36,744 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017502: Undertow 1.1.0.Final starting  
      23:19:36,750 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.1.0.Final starting  
      23:19:37,882 INFO  [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /home/aneto/Apps/servers/wildfly/wildfly-8.2.0.Final/welcome-content  
      23:19:37,967 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017525: Started server default-server.  
      23:19:38,035 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017531: Host default-host starting  
      23:19:38,189 INFO  [org.wildfly.extension.undertow] (MSC service thread 1-4) JBAS017519: Undertow HTTP listener default listening on localhost/127.0.0.1:8080  
      23:19:38,469 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-3) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS]  
      23:19:38,543 INFO  [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-1) JBAS010400: Bound data source [java:jboss/bandradiosDS]  
      23:19:38,616 INFO  [org.jboss.as.server.deployment.scanner] (MSC service thread 1-1) JBAS015012: Started FileSystemDeploymentService for directory /home/aneto/Apps/servers/wildfly/wildfly-8.2.0.Final/standalone/deployments  
      23:19:38,682 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "bandradios-admin.war" (runtime-name: "bandradios-admin.war")  
      23:19:40,123 INFO  [org.jboss.ws.common.management] (MSC service thread 1-2) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.3.2.Final  
      23:19:45,106 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015960: Class Path entry slf4j-api-1.5.6.jar in /home/aneto/Apps/servers/wildfly/wildfly-8.2.0.Final/standalone/deployments/bandradios-admin.war/WEB-INF/lib/jacorb-2.3.2-jbossorg-5.jar  does not point to a valid jar for a Class-Path reference.  
      23:19:45,107 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015960: Class Path entry slf4j-jdk14-1.5.6.jar in /home/aneto/Apps/servers/wildfly/wildfly-8.2.0.Final/standalone/deployments/bandradios-admin.war/WEB-INF/lib/jacorb-2.3.2-jbossorg-5.jar  does not point to a valid jar for a Class-Path reference.  
      23:19:45,107 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015960: Class Path entry antlr-2.7.2.jar in /home/aneto/Apps/servers/wildfly/wildfly-8.2.0.Final/standalone/deployments/bandradios-admin.war/WEB-INF/lib/jacorb-2.3.2-jbossorg-5.jar  does not point to a valid jar for a Class-Path reference.  
      23:19:46,117 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016002: Processing weld deployment bandradios-admin.war  
      23:19:46,237 INFO  [org.hibernate.validator.internal.util.Version] (MSC service thread 1-1) HV000001: Hibernate Validator 5.1.3.Final  
      23:19:46,627 INFO  [org.jboss.weld.deployer] (MSC service thread 1-2) JBAS016005: Starting Services for CDI deployment: bandradios-admin.war  
      23:19:46,673 INFO  [org.jboss.weld.Version] (MSC service thread 1-2) WELD-000900: 2.2.6 (Final)  
      23:19:46,741 INFO  [org.jboss.weld.deployer] (MSC service thread 1-3) JBAS016008: Starting weld service for deployment bandradios-admin.war  
      23:19:48,774 INFO  [io.undertow.servlet] (MSC service thread 1-2) Spring WebApplicationInitializers detected on classpath: [br.com.onebrasil.bandradios.web.app.initializer.SpringSecurityInitializer@72474928, br.com.onebrasil.bandradios.web.app.initializer.SpringMvcInitializer@26141bb5]  
      23:19:48,923 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC000001: Failed to start service jboss.undertow.deployment.default-server.default-host./bandradios-admin: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./bandradios-admin: Failed to start service  
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]  
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_75]  
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_75]  
        at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_75]  
      Caused by: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 3, Size: 0  
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:222)  
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.startContext(UndertowDeploymentService.java:87)  
        at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.start(UndertowDeploymentService.java:72)  
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]  
        at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]  
        ... 3 more  
      Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 0  
        at java.util.ArrayList.rangeCheckForAdd(ArrayList.java:643) [rt.jar:1.7.0_75]  
        at java.util.ArrayList.add(ArrayList.java:455) [rt.jar:1.7.0_75]  
        at io.undertow.servlet.api.DeploymentInfo.insertFilterServletNameMapping(DeploymentInfo.java:354)  
        at io.undertow.servlet.spec.ServletContextImpl.addMappingForServletNames(ServletContextImpl.java:836)  
        at io.undertow.servlet.spec.FilterRegistrationImpl.addMappingForServletNames(FilterRegistrationImpl.java:54)  
        at org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.registerServletFilter(AbstractDispatcherServletInitializer.java:176)  
        at org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.registerDispatcherServlet(AbstractDispatcherServletInitializer.java:103)  
        at org.springframework.web.servlet.support.AbstractDispatcherServletInitializer.onStartup(AbstractDispatcherServletInitializer.java:68)  
        at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)  
        at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:182)  
        ... 7 more  
        
        
      23:19:48,967 ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) JBAS014613: Operation ("deploy") failed - address: ([("deployment" => "bandradios-admin.war")]) - failure description: {"JBAS014671: Failed services" => {"jboss.undertow.deployment.default-server.default-host./bandradios-admin" => "org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./bandradios-admin: Failed to start service  
          Caused by: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 3, Size: 0  
          Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 0"}}  
      23:19:49,270 INFO  [org.jboss.as.server] (ServerService Thread Pool -- 28) JBAS018559: Deployed "bandradios-admin.war" (runtime-name : "bandradios-admin.war")  
      23:19:49,276 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report  
      JBAS014777:   Services which failed to start:      service jboss.undertow.deployment.default-server.default-host./bandradios-admin: org.jboss.msc.service.StartException in service jboss.undertow.deployment.default-server.default-host./bandradios-admin: Failed to start service  
        
        
      23:19:49,348 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management  
      23:19:49,348 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990  
      23:19:49,349 ERROR [org.jboss.as] (Controller Boot Thread) JBAS015875: WildFly 8.2.0.Final "Tweek" started (with errors) in 16598ms - Started 445 of 502 services (2 services failed or missing dependencies, 92 services are lazy, passive or on-demand)  
      23:19:49,586 INFO  [org.jboss.weld.deployer] (MSC service thread 1-1) JBAS016009: Stopping weld service for deployment bandradios-admin.war  
      23:19:49,821 INFO  [org.jboss.as.server.deployment] (MSC service thread 1-1) JBAS015877: Stopped deployment bandradios-admin.war (runtime-name: bandradios-admin.war) in 303ms  
      23:19:49,977 INFO  [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018558: Undeployed "bandradios-admin.war" (runtime-name: "bandradios-admin.war")  
      23:19:49,997 INFO  [org.jboss.as.controller] (DeploymentScanner-threads - 2) JBAS014774: Service status report  
      JBAS014775:    New missing/unsatisfied dependencies:  
            service jboss.deployment.unit."bandradios-admin.war".component."com.sun.faces.config.ConfigureListener".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."javax.faces.webapp.FacetTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."javax.servlet.jsp.jstl.tlv.PermittedTaglibsTLV".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."javax.servlet.jsp.jstl.tlv.ScriptFreeTLV".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.jboss.weld.servlet.WeldInitialListener".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.jboss.weld.servlet.WeldTerminalListener".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.http.server.ServletServerHttpAsyncRequestControl".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.security.taglibs.authz.AccessControlListTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.security.taglibs.authz.AuthenticationTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.security.taglibs.authz.JspAuthorizeTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.security.taglibs.csrf.CsrfInputTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.security.taglibs.csrf.CsrfMetaTagsTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.context.request.async.StandardServletAsyncWebRequest".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.ArgumentTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.BindErrorsTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.BindTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.EscapeBodyTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.EvalTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.HtmlEscapeTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.MessageTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.NestedPathTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.ParamTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.ThemeTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.TransformTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.UrlTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.ButtonTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.CheckboxTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.CheckboxesTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.ErrorsTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.FormTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.HiddenInputTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.InputTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.LabelTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.OptionTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.OptionsTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.PasswordInputTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.RadioButtonTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.RadioButtonsTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.SelectTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.deployment.unit."bandradios-admin.war".component."org.springframework.web.servlet.tags.form.TextareaTag".START (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
            service jboss.undertow.deployment.default-server.default-host./bandradios-admin (missing) dependents: [service jboss.deployment.unit."bandradios-admin.war".deploymentCompleteService]  
      JBAS014777:   Services which failed to start:      service jboss.undertow.deployment.default-server.default-host./bandradios-admin  
        
        
      23:19:54,314 INFO  [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found bandradios-admin.war in deployment directory. To trigger deployment create a file called bandradios-admin.war.dodeploy  
      

      That is my MVC configuration class:

      SpringMvcConfig.java
      package br.com.onebrasil.bandradios.web.app.config;
      
      import java.util.List;
      
      import org.springframework.beans.factory.annotation.Autowired;
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.ComponentScan;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.context.annotation.Import;
      import org.springframework.format.FormatterRegistry;
      import org.springframework.http.converter.HttpMessageConverter;
      import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
      import org.springframework.web.servlet.ViewResolver;
      import org.springframework.web.servlet.config.annotation.EnableWebMvc;
      import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
      import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
      import org.springframework.web.servlet.view.InternalResourceViewResolver;
      import org.springframework.web.servlet.view.JstlView;
      
      import br.com.onebrasil.bandradios.web.util.formatter.AudioFormatter;
      import br.com.onebrasil.bandradios.web.util.formatter.BannerFormatter;
      import br.com.onebrasil.bandradios.web.util.formatter.CityFormatter;
      import br.com.onebrasil.bandradios.web.util.formatter.RadioFormatter;
      import br.com.onebrasil.bandradios.web.util.formatter.StateFormatter;
      
      import com.fasterxml.jackson.databind.ObjectMapper;
      import com.fasterxml.jackson.datatype.hibernate4.Hibernate4Module;
      
      
      @EnableWebMvc
      @Configuration
      @ComponentScan({ "br.com.onebrasil.bandradios.web" })
      @Import({ SpringSecurityConfig.class })
      public class SpringMvcConfig extends WebMvcConfigurerAdapter {
      
      	@Autowired
      	private AudioFormatter audioFormatter;
      
      	@Autowired
      	private BannerFormatter bannerFormatter;
      
      	@Autowired
      	private CityFormatter cityFormatter;
      
      	@Autowired
      	private RadioFormatter radioFormatter;
      
      	@Autowired
      	private StateFormatter stateFormatter;
      
      	@Override
      	public void addResourceHandlers(ResourceHandlerRegistry registry) {
      		registry.addResourceHandler("/resources/**").addResourceLocations("/resources/");
      	}
      
      	@Bean
      	public ViewResolver viewResolver() {
      		InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
      		viewResolver.setViewClass(JstlView.class);
      		viewResolver.setPrefix("/WEB-INF/views/");
      		viewResolver.setSuffix(".jsp");
      		return viewResolver;
      	}
      
      	@Override
      	public void addFormatters(FormatterRegistry registry) {
      		registry.addFormatter(audioFormatter);
      		registry.addFormatter(bannerFormatter);
      		registry.addFormatter(cityFormatter);
      		registry.addFormatter(radioFormatter);
      		registry.addFormatter(stateFormatter);
      	}
      
      	public MappingJackson2HttpMessageConverter jacksonMessageConverter() {
      		MappingJackson2HttpMessageConverter messageConverter = new MappingJackson2HttpMessageConverter();
      
      		ObjectMapper mapper = new ObjectMapper();
      		mapper.registerModule(new Hibernate4Module());
      
      		messageConverter.setObjectMapper(mapper);
      		return messageConverter;
      	}
      
      	@Override
      	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
      		converters.add(jacksonMessageConverter());
      		super.configureMessageConverters(converters);
      	}
      
      }
      

      That is my JPA configuration class:

      SpringJpaConfig.java
      package br.com.onebrasil.bandradios.web.app.config;
      
      import java.util.Properties;
      
      import javax.persistence.EntityManagerFactory;
      import javax.sql.DataSource;
      
      import org.springframework.context.annotation.Bean;
      import org.springframework.context.annotation.Configuration;
      import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
      import org.springframework.jdbc.datasource.lookup.JndiDataSourceLookup;
      import org.springframework.orm.jpa.JpaTransactionManager;
      import org.springframework.orm.jpa.JpaVendorAdapter;
      import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
      import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
      import org.springframework.transaction.PlatformTransactionManager;
      import org.springframework.transaction.annotation.EnableTransactionManagement;
      
      @Configuration
      @EnableTransactionManagement
      public class SpringJpaConfig {
      
      	@Bean
      	public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
      		LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
      		em.setDataSource(dataSource());
      		em.setPackagesToScan(new String[] { "br.com.onebrasil.bandradios.web" });
      
      		JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
      		em.setJpaVendorAdapter(vendorAdapter);
      		em.setJpaProperties(additionalProperties());
      
      		return em;
      	}
      
      	@Bean
      	public DataSource dataSource() {
      		final JndiDataSourceLookup dsLookup = new JndiDataSourceLookup();
      		dsLookup.setResourceRef(true);
      		DataSource dataSource = dsLookup.getDataSource("java:jboss/datasources/bandradiosDS");
      		return dataSource;
      	}
      
      	@Bean
      	public PlatformTransactionManager transactionManager(EntityManagerFactory emf) {
      		JpaTransactionManager transactionManager = new JpaTransactionManager();
      		transactionManager.setEntityManagerFactory(emf);
      
      		return transactionManager;
      	}
      
      	@Bean
      	public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
      		return new PersistenceExceptionTranslationPostProcessor();
      	}
      
      	Properties additionalProperties() {
      		Properties properties = new Properties();
      
      		properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL5Dialect");
      
      		properties.setProperty("hibernate.connection.CharSet", "utf8");
      		properties.setProperty("hibernate.connection.characterEncoding", "utf8");
      		properties.setProperty("hibernate.connection.useUnicode", "true");
      
      		// properties.setProperty("hibernate.hbm2ddl.auto", "create-drop");
      		// properties.setProperty("hibernate.show_sql", "true");
      		// properties.setProperty("hibernate.format_sql", "true");
      		return properties;
      	}
      
      }
      

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              aneto.work Antonio Cesar (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: