Wednesday, October 27, 2010

Resolution of Exception in thread "main" java.lang.NoSuchMethodError, oracle.fabric.composite.model.CompositeModel.getFolder()Ljava/lang/String;

Tools: JDeveloper11., SOA Suite Enterprise Manager 11g (
When deploying SOA Composite from JDeveloper I was having error.

Exception in thread "main" java.lang.NoSuchMethodError: oracle.fabric.composite.model.CompositeModel.getFolder()Ljava/lang/String;
at oracle.soa.scac.ValidateComposite.loadComposite(
at oracle.soa.scac.ValidateComposite.doValidation(
at oracle.soa.scac.ValidateComposite.main(

It is because; the ORACLE_HOME does not have the updated fabric-runtime.jar file

How to fix this issue, you need to copy the folder “oracle.soa.fabric_11.1.1” from your SOA installation to your ORACLE_HOME

Copy the folder “oracle.soa.fabric_11.1.1”, you will find this folder in your installation directory of SOA, in my case the folder location was C:\Oracle\Middleware1\Oracle_SOA1\soa\modules

Paste this folder to there, where you have your ORACLE_HOME, in my case I have pasted this folder to C:\Oracle\11gR1PS2\jdeveloper\soa\modules, while pasting you will be asked to replace the folder, so replace and copy it. Before doing this you need to close your JDeveloper.

Hope it will work


Monday, October 18, 2010

File attachment using Adf faces, EJB3 and Oracle XE database Part IV

Downloading file

In download button, add FileDownloadActionListener and select fileDownloadActionListener from backingBean

The binding of attachment page should looks like above.

Following is the code in AttachmentBackingBean

public void downloadAction(FacesContext facesContext, OutputStream outputStream) {
    Attachment att = (Attachment)attachmentList.getSelectedRowData();
    ExternalContext ectx = facesContext.getExternalContext();
    String fileName = null;
    byte[] contents = null;
    if (att == null) {
    } else if (att.getAttachmentId() == null) {
      fileName = att.getFileName();
      contents = att.getFileContent();
    } else {
      OperationBinding oper = getBindings().getOperationBinding("findAttachmentById");
      oper.getParamsMap().put("attachmentId", att.getAttachmentId());
      Attachment attachment = (Attachment)oper.execute();
      fileName = attachment.getFileName();
      contents = attachment.getFileContent();

    BlobDomain content = new BlobDomain();
    Long length = content.getLength();

    HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
    response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + "\"");
    try {
        InputStream in = content.getBinaryStream();
        byte[] buf = new byte[1024];
        int count;
        while ((count = >= 0) {
            outputStream.write(buf, 0, count);


    } catch (IOException ex) {

Your binding of attachment page should be like this.
Deleting File

On delete File button, provide the actionListener and bellow is the code for actionListener
public void deleteFile(ActionEvent actionEvent) {
     Attachment attachment = (Attachment)attachmentList.getSelectedRowData();
     if ( attachment != null ) {
       List  attachments = (List)AdfFacesContext.getCurrentInstance().getPageFlowScope().get("attachmentList");

You can download the source from

I would like to say special thanks to my team members specially Pino and Owie for their support.

I will appreciate anyone who comments and let me know the more appropriate way for doing the same task.

File attachment using Adf faces, EJB3 and Oracle XE database Part III


Step III: Creating taskflow for file-uploading popup
Design the list of employees like following

List of employees page

Here the “New” button will open new tab for creating “Person”, “Refresh” button simply executes the "Execute" function and “Detail” will open new table populating selected record data for editing.
The edit/new person screen should be like follwing

add/edit person screen

In add/edit person screen, "Save" button updates or inserts new record into the database, close button will close the tab and "Attachment" button opens the popup for file attachment.
Lets design the taskflow for fileAttachment
Create the new taskflow for Attachment
Click on overview and select General, uncheck “Use Page fragements”

Click on Parameters and define input parameter and return parameter as follows.

Create a new java file, and in Managed Beans, provide that file path and name here as

Add a page and a return activity in your taskflow as

Designing Attachment form
Create attachment page and design it as follows

Add a table and buttons as above, Select the value for table and row selection as single.

Bind table with backingBean property.

Creating File brows popup

Create popup and inside popup add dialog

Add ActionListener for Save File button

public void commitUpload(ActionEvent actionEvent) {
  List attachmentList = (List)  AdfFacesContext.getCurrentInstance().getPageFlowScope().get("attachmentList");
  if (attachmentList == null)
    attachmentList = new ArrayList();
  System.out.println("commit upload");
  AdfFacesContext.getCurrentInstance().getPageFlowScope().put("attachmentList", attachmentList);

/** Hide upload method **/
 private void hideUploadWindow() {
   FacesContext context = FacesContext.getCurrentInstance();
   ExtendedRenderKitService service = Service.getRenderKitService(context, ExtendedRenderKitService.class);
   //callling javascript function
   service.addScript(context, "hidePopup();");

Add ActionListener for Cancel button

public void cancelUpload(ActionEvent actionEvent) {

Add valueChangeListener and BindingFor Input file

private RichInputFile inputFile;
private Attachment acchmentEntity1;

public void setInputFile(RichInputFile inputFile) {
  this.inputFile = inputFile;
public RichInputFile getInputFile() {
  return inputFile;
public void onUploading(ValueChangeEvent valueChangeEvent) {

  UploadedFile file = (UploadedFile)valueChangeEvent.getNewValue();
  String fileName = file.getFilename();
  BlobDomain blobDomain = createBlobDomain(file);
  byte[] dataContent = blobDomain.getStorageByteArray();
  acchmentEntity1 = new Attachment();

private BlobDomain createBlobDomain(UploadedFile file) {
    InputStream in = null;
    BlobDomain blobDomain = null;
    OutputStream out = null;
    try {
        in = file.getInputStream();

        blobDomain = new BlobDomain();
        out = blobDomain.getBinaryOutputStream();
        byte[] buffer = new byte[8192];
        int bytesRead = 0;

        while ((bytesRead =, 0, 8192)) != -1) {
            out.write(buffer, 0, bytesRead);
    } catch (IOException e) {
    } catch (SQLException e) {
    } finally {
        try {
        } catch (IOException e) {
    return blobDomain;

Add javascript function, and in form tag provide usesUpload="true", here in my case "uploadWindow" is the name of my popup

Here is the code for my popup
 Click on Design view, click on "Attach File" button provide actionListener for button and add showPopupBehaviour inside the button

Inside Attach file button add showPopupBehaviour provide your popupId in popupId attribute. The code for your button should looks like as above.
  Implement actionListener as below

public void openPopup(ActionEvent actionEvent) {

Call the return activity on "Done" button for returing from the taskflow
  Now we need to call attachment-task-flow from edit person page, open person-detail-task-flow and design it as follows

Provide the input parameter attachmentList from page flow,
we will next set this value from backingBean of person-detail-task-flow
Provide Run as dialog true, and display type as Inline-popup
 Calling attachment-task-flow from edit person page
Open person-detail-task-flow, and open the page make following modifications in "Attachment" button
Provide Action method and returnListener method in edit-person-task-flow manageBean as

/** **/
public String launchAttachment() {
  Person person = (Person)getCurrentRowDataProvider("findPersonByIdIterator");
  getPageFlowSceop().put("attachmentList_", person.getAttachments());
  return "to_attachment";

public void handleReturn(ReturnEvent returnEvent) {
  Map m = returnEvent.getReturnParameters();
  List attachmentList = (List)m.get("attachmentList");
  Person person = (Person)getCurrentRowDataProvider("findPersonByIdIterator");

 * Reference
protected BindingContainer getBindings() {
  return (BindingContainer)JSFUtils.resolveExpression("#{bindings}");

protected Object getCurrentRowDataProvider(String iteratorName) {
  BindingContainer bindings = getBindings();
  DCIteratorBinding dcib = (DCIteratorBinding)bindings.get(iteratorName);
  RowSetIterator iter = dcib.getRowSetIterator();
  DCDataRow row = (DCDataRow)iter.getCurrentRow();
  return row.getDataProvider();

Bindings of person_detail should looks like above.

And for the save button in person edit screen it should be binded with datacontrol method "savePerson"
  Running the file attachment use case followings are the snaps for file uploading and saving it into database


Saving person will also save the attachments which are associated with it.
 Now when you click on Save button in add/edit person the attachment also get save into the database. You can also add more files to the person. The functionality of file attachment is completed

The other functionalities like downloading file, deleting file will come on next section.
To be continue -->
Comming up next download and deleting associated files

File attachment using Adf faces, EJB3 and Oracle XE database Part II


Step # II Create Entities from Database Tables,Session Bean & Data Controls
Creating Entities from database table

Create entities from table

Create database connection and provide the information of your XE Database

Select PERSON and ATTACHMENT tables to create entities




Entites should be created.
 You need to add Sequence annotation and define relationship of ATTACHEMTN table with PERSON table as follows.


  Creating Session bean




  We Also need to add following functions into our session bean

Then expose these functions to remote and local interfaces
Click on Structure, right click on function, click on EJB(N) and then properties you will see the dialog

Check on both checkboxes and click on OK button, the methods should be generated in remote and local interfaces. do the same with all newly added functions.
Now rebuild the model
Creating datacontrols
Right click on FileUploadFacadeBean and click on "Create Data Control" then click OK button
Data controls should be created.
To be continue -->
Coming up next "Taskflow for file upload popup"

File attachment using Adf faces, EJB3 and Oracle XE database Part I


I want to associate files with employees (PERSON). I will have employees(PERSON) with their associated files which will hold the more information for that employees (PERSON) like (employee’s picture, list of his dependant, his Resume etc)

My ERD will have PERSON and ATTACHMENT tables, and a join table between PERSON and ATTACHMENT that is PERSON_ATTACHMENT.

The relation between PERSON AND ATTACHMENT is ONE TO MANY, A single employee (PERSON) can have many attachments.
Step # 1 Creating tables in Oracle database XE
Let’s first create the Tables in Oracle XE Database.
Open your Oracle Database XE by clicking on “Startup” select “Oracle Database 10g Express Edition” and then click on “Go to Database Home page”
Login to Oracle Database XE.
Creating PERSON  Table

PERSON table

PERSON table also create sequence for PERSON table

PERSON table
Create Attachment table with three columns "ATTACHMENT_ID", "FILE_CONTENT" & "FILE_NAME"

ATTACHMENT table, also create sequence for attachment table

Create join table between PERSON and ATTACHEMTN as "PERSON_ATTACHMENT".


PERSON_ATTACHMENT table, make composite primary key

Create Foreign keys

Create Foreign keys

 While creating tables we also added sequences and it causes to generate triggers as well, so in our case we need to delete these triggers, 1. In Object browser select "Triggers" in dropdown, it will show you all the triggers, in our case there will be only two triggers with the name "BI_ATTACHMENT" and "BI_PERSON"
Following are the steps to remove the triggers.

Remove these triggers as follows



To be continue-->
Comming up next
Step II Creating Entities from Database tables, Creating Session beans