This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Mar 11, 2011, 8:03 AM
41 Posts

Re: ECL Permission Denied on a Java class

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role: Developer
  • Tags: java,class,ecl
  • Replies: 4
 Mike, the most likely reason you're triggering an ECL exception is because the code you posted appears to be trying to create a session from within a session:
 
Session nsCurrent = NotesFactory.createSession();
 
Just like a Domino Java agent already has a session, so you'd just grab onto it and go from there, any Java code executed from within an XPage is already running inside a session, although the approach for getting a handle on it is comparatively obtuse. I recommend creating something like a DominoUtils class for convenient access to variables that are implicit globals in SSJS but have to be more manually retrieved in Java. For example:
 

import javax.faces.context.FacesContext;

import javax.faces.el.VariableResolver;

import lotus.domino.Database;

import lotus.domino.Session;

import com.ibm.xsp.application.ApplicationEx;


public class DominoUtils {


public static Database getCurrentDatabase() {

return (Database) resolveVariable("database");

}

public static Session getCurrentSession() {

return (Session) resolveVariable("session");

}

public static VariableResolver getVariableResolver() {

return ApplicationEx.getInstance().getVariableResolver();

}


public static Object resolveVariable(String variable) {

return getVariableResolver().resolveVariable(

FacesContext.getCurrentInstance(), variable);

}


}
 
Then you can just refer to getCurrentDatabase() / getCurrentSession() from anywhere... 
 
System.out.println(DominoUtils.getCurrentDatabase().getTitle()); 
 
 
Additionally, then, the resolveVariable method will allow you to get a handle on any object that has a corresponding value in SSJS (context, requestScope, sessionAsSigner, etc.), including any that your own code has already defined in the current execution context by the time the Java code is invoked. 
 
FWIW, if you're using the Extension Library, there's already a class called ExtLibUtil that provides convenient static access to all manner of useful stuff.
Mar 11, 2011, 3:24 PM
16 Posts
Re: ECL Permission Denied on a Java class
Thanks so much Tim. Really helpful and I've added your DominoUtils suggestion to my Java package
 
I have a much better understanding now

(I solved my initial problem by simply passing session to my Java function in SSJS!)
Mar 11, 2011, 4:02 PM
41 Posts
Re: ECL Permission Denied on a Java class
 That works too. :) I like to keep my method arguments to a minimum, but sometimes it's so much easier to just pass things like session, context - and, of course, this - to a method than to try to reacquire it from within, especially when bouncing back and forth between languages.
Mar 14, 2011, 10:20 PM
39 Posts
Re: ECL Permission Denied on a Java class
Thanks Tim,
 
I hadn't noticed this class "ExtLibUtil" until you mentioned it.  This should keep me from adding my own every time.  Thanks

-Toby

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal