Oracle BI EE 11g – Action Framework – Java, EJB's and PDF Watermarks
September 14th, 2010 by Venkatakrishnan J
As mentioned in the blog entry yesterday, Action Framework of BI EE 11g opens up direct integration with Java. So, any process that can be called via Java can be directly called from BI EE as well. In 10g, the only way for calling Java Processes was by using Delivers. I have blogged about it in detail here. In 11g, the old method is still supported but is not recommended. The recommended approach is to embed the Java Methods in a EJB session bean and then call it from BI EE. Lets look at how the integration works in this blog entry. To make it interesting, lets look at a method of adding Watermarks to the standard PDF export available in BI EE.
For this example, we will be needing JDeveloper 1113. We start of with creating a simple Generic Application called WaterMark as shown below in JDeveloper
Also create a Generic project without any components in the project.
Now within this project create a new EJB Session Bean.
Use the EJB 3.0 option as i believe only EJB 3 is supported in BI EE.
Create a Stateless Bean as shown below
Note down the Mapped Name as that is what will be used when we create the methods within the EJB. Leave the Bean Class to be with the default value. Also, ensure that the Remote and Client Interfaces are chosen to be implemented within the project
![]()
This should create 3 java files within your project as shown below.
For calling EJB’s, we need to always include a Jar file called actionframework-common.jar. This is what enables the 2 way communication between BI EE and the EJB’s. This jar file is generally present under {MIDDLEWARE_HOM}\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\bimiddleware_11.1.1\udy1lp\lib folder. The udy1lp folder is a temporary folder. This could be different in your installation.
Also in our example, we are planning to watermark a PDF generated by BI EE. There are different ways of doing this. One way is to use the BI Publisher watermarking feature that we put into use before here. To keep it simple, i will be using the iText package available for download here. Ensure that the project that we created above has both the actionframework-common.jar and the iText-xxx.jar in the Classpath.
For watermarking, in my example here, i will be using the Rittman Mead logo. This logo will be placed in a directory called C:\PDFExport. This logo will be referred in our main Session Bean code.
Open up SessionEJB.java and enter the code below. This declares our method that we will be calling from BI EE.
package watermark;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.activation.ActivationDataFlavor;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.activation.URLDataSource;
import javax.ejb.Remote;
import oracle.bi.action.annotation.OBIActionParameter;
@Remote
public interface SessionEJB {
String WatermarkReport(
@OBIActionParameter (name = "Enter Filename",
prompt = "Enter filename location:") String filename,
@OBIActionParameter (name = "Analysis",
prompt = "Report to Export:") DataHandler document)
throws FileNotFoundException, IOException;
}
Open up SessionEJBBean.java and enter the code given below. This is where we will be implementing our method.
package watermark;
import com.itextpdf.text.Image;
import com.itextpdf.text.pdf.PdfContentByte;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
@Stateless(name = "SessionEJB",
mappedName = "ejb/WaterMark-watermark-SessionEJB")
@TransactionManagement(TransactionManagementType.BEAN)
@Remote
@Local
public class SessionEJBBean implements SessionEJB, SessionEJBLocal {
public SessionEJBBean() {
}
public String WatermarkReport (String filename,
javax.activation.DataHandler report) throws FileNotFoundException,
IOException {
File f = new File(filename);
FileOutputStream outputStream = new FileOutputStream(f);
report.writeTo(outputStream);
outputStream.close();
try {
PdfReader pdfreadobject = new PdfReader(filename);
int no = pdfreadobject.getNumberOfPages();
int cnt = 0;
PdfStamper pdfstamp = new PdfStamper(pdfreadobject, new FileOutputStream("C:\\PDFExport\\RMWatermark.pdf"));
PdfContentByte pdfcontent;
Image image = Image.getInstance("C:\\PDFExport\\RMLogo.png");
image.setAbsolutePosition(300, 400);
while (cnt < no) {
cnt++;
pdfcontent = pdfstamp.getUnderContent(cnt);
pdfcontent.addImage(image);
}
pdfstamp.close();
}
catch (Exception ex) {
ex.printStackTrace();
}
return "Report Exported";
}
}
And finally in the SessionEJBLocal.java enter the code given below
package watermark;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.activation.ActivationDataFlavor;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.activation.URLDataSource;
import javax.ejb.Local;
@Local
public interface SessionEJBLocal {
String WatermarkReport(String filename, DataHandler document) throws FileNotFoundException,
IOException;
}
Now compile this entire project. Create a deployment profile for this project using EJB-JAR option and ensure that the libraries that we have chosen are included properly in the profile.
![]()
Create an EAR deployment profile for the Application and refer to the EJB-JAR deployment profile that we created for the project as shown below
![]()
![]()
Deploy the EAR file to the file system. Then deploy this to weblogic. Ensure that you are deploying this to the same managed server as BI EE.
![]()
![]()
After deploying and starting up the application, we need to update the ActionFrameworkConfig.xml to enable Java Method calls from BI EE. Open up ActionFrameworkConfig.xml present under {MIDDLEWARE_HOME}/user_projects/domains/bifoundation_domain/config/fmwconfig/biinstances/coreapplication and add the following registry tags.
<registry> <id>reg05</id> <name>WaterMark EJBs</name> <content-type>java</content-type> <provider-class>oracle.bi.action.registry.java.EJBRegistry</provider-class> <description>WaterMark BIEE</description> <location> <path/> </location> <custom-config> <ejb-targets> <appserver> <context-factory>weblogic.jndi.WLInitialContextFactory</context-factory> <jndi-url>t3://localhost:9704</jndi-url> <server-name>localhost</server-name> <account>WLSJNDI</account> <ejb-exclude>mgmt</ejb-exclude> <ejb-exclude>PopulationServiceBean</ejb-exclude> </appserver> <ejb-app> <server>localhost</server> <app-context>watermark</app-context> </ejb-app> </ejb-targets> </custom-config> </registry>
If you look at the registry XML above, there is an accounts tag which is what basically controls the security. So, in order for BI EE to be able to execute a Java process, we need to setup a credential entry that allows the execution. To do that, we log into the Fusion Middleware Control (http://localhost:7001/em) and then right click on bifoundation_domain (under WebLogic Domains) to navigate to the Credentials
![]()
![]()
If you do not have the Credential Map called oracle.bi.actions already, create it using the Create Map option.
![]()
Under this Credential Map, create a new Credential Key called JNDIUser using the Create Key option. The username and password used in this key can be any valid repository username & password
![]()
Restart the entire managed server so that the changes can be picked up by BI EE. Now log in to BI EE and create a new Action using the Java Method.
![]()
This will show our Java Method that we deployed. Choose the Method and enter the parameters as shown below
![]()
As you see, the parameter list shown in BI EE are the parameters that we have specified in the EJB method. So, essentially BI EE looks at the data type of the Java Methods and shows the parameter list accordingly. If we execute the action, you can basically see that a PDF of the report will be saved in the directory specified and the PDF will be watermarked with the Rittman Mead logo.
This might look like a lot of steps but most of it is a one time setup activity.


September 14th, 2010 at 2:29 pm
Very good post, Venkat. Thank you.
Can’t wait to try it out.
September 14th, 2010 at 5:56 pm
Chapeau !
September 15th, 2010 at 6:09 pm
Excellent work!!
February 14th, 2011 at 2:06 pm
I followed the whole guide step by step but I can’t find my EJB module when I start creating a new Action. I have doubts about the right position where inserting the registry info in the ActionFrameworkConfig.xml. Has it to be inserted between the tags and replacing the default tag ? ( registry internal tags ). What could I have missed? All the rest worked fine: deployment,start up..etc..
Thanks, Luca.
April 28th, 2011 at 10:39 pm
I got the same issue than Luca, please reply with a solution.
Thanks,
G
May 1st, 2011 at 3:33 am
Giovanni,
This is very cool. I agree that the integration with OBIEE 11g and Java is really exciting. This is a great example of how a smooth integration can be accomplished even though it appears to be complex. Good Stuff!
July 25th, 2011 at 4:33 pm
I followed the blog to the letter as well and found that it didn’t work. See below the additional changes I had to include to make this work:
reg05
WaterMark EJBs
java
oracle.bi.action.registry.java.EJBRegistry
WaterMark BIEE
weblogic.jndi.WLInitialContextFactory
t3://localhost:9704
localhost
WLSJNDI
mgmt
PopulationServiceBean
localhost
watermark
webservices
Web Services and BPEL Processes
WebServiceActionType
misc
Mixed Services
URLActionType
java
Java Actions
JavaActionType
WLSJNDI
Used for Actions Invoking EJB Methods
false
JNDIUser
oracle.bi.actions
July 27th, 2011 at 6:09 am
Hi,
I tried to replicate above example step by step. But I am not able to see the custom method in “Invoke Java Method”. It just display No Contents. I have added the registry tag between in ActionFrameworkConfig.xml file. Am I missing something?
Regards,
Praneet.
July 27th, 2011 at 12:07 pm
@Karl -
This should definitely work as I demoed this in OOW last year. Are you on 11.1.1.3 or 11.1.1.5? I haven’t tested this on the new release. I will try to see whether I can upload the jdev project somewhere so that you can test it.
- Venkat
November 10th, 2011 at 4:28 pm
@Karl -
Hi Karl,
What changes yo have done to make this work. I have replicated the whole process but I am not able to see the custom method in “Invoke Java Method”.
November 18th, 2011 at 2:44 pm
Thank you very much Mr. Venkatakrishnan and Mr. Karl. I try to describe in detail what I had troubles with following this article.
1/ ad ActionFrameworkConfig.xml
you may finf useful to look into ActionFrameworkConfig.xml definition file afconfig.xsd, located in same directory as ActionFrameworkConfig.xml. <registry> is subelement of <registries>
2/ here http://www.orastudy.com/oradoc/selfstu/fusion/bi.1111/e16364/actions.htm can be found what Karl is writing about – missing <account> and <content-type> elements.
3/ ad libraries in {MIDDLEWARE_HOM}\user_projects\domains\bifoundation_domain\servers\bi_server1\tmp\_WL_user\bimiddleware_11.1.1\udy1lp\lib folder – we have more OBI instances, I found libraries only on some of instances, don’t know why.
4/ in jDeveloper 11g, JAR deployment profile can be created from Project properties, EAR deployment profile can be created from Application properties (in Application Navigator – there are two dropdown lists on one line, click on right and smaller one, it’s right at the end of list). To deploy application, you will need connection defined in IDE Connections – Application Server
February 22nd, 2012 at 11:09 pm
Hi
for some reason, I am not able to see the java methods when I click on “Invoke Java Method”. I am on 11.1.1.3
Anyone any idea??
April 11th, 2012 at 1:06 pm
I have solved the No Content issue by checking and reparing the following:
- the JNDI Tree in WLS to see if it does show your ejb in the ejb entry.
If not, double check whether you have used a mappedName preceded by ejb in the SessionEJBBean.java (i.e. “ejb/WaterMark-watermark-SessionEJB”). After changing your mapped name make sure to redeploy your application.
- Check the account entry in the ActionFrameworkConfig.xml. Be aware that the config file format has changed from 11.1.1.5 to 11.1.1.6. The oracle.bi.actions entry is obsolete in 11.1.1.6
- Check the used account in the registry entry, make sure that account exist as account entry. The config file is located in \user_projects\domains\bifoundation_domain\config\fmwconfig\biinstances\coreapplication. Do not use the master copy that is located in a different location.
- Check the user and it’s permissions in the security realm. This user should be part of the BIAdministrators group. Edit the user to add this group.
- Check the Credentials in Enterprise Manager to see if the user referred to in the account entry is created as key map in the oracle.bi.actions map entry with the appropriate username and password.
NOTE: Make sure to recycle the BI server environment after making configuration changes or editing the users permissions.
Hope this helps.
Regards,
Evelyn
April 20th, 2012 at 4:21 pm
Hi Evelyn Gerritsen,
could you tell me more info about the solution to the No Content problem. I’ve applyed your checking but I don’t solved the problem
Thanks
Annalisa
June 1st, 2012 at 1:42 pm
I have followed all the steps.Still “No Content” is displayed in the screen
June 15th, 2012 at 11:40 am
Please see the following document for more detailed instructions and screenshots https://www.wetransfer.com/dl/LMJ6zbQ0/53e3da7a123fd83feb1e099848c335826fc9b6d631be04ec6d03b71d4fae2507bd9f93993e46c0b
This file will be available until June 29th, 2012
June 19th, 2012 at 4:29 pm
Can we get the EAR file developed on a different system and then deploy it in OBIEE environments DEV, TEST, PROD? Will this work in Linux ? Is there any special steps to be followed for such deployments ?
June 20th, 2012 at 11:43 am
I have done the same steps as mentioned above to the letter, even configured the ActionFrameConfig.xml as suggested, but still i See No Content only when i Invoke Java Method.
I am using version 11.1.1.6
June 20th, 2012 at 12:16 pm
To add, I am able to see my EJB in JNDI Tree structure in Weblogic console, but still “No content” when in try to Invoke Java Method from Actions
July 18th, 2012 at 12:54 am
Make sure the ActionFrameConfig.xml document is well formed. I had a bit of trouble when I copied the registries part from the article into the file. Also make sure to remove the tag from .
July 18th, 2012 at 12:57 am
Make sure the ActionFrameConfig.xml document is well formed. I had a bit of trouble when I copied the registries part from the article into the file. Also make sure to remove the credentialmap tag from the account element.
September 25th, 2012 at 6:48 pm
Hi Evelyn,
Is it possible to post the below link for file again?It will be very helpful for me.
https://www.wetransfer.com/dl/LMJ6zbQ0/53e3da7a123fd83feb1e099848c335826fc9b6d631be04ec6d03b71d4fae2507bd9f93993e46c0b
Thanks,
Swati
October 15th, 2012 at 6:03 pm
Is there a way I can invoke an analysis which has filters using Dashboard prompt from this action framework and achieve the watermark functionality?
January 3rd, 2013 at 10:08 pm
Very interesting !! Is there a java library like iText for excel exports ??
January 30th, 2013 at 6:34 am
Hey Venkat
thanks for such a wonderful help. But while invoking the java method i m getting a error which says
Action cannot be executed as it contains more than one result set mappings.
Would love to hear any suggestion
Thanks
March 20th, 2013 at 8:16 am
This implementation will work on UNIX/Linux/Aix?