0
votes

I am trying since few hours to bring this simple application to work on wildfly 12, which was working fine on tomcat. Any how below is log and config

Webappinitializer

@Configuration
public class ListenerConfig implements WebApplicationInitializer{

    @Override
    public void onStartup(final ServletContext servletContext) throws ServletException {
        final AnnotationConfigWebApplicationContext root = new AnnotationConfigWebApplicationContext();
        root.setServletContext(servletContext);
        root.scan("com.app");
        root.refresh();

        final Dynamic servlet = servletContext.addServlet("spring", new DispatcherServlet(root));
        servlet.setLoadOnStartup(1);
        servlet.addMapping("/*");
        servletContext.addListener(new ContextLoaderListener(root));
    }

ApplicationConfig

@Configuration
@ComponentScan(basePackages = "com.app")
@PropertySource(value = { "classpath:jdbc.properties" })
@EnableTransactionManagement
public class ApplicationConfig {

MVCConfig

@Configuration
@EnableWebMvc
public class WebConfig extends WebMvcConfigurerAdapter{

    @Override
    public void configureMessageConverters( List<HttpMessageConverter<?>> converters ) {
        converters.add(converter());
    }

    @Bean
    public ViewResolver viewResolver() {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix("/WEB-INF/views/");
        viewResolver.setSuffix(".jsp");

        return viewResolver;
    }
    @Bean  
    public UrlBasedViewResolver setupViewResolver() {  
        UrlBasedViewResolver resolver = new UrlBasedViewResolver();  
        resolver.setPrefix("/html/");  
        resolver.setSuffix(".jsp");  
        resolver.setViewClass(JstlView.class);  
        return resolver;  
    }

jboss-deployment-structure.xml

<?xml version="1.0" encoding="UTF-8"?>  
<jboss-deployment-structure>  
    <deployment>  
         <dependencies>  
              <module name="javax.api"/>
              <module name="javax.jms.api"/>
              <module name="javax.servlet.api"/>
              <module name="org.apache.log4j"/>
              <module name="pluto.lib" />  
        </dependencies>  
    </deployment>  
</jboss-deployment-structure>

Note I haven't provided complete code, if required will post it.

Finally what I get in log is below

22:36:39,374 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-2) WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS] 22:36:40,290 INFO [org.wildfly.extension.undertow] (MSC service thread 1-4) WFLYUT0006: Undertow HTTPS listener https listening on 127.0.0.1:8443 22:36:40,504 INFO [org.jboss.ws.common.management] (MSC service thread 1-3) JBWS022052: Starting JBossWS 5.2.0.Final (Apache CXF 3.2.2) 22:36:43,005 INFO [org.infinispan.factories.GlobalComponentRegistry] (MSC service thread 1-4) ISPN000128: Infinispan version: Infinispan 'Bastille' 9.1.6.Final 22:36:43,650 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 62) WFLYCLINF0002: Started client-mappings cache from ejb container 22:36:44,314 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 64) WFLYUT0021: Registered web context: '/Pluto' for server 'default-server' 22:36:44,412 INFO [org.jboss.as.server] (ServerService Thread Pool -- 37) WFLYSRV0010: Deployed "Pluto.war" (runtime-name : "Pluto.war") 22:36:44,857 INFO [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0212: Resuming server 22:36:44,863 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0060: Http management interface listening on http://127.0.0.1:9990/management 22:36:44,863 INFO [org.jboss.as] (Controller Boot Thread) WFLYSRV0051: Admin console listening on http://127.0.0.1:9990

Pluto.war is application and I get 403 forbidden, I have tried multiple things, What I feel is Jboss is not able to pick dispatcher servlet at all, I have used spring with jboss as 7.1, but then it was xml config, I do not use maven so no pom.xml here, this same config is running fine in tomcat 8.

After removing custom lib and placed all the libs in web-inf/lib folder and deleted jboss-deployment-structure.xml from web-inf then its working fine. What wrong am I doing, in case of custom module? I created pluto.lib.main under modules folder and added this in standalone.xml

 <subsystem xmlns="urn:jboss:domain:ee:4.0">
            <global-modules>
                <module name="pluto.lib" slot="main"/>
            </global-modules>

Then I am facing 403 error

1
What URL are you using to access the system? localhost:8443/Pluto with https?ℛɑƒæĿᴿᴹᴿ
You don't need this jboss-deployment-structure.xml file to deploy with Wildfly nor make changes to the subsystem domain in standalone.xml this way. Delete the file and remove the changes.ℛɑƒæĿᴿᴹᴿ
URL is localhost:8081/Pluto, it is http, not httpsAadam
I have done both changes suggested by you, and restarted server. Anyhow I enabled log to debug, now I can see this when url is requested. Authentication result was ATTEMPTED for /Pluto/, something related to undertow. I think there is no point talking about url now as spring beans are not loaded at all, no request-mapping or anything is spring related is happening, its like spring is dead :PAadam
Did you have the ApplicationContext.xml configured correctly? Example: stackoverflow.com/a/28418012/5626568ℛɑƒæĿᴿᴹᴿ

1 Answers

0
votes

After a long pain-full debugging along with trial and error with different versions of spring and wild fly, I have come to a conclusion that my custom module which consists of spring 4.3 is not running on wildfly 12.

Anyhow the solution was to downgrade app server to wildfly 11. The very same module and .war runs smoothly on ver 11.

I enabled debug logs on ver 12, still there nothing in logs that could probably show the root cause, I think there is some bug associated to wildfy version 12 and spring.

As of now this seems to work fine, if anyone who is able to find solution for spring with java config on wildfly 12, please post an answer :)