Pages

Tuesday, June 21, 2011

Publish to EDN from java & OSB with JMS

My previous blogpost was about how to configure the SOA Suite EDN for JMS ( EDN-JMS ) instead of AQ (EDN-DB) and in this blogpost I will show you how you can publish events from Java and OSB.

Before we start you should know that we can only make Remote Event Connections because you are running the Java or OSB process in a different JVM then the SOA Suite. And only asynchronous subscriptions will be supported for remote event connections.

First let's create a Java Client which publish the events directly to the SOA Suite Server. I will use the jars of the SOA Suite. This is not necessary. You can just publish a JMS text message and set some JMS Header properties (MessageType and SideCar )

Make a new JDeveloper  project which contains the following libraries.

Here is my test class.
And this will produce the following event on the EDN Queue.

The second part of this blogpost is how to do this in OSB.
Before we can work on the Proxy or Business Service we need to create a Foreign JNDI Provider on the WebLogic Service. ( You can also use a JNDI Provider of the OSB Configuration project )

Provide the SOA Server details.

Provide the local and remote EDN-JMS JNDI Link names. The Remote JNDI Names are fixed but you can change your  local ones.

Restart the OSB Server and open OEPE or the SBConsole.

Create a new Business Service and choose for Messaging Service as Service Type.

Event is an One Way Operation so only need to set the Request Message Type to text.

Use the Local JNDI names of the Foreign JNDI Provider in the Endpoint URI

 Select Text as Message Type.

Create a Proxy Service which call this Business Service, where we will replace the Body contents with the event data and set some JMS Headers in the Transport Header.
 Replace the body contents in a Replace Action.

My test event, the values of Id and ecid element contains unique UUID values.

And the last part is to set the Messagetype and SideCar JMS Headers
MessageType is always Remote
SideCar in my case

<business-event-sidecar xmlns:ns="http://schemas.oracle.com/events/edl/EmployeeEventEDL"
                        xmlns="http://oracle.com/fabric/sideCar">
<name xmlns="http://oracle.com/fabric/businessEvent">ns:EmployeeEvent-sidecar</name>
</business-event-sidecar>

You can test the Proxy Service in the SBConsole.

Configure and test JMS based EDN in SOA Suite 11g

Beside the default AQ implementation it is also possible to use a JMS Queue for EDN. When you use the JMS implementation in SOA Suite 11g instead of AQ, it can be easier to publish an event from a Java Web application, WebLogic SAF, MDB or from OSB. In this blogpost I will show you how to configure EDN-JMS and how to publish an Event to this JMS Queue.

When you take a look at the SOAJMSModule located at the JMSModules of WebLogic you can see that the module already contains an EDN Queue and an EDN ConnectionFactory.

So you only need to configure SOA Suite so it uses this Queue and Connection Factory. To do so open the enterprise manager application | SOA | soa-infra and open the Common Properties Menu item of the SOA-Infrastructure menu. Click on More SOA-Infra Advanced Configuration Properties


This will open the System MBean Browser. In this we can change the EdnJmsMode and set this to true.

Restart the SOA Server and take a look at the monitoring of the EDN Queue. Here you must see there are some Queue Consumers
Second part of this blog is to publish a event. For this I made a simple Employee Id XSD which can be published.

Create a SOA Project and add a Mediator with a One Way Operation which uses this XSD. Also expose this Mediator so you can invoke this operation from the Enterprise Manager.

Add a routing rule and choose for an Event.
 Define an Employee Event.

Add a transformation and map the source and destination elements

Your composite will look like this.  Deploy the composite to the SOA Server.

To see the event you need to pause the consumption of the EDNQueue.

Open the Enterprise Manager and test the service of the EDN composite.

Go back to the EDNQueue and look at the JMS Message. It contains some SOA instance tracing elements and has a MessageType JMS Header which defines the EDN mode.


In the following documentation you can read about, how to create a Foreign JNDI provider on your ADF server so you can publish JMS EDN events from an ADF Client.

38.3.6 How to Configure JMS-based EDN Implementations

In one of the future blogposts I will publish an JMS event from a Java Client.

Monday, June 13, 2011

Building with Maven in JDeveloper 11gR2

With JDeveloper 11gR2 you can use Maven 2 as your build engine, before 11gR2 you could download a plugin which did not work great because all the required Oracle libraries which were not available in a public repository. So you had no choice to add them manually to a Maven Repository before you can use Maven. With 11gR2 Oracle fixed that by adding your projects libraries to the local Maven Repository when you add a Pom.xml to your projects.

Using Maven in JDeveloper is not that simple and I hope that this blogpost can help you to use maven as your buidtool.

First check if you have in your user profile a folder called .m2 . This folder must contain a settings.xml file ( you can copy it from jdeveloper\apache-maven-2.2.1\conf ) And also add a sub folder called repository.


Select for example your model project and add a Maven POM for Project to this project


You will get a POM overview which matches with your project.


This will add the libraries of the model project to your local Maven repository.


Now you can do the same for the ViewController project.


The only thing missing is the application workspace POM.xml which build all workspace projects. Add the Application POM to your workspace.


Don't enable Generate POM for Projects in this Application because we already did that.


This Application POM is located in the Application Resources window and only contains the Model and ViewController references,

In the project options or when you select the POM.xml you can change the Maven settings


Add some extra Maven goals to your project.


or add some extra Maven Repositories, like your company one.


Too bad indexing the Maven repositories ends in a error. Even when I use my own repository. You can ignore this error.

This is fixed in the 11gR2 patch and now it is working fine.

Now its time to build your project by running the Maven Package Goal.

The Model project was no problem.

The ViewControler project was different.

First I got a Apacle Trinidad error ( the ADF Faces Runtime needs a Trinidad pom )
Cannot find parent: org.apache.myfaces.trinidad:trinidad for project: null:trinidad-api:jar:null for project null:trinidad-api:jar:null

You can try to add and remove the right dependency  ( oracle.jdeveloper.library:ADF-Faces-Runtime-11:pom:11.1.2.0.0 ), maybe this will fix it.

This is fixed in the 11gR2 patch and now it is working fine.

In the Maven setting you can Add or Remove the library dependency.


You will get a message that the local repository will be updated.


In case of the Apache Trinidad error. I need to update the trinidad pom in my local repository and remove the  missing parent and move the groupId and version element,

This is fixed in the 11gR2 patch and now it is working fine.
<!--
  <parent>
    <groupId>org.apache.myfaces.trinidad</groupId>
    <artifactId>trinidad</artifactId>
    <version>2.0.0.1-SNAPSHOT</version>
  </parent>
-->
  <groupId>org.apache.myfaces.trinidad</groupId>
  <version>2.0.0.1-SNAPSHOT</version>
  <artifactId>trinidad-impl</artifactId>
  <packaging>jar</packaging>

and so it goes on and on. Also need to do this for the 2 RichClient Faces POMs located in .m2\repository\oracle\adf\view\faces
Somehow the parent POM of the Oracle and Apache POMs are not added to  the local repository.

And it would be great if Oracle made a option to force the synchronization of all the Jdeveloper libraries ( disc  space is not a problem anymore and make it complete )  and even a option to export these POMs to your own Maven Repository.

The ViewController project has a dependecy with the model project so you need to make sure that the ViewController project can find the Model jar. To do so I will add my own Maven Repository to all the projects.


Change the Settings.xml of Apache Maven or of your local Maven repository and the add the username password which can upload the model artifact.

In the Model POM add a Distribution so Maven can upload the model artifact.

The ViewController can now find the Model dependency and you can create the WAR. This is a big one (130) because it adds all the reference jar to the web-inf/lib. You need to control this by deselecting the export option in the Maven project dependency.

To solve the Apache Trinidad dependency you need to add the Apache repository on the ViewController maven repositories. Add https://repository.apache.org/content/repositories/snapshots/ as url
Open the ADF-Faces-Runtime-11-11.1.2.0.0.pom located in .m2\repository\oracle\jdeveloper\library\ADF-Faces-Runtime-11\11.1.2.0.0\ and change the Trinidad dependency from 2.0.0.1-SNAPSHOT to 2.0.0.3-SNAPSHOT
The 2.0.0.1-SNAPSHOT does not exists in the Apache repository anymore.

This is fixed in the 11gR2 patch and now it is working fine.


Do the same for Trinidad-Runtime-11-11.1.2.0.0.pom  located at .m2\repository\oracle\jdeveloper\library\Trinidad-Runtime-11\11.1.2.0.0

This is fixed in the 11gR2 patch and now it is working fine.



Also got a Maven Package Goal error when I run this Package Goal twice. It is solved when I do a clean first.
Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor

message             : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
cause-exception     : com.thoughtworks.xstream.converters.reflection.ObjectAccessException
cause-message       : Cannot construct org.apache.maven.plugin.war.util.WebappStructure as it does not have a no-args constructor
class               : org.apache.maven.plugin.war.util.WebappStructure
required-type       : org.apache.maven.plugin.war.util.WebappStructure
path                : /webapp-structure
line number         : 1

Wednesday, June 8, 2011

Using the EJB or Java Datacontrol in ADF Rich Faces

In my previous blogspot I showed you the new JDeveloper 11gR2 EJB and ADF DataControl features and in this blogpost I will use this EJB or Java DataControl in a JSF page.

I made a simple EJB model project which uses the dept and emp tables of the Scott schema. This project also contains with a Session Bean on which I generated an ADF DataControl.

When you open the DataControls.dcx in your model project and select one of your DataControl entries you can click on the edit button. This will open and generate an ADF entity xml in which you can change some properties.
We will add a new Named Criteria in which you can search on a particular location of the department. This criteria can be used in a Query Panel.


The criteria dialog, where I add the location attribute of the dept entity and compare it with a bind variable.


When we switch to the ViewController project, you will see this criteria in the DataControl Window.

Drag All Queriable Attributes on the JSF Page and choose for ADF Query Panel with Table.

You can run this page and in the top right Combobox you can select your criteria,  next the bind variable will be shown on the query panel.
The saving of your own custom queries in the MDS store is not working (yet) with this DataControl. You will get a viewobject error. And I can't define a list of values on an attribute, so no nice combobox in the query panel.

The second part of this blogpost will show you, how you can change a department of a employee.  Here you can see that the employee entity has the department entity as attribute( no dept_id attribute).
Drag the empFindAll operation on the page and choose for ADF Form

You can see that there is no combobox option for the department entity but you can include its attributes.

On runtime it will look like this.
I removed the entity attributes of  Dept and drag the dept attribute from the DataControl on the Form and choose for ADF Select One Choice.


The Base Data Source is the dept entity inside the Employee entity and add a new other department operation as List Data Source


Add the data mapping and display some department attributes.


This time a combobox is displayed and you can change the department on the employee
That's all for now.