On 9/26/10 7:03 AM, Brad Cox wrote:
I'm using Sun's XACML implementation which loads XACML from either
URLs or files. That was causing headaches making code that works from
either test cases or servlets, so I developed the URLStreamHandler
lashup (attached) until a better idea comes along. That adds a
classpath: URL prefix (to the JVM) which works fine under junit and
httpServlet but fails under WSO2.
Also, what should I do to make my log messages appear in the console?
I've added this to log4j.properties:
log4j.category.com.technica.pbac=DEBUG
Can anyone shed any light on why classpath URLs don't work under WSO2
ESB? Security? Classloader problems? OSGI?
This is becuse of OSGi and the actual root cause is the classloader
problem. In OSGi each and every bundle has its own class loader and they
do not see any other classes or resources out of that bundle unless
specified explicitly.
So the way to do this is to read the resource form the context class loader.
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream in = cl.getResourceAsStream(filePath);
Try this and let us know whether it fixes the issue that you are facing.
Ruwan
public
void init(SynapseEnvironment synapseEnvironment)
{
log
= Logger.getLogger(PbacMediator.class.getName());
log
.setLevel(Level.INFO); //desperation
log
.info("PbacMediator.init:"+synapseEnvironment);
/**
* Enable support for classpath: urls.
*/
ClassLoader cl = getClass().getClassLoader();
ClasspathURL.init(cl);
/**
* FixMe: should load this string from config. Research how later.
*/
String domainsPath
=
"file://localhost/Users/Brad/Dropbox/work-technica-new/Technica-PBAC-PDP/DecisionServer/DS-PBAC-Mediator/src/main/resources/Domains.xml";
// hacking
String doesntWorkPath = "classpath:Domains.xml";
try
{
URL domainsURL = new URL(domainsPath);
InputStream domainsStream = domainsURL.openStream();
this.pdp = new PbacPDP(domainsStream);
}
_______________________________________________
Carbon-dev mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
--
Ruwan Linton
Software Architect& Product Manager, WSO2 ESB; http://wso2.org/esb
WSO2 Inc.; http://wso2.com
Lean . Enterprise . Middleware
phone: +1 408 754 7388 ext 51789
email: [email protected]; cell: +94 77 341 3097
blog: http://blog.ruwan.org
linkedin: http://www.linkedin.com/in/ruwanlinton
tweet: http://twitter.com/ruwanlinton
_______________________________________________
Carbon-dev mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev