Anonymous_User Absent Member.
Absent Member.
408 views

Policy simulator vs. ECMAScript

I'm not sure yet if this is a Designer thing, but I think it is. It may
also be that I'm doing this wrong, but I don't think I am.

I'm attempting to incorporate Apache log4j via ECMAScript. I've
previously done this by wrapping it in Java, but now I'd like to do it
without having to use an additional Jar file, so I'm trying to move to
ECMAScript. Right now, I'm testing this only in Designer's policy
simulator.

Stripping out most of the cruft to keep this as short as possible, I have
an ECMAScript object on a test Null driver that looks like:

Code:
----------------
importPackage(Packages.org.apache.log4j);

/*
* Some comments would be nice here ...
*/

function niuAuditLogger( logName, logPropFile, logType, logText )
{
var log = Logger.getLogger( logName );
var result = logText;
/*
* Other stuff goes here
*/
return( result );
}
----------------

From within the ECMAScript editor, I can "test" this function, like:

Code:
----------------
>niuAuditLogger("IDMLog","IDMLog4j.properties","INFO","Message goes here")

Message goes here
----------------

and it seems to work. But when I call it from policy, like:

Code:
----------------
Development : Action: do-set-local-variable
("SyslogMessage",scope="policy",token-xpath("es:niuAuditLogger
('IDMLog','IDMlog4j.properties','INFO',$Msg)")).
----------------

I get Designer's error popup window with:

Code:
----------------
com.novell.xml.xpath.XPathEvaluationException: ReferenceError: "Logger"
is not defined. (vnd.nds.stream:/null/Driver+Set/Development/
niuAuditLogger#9
----------------

The problem is not that the ECMAScript is not linked, that generates a
different error. I'm not completely sure that the importPackage() is
right, but it seems to be based on the references I found on-line. Using
'lsof' I can see that Designer has a log4j.jar open, so it seems to have
found the right jar file and loaded it.

Yet it claims that "Logger" is not defined.

What am I missing here?


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.netiq.com

Please post questions in the forums. No support provided via email.
If you find this post helpful, please click on the star below.
Labels (1)
0 Likes
5 Replies
Anonymous_User Absent Member.
Absent Member.

Re: Policy simulator vs. ECMAScript

David,

have you tried calling

var log = Packages.org.apache.log4j.Logger.getLogger( logName );

Wolfgang



On 16.04.2014 22:00, David Gersic wrote:
> I'm not sure yet if this is a Designer thing, but I think it is. It may
> also be that I'm doing this wrong, but I don't think I am.
>
> I'm attempting to incorporate Apache log4j via ECMAScript. I've
> previously done this by wrapping it in Java, but now I'd like to do it
> without having to use an additional Jar file, so I'm trying to move to
> ECMAScript. Right now, I'm testing this only in Designer's policy
> simulator.
>
> Stripping out most of the cruft to keep this as short as possible, I have
> an ECMAScript object on a test Null driver that looks like:
>
> Code:
> ----------------
> importPackage(Packages.org.apache.log4j);
>
> /*
> * Some comments would be nice here ...
> */
>
> function niuAuditLogger( logName, logPropFile, logType, logText )
> {
> var log = Logger.getLogger( logName );
> var result = logText;
> /*
> * Other stuff goes here
> */
> return( result );
> }
> ----------------
>
> From within the ECMAScript editor, I can "test" this function, like:
>
> Code:
> ----------------
>> niuAuditLogger("IDMLog","IDMLog4j.properties","INFO","Message goes here")

> Message goes here
> ----------------
>
> and it seems to work. But when I call it from policy, like:
>
> Code:
> ----------------
> Development : Action: do-set-local-variable
> ("SyslogMessage",scope="policy",token-xpath("es:niuAuditLogger
> ('IDMLog','IDMlog4j.properties','INFO',$Msg)")).
> ----------------
>
> I get Designer's error popup window with:
>
> Code:
> ----------------
> com.novell.xml.xpath.XPathEvaluationException: ReferenceError: "Logger"
> is not defined. (vnd.nds.stream:/null/Driver+Set/Development/
> niuAuditLogger#9
> ----------------
>
> The problem is not that the ECMAScript is not linked, that generates a
> different error. I'm not completely sure that the importPackage() is
> right, but it seems to be based on the references I found on-line. Using
> 'lsof' I can see that Designer has a log4j.jar open, so it seems to have
> found the right jar file and loaded it.
>
> Yet it claims that "Logger" is not defined.
>
> What am I missing here?
>
>

0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Policy simulator vs. ECMAScript

On Wed, 16 Apr 2014 20:43:53 +0000, Wolfgang Schreiber wrote:

> var log = Packages.org.apache.log4j.Logger.getLogger( logName );


Yes:

Code:
----------------
com.novell.nds.dirxml.engine.VRDException: Code(-9131) Error in
vnd.nds.stream:/null/Driver+Set/Development/Subscriber/niuAudit+Sub
+Command:195 : Error evaluating XPATH expression 'token-xpath
("es:niuAuditLogger('IDMLog','IDMlog4j.properties','INFO',$Msg)")' :
com.novell.xml.xpath.XPathEvaluationException: TypeError: getLogger is
not a function. (vnd.nds.stream:/null/Driver+Set/Development/
niuAuditLogger#11).
Code(-9131) Error in vnd.nds.stream:/null/Driver+Set/Development/
Subscriber/niuAudit+Sub+Command:195 : Error evaluating XPATH expression
'token-xpath("es:niuAuditLogger('IDMLog','IDMlog4j.properties','INFO',
$Msg)")' : com.novell.xml.xpath.XPathEvaluationException: TypeError:
getLogger is not a function. (vnd.nds.stream:/null/Driver+Set/Development/
niuAuditLogger#11).
----------------


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.netiq.com

Please post questions in the forums. No support provided via email.
If you find this post helpful, please click on the star below.
0 Likes
ffreitas Frequent Contributor.
Frequent Contributor.

Re: Policy simulator vs. ECMAScript

From my lab (integrated installer):
ffreitas5:~ # find /opt/novell/idm/Designer/ -iname "*.jar" -exec grep
"org.apache.log4j.Logger" {} \;
Binary file
/opt/novell/idm/Designer/plugins/com.novell.core.scriptengineshell_4.0.0.201401071232/lib/log4j.jar
matches
Binary file
/opt/novell/idm/Designer/plugins/com.novell.core.scriptengineshell_4.0.0.201401071232/lib/log4j-1.2.13.jar
matches
Binary file
/opt/novell/idm/Designer/plugins/com.novell.core.scriptengineshell_4.0.0.201310241206/lib/log4j.jar
matches
Binary file
/opt/novell/idm/Designer/plugins/com.novell.core.scriptengineshell_4.0.0.201310241206/lib/log4j-1.2.13.jar
matches
Binary file
/opt/novell/idm/Designer/plugins/com.novell.soa.eai.integrationActivity_4.0.0.201206110753/lib/log4j-1.2.13.jar
matches
Binary file
/opt/novell/idm/Designer/plugins/com.novell.core.scriptengineshell_4.0.0.201206110753/lib/log4j.jar
matches
Binary file
/opt/novell/idm/Designer/plugins/com.novell.core.scriptengineshell_4.0.0.201206110753/lib/log4j-1.2.13.jar
matches
ffreitas5:~ # find /opt/novell/eDirectory/lib/dirxml/classes/ -iname
"*.jar" -exec grep "org.apache.log4j.Logger" {} \;
Binary file /opt/novell/eDirectory/lib/dirxml/classes/log4j.jar matches
ffreitas5:~ #

I'd make sure you have the file
/opt/novell/eDirectory/lib/dirxml/classes/log4j.jar in your system. If
you are on Linux you can use the find/grep combo above to find classes
in jar files (as long as the jar file is not obfuscated).

Cheers,

-Fernando


On 4/16/2014 11:17 PM, David Gersic wrote:
> On Wed, 16 Apr 2014 20:43:53 +0000, Wolfgang Schreiber wrote:
>
>> var log = Packages.org.apache.log4j.Logger.getLogger( logName );

>
> Yes:
>
> Code:
> ----------------
> com.novell.nds.dirxml.engine.VRDException: Code(-9131) Error in
> vnd.nds.stream:/null/Driver+Set/Development/Subscriber/niuAudit+Sub
> +Command:195 : Error evaluating XPATH expression 'token-xpath
> ("es:niuAuditLogger('IDMLog','IDMlog4j.properties','INFO',$Msg)")' :
> com.novell.xml.xpath.XPathEvaluationException: TypeError: getLogger is
> not a function. (vnd.nds.stream:/null/Driver+Set/Development/
> niuAuditLogger#11).
> Code(-9131) Error in vnd.nds.stream:/null/Driver+Set/Development/
> Subscriber/niuAudit+Sub+Command:195 : Error evaluating XPATH expression
> 'token-xpath("es:niuAuditLogger('IDMLog','IDMlog4j.properties','INFO',
> $Msg)")' : com.novell.xml.xpath.XPathEvaluationException: TypeError:
> getLogger is not a function. (vnd.nds.stream:/null/Driver+Set/Development/
> niuAuditLogger#11).
> ----------------
>
>



0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Policy simulator vs. ECMAScript

On Thu, 17 Apr 2014 09:35:40 +0000, ffreitas wrote:

> I'd make sure you have the file
> /opt/novell/eDirectory/lib/dirxml/classes/log4j.jar in your system.


That's the engine. This is Designer. I have log4j.jar:


Code:
--------------------
a02dag1@straylight:~/bin/designer_4.02> find . -iname '*log4j*.jar'./
plugins/com.novell.soa.eai.integrationActivity_4.0.0.201206110753/lib/
log4j-1.2.13.jar
../plugins/org.apache.ant_1.7.0.v200803061910/lib/ant-apache-log4j.jar
../plugins/com.novell.core.scriptengineshell_4.0.0.201206110753/lib/
log4j.jar
../plugins/com.novell.core.scriptengineshell_4.0.0.201206110753/lib/
log4j-1.2.13.jar
--------------------

and:

Code:
--------------------
lsof|grep -i designer | grep -i log4j
--------------------

shows Designer does load log4j.jar. Interestingly, it loads it when the
ECMAScript editor opens. But it does NOT load it when running policy
simulate.


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.netiq.com

Please post questions in the forums. No support provided via email.
If you find this post helpful, please click on the star below.
0 Likes
Anonymous_User Absent Member.
Absent Member.

Re: Policy simulator vs. ECMAScript

On Wed, 16 Apr 2014 20:00:02 +0000, David Gersic wrote:

> I'm not sure yet if this is a Designer thing, but I think it is. It may
> also be that I'm doing this wrong, but I don't think I am.


It's Designer. After deploying the policies and ECMAScript, the engine
processes them just fine.


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.netiq.com

Please post questions in the forums. No support provided via email.
If you find this post helpful, please click on the star below.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.