i using servlet context in service:
@context private servletcontext servletcontext; public void amethod(){ servletcontext.getattribute(.. //this works } i'd initialize attribute, according documentation servlet context can accessed in web methods. tried with:
@postconstruct public void init(){ servletcontext.setattribute(... //this not work } but gives me null pointer exception. how solve this? avoid if null then.. schemas...
are sure when @postconstruct methods invoked servletcontext available? if need use in service, try inject directly method parameter. otherwise try servletcontextlistener
Comments
Post a Comment