Spring Java configuration on weblogic -


i'm new spring, , i'm trying learn pure java configuration element of it.

i'm able run spring application on tomcat following classes:

config class:

/*  * change license header, choose license headers in project properties.  * change template file, choose tools | templates  * , open template in editor.  */ package com.inka.spring.test.maven.configuration;  import org.springframework.context.annotation.bean; import org.springframework.context.annotation.componentscan; import org.springframework.context.annotation.configuration; import org.springframework.web.servlet.viewresolver; import org.springframework.web.servlet.config.annotation.enablewebmvc; import org.springframework.web.servlet.config.annotation.webmvcconfigureradapter; import org.springframework.web.servlet.view.internalresourceviewresolver; import org.springframework.web.servlet.view.jstlview;  /**  *  * @author user  */ @configuration @enablewebmvc @componentscan(basepackages = "com.inka.spring.test.maven") public class helloworldconfiguration extends webmvcconfigureradapter {     @bean     public viewresolver viewresolver() {         internalresourceviewresolver viewresolver = new internalresourceviewresolver();         viewresolver.setviewclass(jstlview.class);         viewresolver.setprefix("/web-inf/views/");         viewresolver.setsuffix(".jsp");          return viewresolver;     } } 

initializer class:

/*  * change license header, choose license headers in project properties.  * change template file, choose tools | templates  * , open template in editor.  */ package com.inka.spring.test.maven.configuration;  import org.springframework.web.servlet.support.abstractannotationconfigdispatcherservletinitializer;  /**  *  * @author user  */ public class helloworldinitializer extends abstractannotationconfigdispatcherservletinitializer {      @override     protected class<?>[] getrootconfigclasses() {         return new class[] {helloworldconfiguration.class};     }      @override     protected class<?>[] getservletconfigclasses() {         return null;     }      @override     protected string[] getservletmappings() {         return new string[] {"/"};     }  } 

controller class:

/*  * change license header, choose license headers in project properties.  * change template file, choose tools | templates  * , open template in editor.  */ package com.inka.spring.test.maven.controllers;  import org.springframework.stereotype.controller; import org.springframework.ui.modelmap; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod;  /**  *  * @author user  */ @controller @requestmapping("/") public class helloworldcontroller {      @requestmapping(method = requestmethod.get)     public string sayhello(modelmap model) {         model.addattribute("greeting", "hello world spring 4 mvc");         return "welcome";     }      @requestmapping(value = "/helloagain", method = requestmethod.get)     public string sayhelloagain(modelmap model) {         model.addattribute("greeting", "hello world again, spring 4 mvc");         return "welcome";     } } 

this calls .jsp page prints respective messages depending on path enter stated above in codes.

however, when try weblogic, doesn't work. 403 , 404 error.

i have stuck tomcat, use weblogic @ our organisation , i've been instructed build application work weblogic.

please, there configuration i'm supposed use on weblogic?

ok, i've resolved issue. turns out, in initializer class, no matter class extend, must implement webapplicationinitializer class if intend deploy on weblogic. don't have tomcat (don't know jboss , rest), weblogic, must implement class.

so, after changing this:

public class helloworldinitializer extends abstractannotationconfigdispatcherservletinitializer { 

to this:

public class helloworldinitializer extends abstractannotationconfigdispatcherservletinitializer implements webapplicationinitializer { 

everything works fine!

for more information, please visit spring guide.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -