K.G.K.Thilina
K.G.K.Thilina

Reputation: 121

How to fix ‘404--Not Found' issue of Spring Web Application

I migrated Spring XML base configuration, REST service application into Java base configuration. After the migration was done, the application worked well on Apache Tomcat 8 server. But it didn't work on WebLogic Server 12 in version 12.1.3.0.0 and deployment happened without any error.

I removed web.xml file. I added weblogic.xml file into WEB-INF, configuration below:

public class WebAppInitializer extends ABCInitializer {

    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{};
    }

    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{};
    }

    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    @Override
    public void onStartup(ServletContext servletContext) throws 
    ServletException {
        init(servletContext);
    }
}

class ABCInitializer extends AbstractAnnotationConfigDispatcherServletInitializer{

    public void init(ServletContext container) throws ServletException {
        AnnotationConfigWebApplicationContext context = new 
        AnnotationConfigWebApplicationContext();
        context.register(WebConfig.class);

        container.addListener(new ContextLoaderListener(context));
        ServletRegistration.Dynamic dispatcher = 
        container.addServlet("dispatcher", new DispatcherServlet(context));
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }
}

Expected Result : The endpoints work well.

Actual Result :

Error 404--Not Found From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1: 10.4.5 404 Not Found

Please anyone help me understand this problem.?

Upvotes: 1

Views: 3633

Answers (2)

If you are using Windows 2016 server to deploy your application, it is incompatible with the Weblogic 12.1.x. Try upgrading the weblogic version in your application. Also consider upgrading to Java 8 if you are not using it in your project. Weblogic 12.2.x and Java 8 shoud go together.

Upvotes: 1

Please check on a higher version of weblogic server, seems there is a incompatibility of spring version and weblogic release ,

Answer : I tried a sample with same spring configuration and it works perfectly with Spring 4.2.6 (version doesnt matter , 4.1.x > ) , and weblogic server you mentioned ( not the minimal or portable version ).Besides,if you have made any swagger configuration on the application please check the compatibility of the swagger version.

Upvotes: 1

Related Questions