Spring mvc + Maven multi module + Ear - deployment -
i created following multi module project spring + maven. has following hierarchy,
when build project getting cleveree.ear file under clevermoe_ee/target
. ear file contains following things,
initially used jboss7.1.1 deployment, copied ear file jboss depolyments, able load war follows,
http://localhost:8080/clevermoe_web
i followed link make spring project, http://www.mkyong.com/spring3/spring-3-mvc-hello-world-example-annotation/
so used following classes in clevermoe_web module,
springwebconfig,
@enablewebmvc // mvc:annotation-driven @configuration @componentscan({ "com.zeptoh.clever.controllers" }) public class springwebconfig extends webmvcconfigureradapter { @override public void addresourcehandlers(resourcehandlerregistry registry) { registry.addresourcehandler("/resources/**").addresourcelocations( "/resources/"); } @bean public internalresourceviewresolver viewresolver() { internalresourceviewresolver viewresolver = new internalresourceviewresolver(); viewresolver.setviewclass(jstlview.class); viewresolver.setprefix("/web-inf/views/jsp/"); viewresolver.setsuffix(".jsp"); return viewresolver; }
mywebinitializer class,
public class mywebinitializer extends abstractannotationconfigdispatcherservletinitializer { @override protected class<?>[] getrootconfigclasses() { // todo auto-generated method stub return null; } @override protected class<?>[] getservletconfigclasses() { // todo auto-generated method stub return new class[] { springwebconfig.class }; } @override protected string[] getservletmappings() { // todo auto-generated method stub return new string[] { "/" }; } }
controller class,
@controller public class hellocontroller { @requestmapping(value = "/", method = requestmethod.get) public string printwelcome(modelmap model) { model.addattribute("message", "clever portal"); return "hello"; } @requestmapping(value = "/hello/{name:.+}", method = requestmethod.get) public modelandview hello(@pathvariable("name") string name) { modelandview model = new modelandview(); model.setviewname("hello"); model.addobject("msg", name); return model; } }
i cant open spring controller follows,
http://localhost:8080/clevermoe_web/hello/something
it says 404 error
http status 404 - /clevermoe_web/hello/something type status report message /clevermoe_web/hello/something description requested resource (/clevermoe_web/hello/something) not available. jbossweb/2.0.1.ga
i read articles, says, access ear deployment, not move use jboss. downloaded tomee server. extracts ear file folder. met same problem had in jboss.
i copied war file(clevermoe_web.war) inside cleveree.ear in tomee server's webapps folder, works fine access spring controller.
i copied war file(clevermoe_web.war) inside cleveree.ear in jboss, still shows 404 error.
can need take care of here?
does http://localhost:8080/clevermoe_web-0.1/hello/something works? if don't map war context in application.xml in meta-inf context used (from war name)
Comments
Post a Comment