Archive for the ‘ADF’ Category

Create a demo using EJB 3.0, Toplink and ADF as the UI layer and Bpel and ESB as the back-end layer (through web service invocation) – Episode 1

May 15, 2007

The case I worked out for my demo application is the following: Create a new person via the UI (using JSF and EJB3.0 as data-layer) and initiate a bpel process for the creation of the person. The bpel process will check if all business requirements were met for the person that needs to be created using Business Rules.
A human task was added to make sure the Personal Manager has approved the new person and finally an ESB was added to actually create the person.
The ESB will transform the person-object, an xml-file, to the specific format I need to be able to insert the person in my db.

During the creation of my demo-project I faced some design problems which I will explain in the following chapters:

The first part of the case was simple, create a UI using EJB 3.0 and ADF Faces using JDeveloper as my IDE.
The UI consists of a ListPersons.jspx – page that lists all existing persons of my persons-db and a link to the CreatePerson.jspx-page. In the CreatePerson.jspx page I will create a new Person and initiate the bpel process from here.

But it wasn’t as simple as I thought … to be able to initiate my bpel process using the EJB-objects I needed to prefetch the sequence-value needed for uniquely identifying the person-object, e.g. the Person.personid. This is needed because the bpel process needs all xml-tags to be filled in. If for example the personid, or firstname isn’t filled in you will get the following exception ‘unexpected null value for literal data’.

