wildfly 12 和 spring java 配置,不工作,403 错误

wildfly 12 and spring java config, not working , 403 error

几个小时以来,我一直在尝试将这个简单的应用程序用于 wildfly 12,它在 tomcat 上运行良好。下面是日志和配置的任何方式

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));
    }

应用程序配置

@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-部署-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>

注意我没有提供完整的代码,如果需要会post它。

最后我在日志中得到的内容如下

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 是应用程序,我得到 403 禁止,我尝试了很多东西,我觉得 Jboss 根本无法选择调度程序 servlet,我用过 spring jboss 作为 7.1,但后来是 xml 配置,我不使用 maven 所以这里没有 pom.xml,同样的配置 运行 在 [=59= 中很好] 8.

删除自定义库并将所有库放入 web-inf/lib 文件夹并从 web-inf 中删除 jboss-deployment-structure.xml 后,它工作正常。如果是自定义模块,我做错了什么?我在模块文件夹下创建了 pluto.lib.main 并在 standalone.xml

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

然后我遇到了 403 错误

经过长时间的调试以及对不同版本的 spring 和 wild fly 的反复试验,我得出的结论是我的自定义模块由 spring 4.3 不是 运行 on wildfly 12.

无论如何,解决方案是将应用程序服务器降级到 Wildfly 11。完全相同的模块和 .war 在版本 11 上运行顺利。

我在版本 12 上启用了调试日志,但日志中仍然没有任何可能显示根本原因的内容,我认为存在一些与 wildfy 版本 12 和 spring 相关的错误。

到目前为止,这似乎工作正常,如果有人能够在 wildfly 12 上使用 java 配置找到 spring 的解决方案,请 post 回答 :)