Annotation/java config based application starts to look for xml config file when moved from weblogic12c(12.1.3) to weblogic12cR2 (12.2.1)

最后都变了- 提交于 2019-12-04 10:06:03

Had the same problem. I guess there is something wrong with WebLogic 12.2.1.

Try to manually set context class for Spring servlet, like so:

public class ApplicationInitializer implements WebApplicationInitializer {

    @Override
    public void onStartup(ServletContext container) throws ServletException {
        AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
        // <some context configuration>

        ServletRegistration.Dynamic spring = container.addServlet("Spring", new DispatcherServlet(context));
        // <some servlet configuration>

        // Here, set desired context class using 'contextClass' parameter.
        spring.setInitParameter("contextClass", context.getClass().getName());

        container.addListener(new ContextLoaderListener(context));
    }

}

And everything will work fine again :)

Sorry , I can't add a comment on the response of amariq.

Just a comment: if your WebApplicationInitializer extends AbstractDispatcherServletInitializer, you can override the method customizeRegistration like:

@Override
protected void customizeRegistration(ServletRegistration.Dynamic registration) {
    registration.setInitParameter("contextClass", AnnotationConfigWebApplicationContext.class.getName());
}

I managed to get spring-boot 1.3.6.RELEASE working on Weblogic 12.2.1.

I had to create an empty (no declared beans) dispatcherServlet-servlet.xml file on src/main/webapp/WEB-INF directory.

Here is the file content:

    <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.xsd">

    </beans>

In addition, I made my main application class implement WebApplicationInitializer as stated on Spring Boot Ref Guide.

I am not sure if there are now two application contexts, but the one who is answering all my API calls seems to be working fine (dependency injection, aop, jdbc, jpa, logging, session context, actuator, etc).

PS: I have tried @amariq solution but it didn't work on Weblogic 12.2.1, only the one described above.

I had the exact same issue here and tried the solutions suggested above, but they didn't work for me. I finally managed to make it work by doing a few modifications using this GitHub repo as reference.

They main points I could outline are:

  • pom.xml: add excludes for tomcat-embed-el dependency from spring-boot-starter-web
  • pom.xml: add dependency for spring-boot-legacy
  • add web.xml with contextConfigLocation, SpringBootContextLoaderListener and appServlet (in my previous configuration I had no web.xml at all)

Take a look at https://github.com/DISID/disid-proofs/tree/master/spring-boot-weblogic for further details.

I hope it helps.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!