To be able to prefetch the id in my EJB i thought I could ‘eagerly fetch’ this id using an annotation in EJB 3.0, but there’s no such annotation available :(

What to do next … fetch the sequence value myself and populate the Person.personID with my sequence-value.

I’ve added a new method in my SessionBean that gets the sequence value from my db-sequence, this method is invoked from my custom-method ‘createPersonObject() which constitutes a valid person-object.

The custom-method to fetch the sequence-value uses the ‘createNativeQuery’-method on the EntityManager:

em.createNativeQuery(“select person_seq.nextval from dual”);

The UI now works correctly, using the createPersonObject()-method as binding-layer to go to the CreatePerson.jspx file.

Now I need to link my existing Bpel Process to this UI … coming up soon …

Solution for page refresh problems in ADF when no relationships are used.

May 11, 2007

I have a small program which is used for registering money transfers.

It has two tables, table A holds all the transfer information and table B keeps the total amount of money earned so far. There is no connection between the tables, there are only triggers on table A which keep table B up to date.

On the overview page it looks like this:

The problem that I had was that when I pressed “Create” and inserted a new record, the total amount field was not updated after the create page navigated back to the overview page. It didn’t refresh, but the trigger was called and executed. So, for example, after “2 very large bags of potatoes” was inserted the “Total Amount” field would still display 10, although if you peeked in table B it would say 30.

I don’t know if it’s the right solution, but I solved it this way:

In the page definition of the overview page I made a new action, an execute action based on the iterator of table B.

<action IterBinding=”TotalAmountIterator” id=”ExecuteTotalAmount”
InstanceName=”SampleServiceDataControl.TotalAmount”
DataControl=”SampleServiceDataControl” RequiresUpdateModel=”true”
Action=”2″/>


To invoke it every time the page is loaded, you do this:

<invokeAction Binds=”ExecuteTotalAmount”
id=”ExecuteTotalAmountOnPageLoad”
Refresh=”always”
RefreshCondition=”#{!adfFacesContext.postback}”/>

So far the Total Amount field will always be refreshed when the application navigates to the overview page.

There is only a small exception, the delete button. The effect of pressing the delete button – besides the deletion of the record – is a partial page refresh, so the main table is OK, but the total amount field is not.

I fixed it by calling the method I declared in the page definition in the deleteButton method in the backing bean of the overview page.

public String deleteButton_action() {
BindingContainer bindings = getBindings();
OperationBinding operationBinding =
bindings.getOperationBinding(“Delete”);
Object result = operationBinding.execute();

operationBinding = bindings.getOperationBinding(“Commit”);
result = operationBinding.execute();

operationBinding = bindings.getOperationBinding(“ExecuteTotalAmount”);
result = operationBinding.execute();

return null; }

Oracle Webcenter technical workshop (part 2)

April 24, 2007

As promised here is the continuation of the technical workshop we have followed.
In this text I will talk about how we created a little appliciation in Webcenter with some build in features of webcenter. In most part of the exercise we used ADF to build this, but we have also build in some out-of-the-box portlets of webcenter such as the Omniportlet and the Rich Text Editor Portlet but this will be discussed later.

I will go into detail on the real webcenter development and I will not go into detail about the not really webcenter related issues(this is not a step by step guide)

If you want to know more about this, you will have to read further

First thing we had to do of course is to open Jdevelopper, since this is the (free) tool which is used to create the webcenter portlets – portals. The version we need for using Webcenter is jdev 10.1.3.2.0 (or later).

Then we had to create a new application. If you want to create a porlet application you have to select Webcenter Application(Portlet, content Repository,JSF) as application template.
This will not only create a new application for you, but it will already contain some structure to build your pages – portlets in. The structure contains 3 ‘directories’: Model, ViewController and Portlets. As we have already mentioned webcenter uses the MVC ADF framework. The next thing was creating a portlet. We had to right click the portlets ‘directorie’ in the application navigator and then choose the option below Web Tier -> Portlets which was ‘Standards based Java Portlets(JSR-168) the other option is the Oracle PDK-Java Portlet (this is based on the Oracle portal API’s).

Next thing we had to do in the creation wizard was to select the web application version. We had the choice between j2ee 1.3 and J2ee 1.4

We also had to give in some names, titles, keywords,… and we had to make a choice which portlet modes we wanted to use(possibilities are: help, about, config, preview, print, view, edit and edit_defaults), for this exercise we only choose view, edit and edit_defaults. For each of these 3 modes a different jsp will be build.

In this wizard you will also have to create the parameters if you want to use some in your portlet.

Once finished, our first portlet was created. But before deploying this we had to create a link to an application server and a deployment file.

In this version of jdev there is a preconfigured OC4J for webcenter. So we used this container to deploy our application on, we didn’t had to install the webcenter suite for testing our portlets. You first have to start this container, this can be done by clicking the green light on the top right of the menu in Jdev.


Hint, when creating a connection you should use 22667 as RMI port, this is the default RMI port for the webcenter container.

Once your portlet is deployed into your OC4J you can find the WSDL URL by using http://localhost:6688//portlets/wsrp2?WSDL.
We have now created a portlet but we don’t have a page to publish it on. Therefor we had to rightclick the Viewcontroller ‘directorie’ in the Application navigator and choose New. Once again you will have to choose a technology, in this case we had to choose JSF JSP(Web Tier -> JSP) .
A wizard opens and we choose jspx (xml version of a jsp page). In the wizard we selected the needed libraries(adf faces components,adf faces html,customizable components, jsf core, jsf html) since we were going to use some parts of all these libraries we selected them all.

So now we have a portlet and a page, but how do we have to include this portlet into the page? Well we have to register the portlet into the oracle Webcenter framework. Go to the Application Navigator and right click the Viewcontroller and click new. Select WSRP Producer Registration(Web-Tier -> portlets). In the next wizard you will have to give in the WSDL URL(see above). Once you have selected all the other attributes you click finish and your portlets is registered.

Now you just have to drag and drop the portlet into the jspx file. Therefor you have to open your jspx file and then select your producer in the Component Palet and drag and drop your portlet into the application.

Conclusion: I believe that there is a good future for this product it has lots of options and lots of potential, but you have to get used to all the possibilities of it and where you have to select what… But I believe that you really can create some nice working portal pages after a few days. If you want to learn more about ADF or webcenter there is only one option, start using it! I really got interested in it maybe you do too…

Deploying ADF Application to IAS 10.1.3.1

April 23, 2007

As you could read in my previous post, ‘Deploying ADF Application to Standalone OC4J’, I’ve faced some problems when trying to deploy the application to a Standalone OC4J.

But the goal is to deploy this application to the production environment which would be an Application Server 10.1.3.1.

When trying to deploy to this environment other problems arrised …

When we took the same deployment plan of the standalone OC4J, which worked splendidly, the deployment failed to the IAS 10.1.3.1 environment.

We still encountered the ‘NoClassDefFoundError: oracle/jbo/JboException’ which arises when you didn’t install the ‘ADF Runtime Installer’ libraries to your environment. The weard problem was that we had run the ADF Runtime Installer on our IAS environment, in the same way has we did for our standalone OC4J and it only worked for OC4J.

After investigating the problem further we found out that the libraries that should be copied by the ADF Runtime Installer, weren’t available on our IAS Environment. The ADF Runtime Installer will copy over all the needed libraries to your IAS/OC4J to be able to run ADF applications on your container. These libraries are copied over to the BC4J-folder of your environment, which isn’t the case for IAS.

What we did was manually copy the libraries (jar-files) from ADF Runtime Installer to our IAS Environment. This means you have to copy the content of the following folders: jlib, lib and redist to your IAS-environment under the IAS_HOME\BC4J folders.

After you’ve done this you’re able to deploy the application to your IAS Environment using the deployment plan you’ve set up for as well the standalone OC4J as IAS.

Because we’re working with Toplink we also have to copy over the xdb.jar file from our toplink-workbench\bin folder to the Toplink folder of IAS. The same step we’ve done for our standalone OC4J, as mentioned in the previous post.

Deploying ADF Application to Standalone OC4J

April 19, 2007

For the deployment of an ADF Application to my standalone OC4J I’ve faced some problems which aren’t clearly explained/solved on OTN.
You will find many people facing the same problems when deploying applications to OC4J from jboException until Log4j-exceptions, etc.

I will try to address some of these problems in this blog using my own project deployed to a standalone OC4J.

Following errors/problems cam uping during deployment:

  • java.lang.NoClassDefFoundError: oracle/jbo/JboException
  • java.lang.NoClassDefFoundError: org/apache/log4j/Category
  • Problems with shared libraries and user-libraries when deploying from JDeveloper-IDE
  • Memory problems during deployment

How were this problems addressed and how did I package the application?

In my J2EE application the following technologies are being used: Toplink, EJB 3.0, OCS and finally ADF Faces as the frontend. Additional libraries we’re using: log4j-libraries.

This J2EE application uses the MVC-paradigm which means i’m working with 3 important layers: Model, View and Controller. In my case the Model is written in Toplink, the DataControl which is the glue between the Model and View is based on the EJB 3.0 (sessionbeans) and in the end we which faces for our Controller.

How did I package this application, by the creation of deployment profiles for each application that’s used in the application:

  • A jar-file for the Toplink-model and bizzlogic-model
  • An ejb-jar file for the EJB-project(s)
  • A war-file containing all logic of the view-layer (jspx, images, pageDefinitions, backing beans, web.xml file, jazn-data file, orion-application.xml file, etc.
  • An ear-file packaging all the different deployment profiles together using the Application Assembly tool

As I mentioned before i’m using log4j in the application and I experienced a lot of problems during deployment because a newer version of log4j is used in our application, than the one which is used by default by OC4J. How can you solve this problem:

  • Add the version you’re using in your project (log4j-1.2.13.jar) and the commons-logging jars from JDeveloper to the EAR file and point towards these 2 jar-files in the MANIFEST.MF file from the project that uses log4j

Secondly I mentioned Toplink is used for the Model-layer for which we needed to perform a manual configuration as well:

  • Copy xdb.jar from the toplink workbench folder to the directory of the standalone OC4J installation \toplink\jlib\xdb.jar

To address the jboException you need to install the ADF Runtime Installer to your standalone container. You can do this using the JDeveloper IDE, first create an Application Server Connection to your standalone OC4J. Go to the menu ‘Tools’, choose the ‘ADF Runtime Installer’ and choose to deploy to ‘standalone OC4J’.

Make sure your OC4J isn’t running when you perform this task because otherwise all libraries can’t be upgraded because they’re being used by the container.

Last but not least the ‘OutOfMemoryException’/PermGen Space can be adressed by adding memory to your standalone OC4J or IAS. For OC4J you could add the following attribute to the oc4J.cmd-file which can be found in the bin-folder of your oc4J_home => add the following:

OC4J_JVM_ARGS=-XX:PermSize=128m -XX:MaxPermSize=256m

If you need an indepth explanation about memory-management you can view the Memory Management topic on this blog.

Have fun!

Oracle Webcenter technical workshop (part 1)

April 19, 2007

On the 17th of april we where invited to join a technical workshop about Oracle Webcenter for partners at Oracle DeMeern near to Utrecht (Holland).

We wanted to know what Webcenter really could do for us, and what the capabilities are, and of course what the next generation of Webcenter would look like.

Well, we came back full of enthusiasm and the will to explore and look deeper in the webcenter technology.

Read further …

What have we seen during that day?
First of all we got an introduction about all the different layers on which the webcenter framework was build.
And we also saw that webcenter uses several known standards like wsrp, jsr168, jsr170, web 2.0 …


They explained that the Webcenter framework uses Oracle Metadata Management (MDS). This is an XML based repository that stores all kinds of application metadata. In the version we use now this is file based, but in future versions the user will have the choice between file and database based storage.
Webcenter is the first tool in the fusion stack that uses MDS but in the next releases this will also be used for other tools.

In Webcenter it is also possible to use existing portlets/pages/… Therefore you will have to use the ‘Federated Portal Adapter’.
The other way round is also possible, by using the ‘JSF Portlet Bridge’. This will make it possible to publish any portlet created in webcenter to a portal (e.g. oracle portal) that supports jsr168.

The main subject of the day was the JSF part. Oracle uses their ADF framework for creating these kinds of applications.
Not being a real java expert, I really enjoyed working with this tool and the fastness of creating little applications with it.
In the webcenter there are already a few build in portlet applications like the rich text editor, omniportlet which we already knew from the oracle portal.

We also saw how the future of webcenter possible would look like.
First of all the UI of the portlets will look much flashier with more use of AJAX, dhtml,…
It will also be possible to change pages on the fly and there will be more drag and drop functionality.

Last but not least, we also discussed the positioning of the product, particularly against the oracle portal. This was a tricky one, but I kind of know now how I have to position it now. If you want to use open standards and you don’t mind to create applications (almost) from scratch (apart from the already build in applications like rte, omniportlet,…) this is a very fast and good development tool!

One of the next days we will handle the practical part of this day, to give you a glimpse on how webcenter works.

To be continued…

Export ADF Table To Excel

April 11, 2007

Recently a colleague of mine came up with a blog about exporting data shown in an af:table-component to Excel using the Apache POI API.

Some time ago I’ve accomplished the same behaviour without using any additional API or framework because I wanted to stay ‘independend’ and not use another framework on top of ADF. So I’ve done some research on OTN and finally figured out we couls accomplish the same behaviour using the Response of our HttpServlet to stream the data as Excel to our Browser.

How did I accomplish this?


I’ve created a Backing Bean for the jspx-page to be able to add my own business logic in a java class. In the jspx-document I’ve added the actionListener-attribute to my component and this attribute is bound to a method in my backing bean.

In my backing bean I’m delegating the action to my java class that holds the generic business logic. This method accepts the DCIteratorBinding as parameter to be able to browse the table-data for my Excel-file.

public void exportToExcel(ActionEvent actionEvent) throws
IOException {
ExportToExcel.exportHtmlTableToExcel((DCIteratorBinding)bindings.get(“findAllIter”)); }

The Java Class that actually performs the transformation to Excel uses the HttpServletResponse to output the data as Excel.

public static void exportHtmlTableToExcel(DCIteratorBinding tableContent) throws IOException {

//Set the filename DateTime dt = new
DateTime();
DateTimeFormatter fmt =
DateTimeFormat.forPattern(“yyyy-MM-dd_HHmmss”);
String filename = dt.toString(fmt) + “.csv”;

//Setup the output

String contentType = “application/vnd.ms-excel”;
FacesContext fc = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)fc.getExternalContext().getResponse();
response.setHeader(“Content-disposition”, “attachment; filename=” + filename);

response.setContentType(contentType);
PrintWriter out = response.getWriter();

RowSetIterator rsi = tableContent.getRowSetIterator();

String[] attNames = rsi.getRowAtRangeIndex(0).getAttributeNames();

for (int i = 0; i

out.print(attNames[i] + “;”);

}

out.println();

for (int i = 0; i

Row currentRow = rsi.getRowAtRangeIndex(i);

Object[] attValues = currentRow.getAttributeValues();

for (int j = 0; j

out.print(attValues[j] + “;”);

}

out.println();

}
out.close();

fc.responseComplete();

}

Deployment to WebCenter Pre-configured OC4J

April 10, 2007

Ever wondered how to deploy your first portletized adf application to the ‘Webcenter preconfigured OC4J’ … it’s not documented in the Developer guide and you can’t find it on technet … so what should we do do …

Read further …

When you’ve created your ADF-application and you’ve portletized it to be deployed to your ‘Webcenter preconfigured OC4J’, you need to define the connection to your container (webcenter pre-configured)

This isn’t that easy as I expected because you can’t find the ports listed in the Enterprise Manager Console of the Webcenter pre-configured container. These settings aren’t documented either in the Developer Guide or on technet, so after a lot of searching and trying out we’ve finally figured it out.

There are 2 ways to get the connection-settings used by the ‘Webcenter pre-configured OC4J’:

  • Check out the log-window when shutting down the container in Jdeveloper, the following information is shown:

C:\jdev10132\jdev\extensions\oracle.adfp.seededoc4j.10.1.3.2.0 -shutdown -port 22667 -password welcomeShutdown OC4J instance…Executing:
C:\jdev10132\jdk\jre/..\bin\java -jar “C:\jdev10132\j2ee\home\admin.jar”
ormi://127.0.0.1:22667 oc4jadmin welcome -shutdown

  • Check out the rmi.xml file which can be found in the following directory

/jdev/extensions/oracle.adfp.seededoc4j.10.1.3.2.0/

j2ee/home/config/rmi.xml


Follow

Get every new post delivered to your Inbox.