java - Using Spring Security in an OSGi Application without SpringDM -
it's half day i'm trying find way migrate implementations on springsecurity context of osgi(equinox) bundles without switching springdm.
currently have 2 projects:
1. have an implementation of spring security based on xml configuration files handle authentication , authorization.
2. on other hand, have huge ogsi bundled project structure 200 bundles need integrated security bundle(the 1 described above)
first step create myspringbasedsecuritybundle need run method after loading mysecuritybundle access security configuration xml-file located : com/mycomp/backend/appsecurity/spring/resources/spring-context.xml prepared me spring-datasource.xml , spring-security.xml following:
private void loadapplicationcontext() { securitycontextholder.setstrategyname(securitycontextholder.mode_global); new threadlocal<object>(); setapplicationcontext(new classpathxmlapplicationcontext(spring_context_address)); }
but unfortunately exception occurred:
org.springframework.beans.factory.beandefinitionstoreexception: ioexception parsing xml document class path resource [com/mycomp/backend/appsecurity/spring/resources/spring-context.xml]; nested exception java.io.filenotfoundexception: class path resource [com/mycomp/backend/appsecurity/spring/resources/spring-context.xml] cannot opened because not exist @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:341) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:302) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:143) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:178) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:149) @ org.springframework.beans.factory.support.abstractbeandefinitionreader.loadbeandefinitions(abstractbeandefinitionreader.java:212) @ org.springframework.context.support.abstractxmlapplicationcontext.loadbeandefinitions(abstractxmlapplicationcontext.java:126) @ org.springframework.context.support.abstractxmlapplicationcontext.loadbeandefinitions(abstractxmlapplicationcontext.java:92) @ org.springframework.context.support.abstractrefreshableapplicationcontext.refreshbeanfactory(abstractrefreshableapplicationcontext.java:130) @ org.springframework.context.support.abstractapplicationcontext.obtainfreshbeanfactory(abstractapplicationcontext.java:467) @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:397) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:139) @ org.springframework.context.support.classpathxmlapplicationcontext.<init>(classpathxmlapplicationcontext.java:83) @ com.mycomp.backend.appsecurity.spring.appsecuritymanager.loadapplicationcontext(appsecuritymanager.java:233) @ com.mycomp.backend.appsecurity.spring.appsecuritymanager.internalinitialize(appsecuritymanager.java:106) @ com.mycomp.basemodulemanager.initialize(basemodulemanager.java:511) @ com.mycomp.basemodulemanager.initialize(basemodulemanager.java:1) @ com.mycomp.backend.basebackendmanager.initializesubbackendmanagers(basebackendmanager.java:643) @ com.mycomp.backend.basebackendmanager.preparesubbackendmanagers(basebackendmanager.java:885) @ com.mycomp.backend.backendmanager.internalstart(backendmanager.java:127) @ com.mycomp.basemodulemanager.start(basemodulemanager.java:574) @ com.mycomp.basemodulemanager.start(basemodulemanager.java:1) @ com.mycomp.application.baseapplicationstub.startbackendmanager(baseapplicationstub.java:2407) @ com.mycomp.application.frameworkevent(application.java:72) @ org.eclipse.osgi.framework.internal.core.bundlecontextimpl.dispatchevent(bundlecontextimpl.java:874) @ org.eclipse.osgi.framework.eventmgr.eventmanager.dispatchevent(eventmanager.java:230) @ org.eclipse.osgi.framework.eventmgr.eventmanager$eventthread.run(eventmanager.java:340)caused by: java.io.filenotfoundexception: class path resource [com/mycomp/backend/appsecurity/spring/resources/spring-context.xml] cannot opened because not exist @ org.springframework.core.io.classpathresource.getinputstream(classpathresource.java:158) @ org.springframework.beans.factory.xml.xmlbeandefinitionreader.loadbeandefinitions(xmlbeandefinitionreader.java:328) .. 26 more
as search web, recommendation issue ends application on springdm, but not acceptable our projectmanager switch springdm , honest have no idea springdm.
would please me resolve issue using spring core functionalities.
thanks alot
moein
you don't need spring dm. provides bridge between osgi , spring, niceties loading context files in osgi environment. can well, have compensate classloading issues, problem having.
try fix classloading issues.
applicationcontext ctx = new classpathxmlapplicationcontext(myctxpath) { protected void initbeandefinitionreader(xmlbeandefinitionreader reader) { super.initbeandefinitionreader(reader); reader.setvalidationmode(xmlbeandefinitionreader.validation_none); reader.setbeanclassloader(getclassloader()); } } btw, second line of method serves no purpose.
Comments
Post a Comment