Thursday

Correct dependency configuration for maven-weblogic-plugin to deploy in Weblogic server 10.3.0.0

Mojo weblogic plugin version 2.9.0 is not stable for Weblogic server 10.3.0.0. Configuration which suggest on the mojo documentation is not working for current Weblogic server version and produce some hopeless error. Seems installed weblogic.jar and webservices.jar on local repository is not using properly on plug ins life cycle. However it's easy to fix the error through system scope dependency which i will demonstrate below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>ru.fors.test.gwt.core</groupId>
<artifactId>core-web</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>core-web</name>
<url>http://www.fors.ru</url>
<parent>
<groupId>ru.fors.test.gwt.core</groupId>
<artifactId>app</artifactId>
<version>1.0</version>
</parent>
<properties>
<weblogic.version>1.0</weblogic.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwtVersion}</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/gwt-servlet.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwtVersion}</version>
<scope>system</scope>
<systemPath>${GWT_HOME}/gwt-user.jar</systemPath>
</dependency>    
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev-windows</artifactId>
<version>${gwtVersion}</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/webapp/WEB-INF/lib/gwt-dev-windows.jar</systemPath>
</dependency>  
</dependencies>
<build>
<finalName>core-web</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- maven googletoolkit plugin-->
<plugin>
<groupId>com.totsp.gwt</groupId>
<artifactId>maven-googlewebtoolkit2-plugin</artifactId>
<version>2.0-beta6</version>
<configuration>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
<runTarget>HelloGWT.html</runTarget>
<compileTargets>
<param>ru.fors.test.gwt.core.HelloGWT</param>
</compileTargets>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
<executions>
<execution>
<goals>
<goal>mergewebxml</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<webXml>target/web.xml</webXml>
</configuration>
</plugin>
<!-- maven weblogic plugin configuration -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>2.9.0</version>
<configuration>
<adminServerHostName>localhost</adminServerHostName>
<adminServerPort>7001</adminServerPort>
<adminServerProtocol>t3</adminServerProtocol>
<userId>weblogic</userId>
<password>weblogic</password>
<upload>false</upload>
<remote>false</remote>
<verbose>false</verbose>
<debug>false</debug>
<targetNames>AdminServer</targetNames>
<exploded>false</exploded>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.5</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>${weblogic.version}</version>
<scope>system</scope>
<systemPath>PATH_TO_LIBRARY/weblogic.jar</systemPath>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>webservices</artifactId>
<version>${weblogic.version}</version>
<scope>system</scope>
<systemPath>PATH_TO_LIBRARY/webservices.jar</systemPath>
</dependency>
</dependencies>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.html</include>
<include>**/*.xml</include>
<include>**/*.css</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</project>

Tuesday

Oracle develop roadshow in Moscow, 4-5 th february

Last week Oracle corporation demonstrated their roadshow in Moscow. The roadshow started with the sparkling presentation of Larry Cable. Within an hour he could manage to demonstrate the Oracle Big Fussion middleware, focused on Oracle WebLogic Server and related (Java based) standards technologies. It was very interesting to listen JAVA/RICH ENTERPRISE APPLICATIONS TRACK and enjoy the ability of Oracle JDeveloper. I always against Oracle strategy to make JDeveloper as a main IDE to develop all the java related technology on Oracle platform, because it's seems all the eggs in one basket. But while Larry go through all the the ADF rich client with some mouse click, i started believe that may be JDeveloper already got maturity to use seriously.
There were three main Track:
DataBase Track and hands on lab;
Java/Rich enterprise Application track and hands on lab;
Service oriented architecture track and hands on lab.

I was very interested on SOA track, specially on BEA products. This track covers all things service-oriented architecture (SOA), from basics to best practices. Also covers architecture role on small and large enterprise application. This track also focused on emerging trends such as business process management (BPM) and event-driven architecture. I love the technical deep drive on BPM suite and BPA suite and the Oracle Business Rules engine. The overview of SCA was very interesting, now Oracle has their own implementation of SCA on their basket.
One of my friend convince me to attend on Database track named "Doing SQL from PL/SQL: Best and Worse Practices", it was wonder full to learn about the new features of PL/SQL and the worst practices.
In the conclusion i can only say that, i was satisfied and be sorry for those who missed the roadshow.

Wrapping business rules rmi clients with JAX-WS

Most often after deploying new business rules in BRES, we have to redeploy IlrSession beans with our custom beans(XOM). Also developing new client for the business rules is time consuming work. Bres(Business rules execution server) provide rmi protocol and some web service support(Decision service) to invoke rules in bres. Deployed rules will be exposed only when you add your domain class(XOM) in the jrules-bres-ootbds.ear and redeploy it again in application server. All the life cycle is too time consuming to manage the whole project. However, often business analyst (Most of time, project mangers require such thing to fulfill customers demand) requires expose business rules through web service for solving business requirement with customer. In today's post i will show a agile way to expose business rules through web service and run it into jdk 6 embedded http server.
We have one web service with a few methods, every method expose one business rules as a web method. For developing i have use jdk 6 and OAS 10.1.3.3 (where installed and deployed ours business rules).
Web service Class:BusinessRulesServices
package ru.fors.test.rules.project;

import ru.fors.pak.jrules.bom.Result;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;
import javax.naming.Context;
import javax.wsdl.extensions.soap.SOAPBinding;
import java.util.Properties;

import ilog.rules.bres.session.*;
import ilog.rules.xml.model.IlrXsdXomProcessor;
import ilog.rules.data.IlrSourceStructure;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* Package: ru.fors.test.rules.project
* Author: sahmed
* Date: 03.02.2009
*/
@WebService(name = "BusinessRulesServices",
serviceName="BusinessRulesServices",
targetNamespace = "http://com.blu.rules/services")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT,
use = SOAPBinding.Use.LITERAL,
parameterStyle = SOAPBinding.ParameterStyle.BARE)
public class BusinessRulesServices {
private static Log log = LogFactory.getLog(BusinessRulesServices.class);

private static final String UFTP_RULESPATH = "/UFTPNRuleAppS/1.0/rmReportUPFT/1.0";
private static IlrStatelessRuleSession session;

static{
IlrSourceStructure.Properties jndi = new Properties();
jndi.put(IlrXsdXomProcessor.Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory");
jndi.put(Context.PROVIDER_URL,"ormi://Host:12402/NAME_OF_IRLRULESSESION");
jndi.put(Context.SECURITY_PRINCIPAL,"bres");
jndi.put(IlrXsdXomProcessor.Context.SECURITY_CREDENTIALS,"bres");
try {
IlrRuleSessionProvider rsProvider = new IlrRuleSessionProviderFactory.Builder(jndi).build();
session = rsProvider.createStatelessRuleSession();
if(log.isInfoEnabled()){
log.info("[Session Initilized.]");
}
} catch (IlrRuleSessionCreationException e) {
log.error("["+e.getMessage()+"]");
} 
}
@WebMethod(operationName = "uftpRules")
public Result callUftpRules(Long paramOperation){
IlrSessionRequest request = new IlrSessionRequest(UFTP_RULESPATH);
IlrSessionExecutionSettings sessionExecutionSettings = request.getExecutionSettings();
IlrSessionParameters inputParameters = sessionExecutionSettings.getInputParameters();
inputParameters.setParameter("paramOperation", paramOperation);
// enable trace
request.getSessionDescriptor().enableTrace();
Result  result = null;
try {
IlrSessionResponse response = session.executeRules(request);
IlrSessionExecutionResult executionResult = response.getExecutionResult();
//System.out.println("FiredRule:"+ executionResult.getNumRulesFired());
result = (Result)executionResult.getOutputParameters().getObjectValue("paramOutput");
} catch (RemoteException e) {
log.error("["+e.getMessage()+"]");
} catch (IlrRuleSessionException e) {
log.error("["+e.getMessage()+"]");
}
if(log.isInfoEnabled()){
log.info("[Request completed.]");
}
return result;
}
// more web methods goes here.
}

Now we will create the agent to start embedded http server and run the web service.
Agent:
package ru.fors.test.rules.project;

import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.ws.Endpoint;

/**
* Package: ru.fors.test.rules.project
* Author: sahmed
* Date: 03.02.2009
*/
public class TestWs {
public static void main(String[] args) {
Endpoint.publish("http://localhost:8080/invokeRules",new BusinessRulesServices());
System.out.println("Server start...");
}
}

Now you can run the class TestWs and the wsdl of the web service will be available on the following url: http://localhost:8080/invokeRules?wsdl
Actually it's a simple well known wrapping pattern to expose legacy code as web service.
To run successes fully the agent, you need following libraries in your classpath:
bcel.jar
jrules-engine.jar
oc4jclient.jar
ilrsession.jar
jrules-bres-execution.jar
log4j.jar
commons-logging.jar
commons-discovery.jar

Sunday

Agile development of apache tucsany SCA with Ilog jrules decision services

Apache tucsany provides a framework for developing SOA solution that is based on Service Component Architecture (SCA) standard. Tucsany offers following advantages:
1) Provides a model for creating composite applications by defining the services in the fabric and their relationships with one another.
2) Enables service developers to create reusable services that only contain business logic.
3) Existing applications can work with new SCA compositions. This allows for incremental growth towards a more flexible architecture, outsourcing or providing services to others.

Tucsany implemented in java and c++ programming language. For more information visit apache tucsany site.
In the growing uses of business rules in SOA, on the current post i decide to make a laboratory work to show how to use business rules in SCA SOA solution.
For more information to get benifit from business rules please consider my some previous post about Ilog business rules.
On the current tutorial we are going to use following tools and libraries:
1) Maven 2.0.9
2) JAX-WS 2.1.5
3) Tucsany SCA 1.4
4) Ilog Jrules 6.0.7
All the information to download and install of all tools and frameworks should be found on their home site.
For developing the tutorial i preferred to use Intelli Idea 7. But you can use your own IDE because we uses maven to manage the project and you can easily create any particullar project by maven tools.
Create composite service application:
The following shows the composition diagram for the composite service application we are about to create.

The composite stock agent component consist of two services and one decision service. There is Customer agent service, from where you might get all the necessary information of customer by customer id. From the otder service we will get product information and sned all the information to decision service for some validation. If outgoing status approved, then stock agent generate products bill. Actually example used here to only show the jax-ws binding to ilog decision service.
Now we start developing from the scratch by using maven tools. First we will start ilog jrules server and deploy the example decision service provide with the jrules installation. If you deploy it's properly, you should get the wsdl in the folowing location
http://localhost:8080/DecisionService/ws/PreTradeChecksRuleApp/1.0/PreTradeChecks/1.0?WSDL
For more information develop and deploy decesion service on Jrules, please refer to the following post.
Now it's time to create the pom.xml file as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.blu.sca.simple</groupId>
<artifactId>sca-simple</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sca-simple</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>apache.incubator</id>
<url>http://people.apache.org/repo/m2-incubating-repository</url>
</repository>
</repositories>    
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-node-impl</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-domain-manager</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-sca</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-binding-sca-axis2</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-host-embedded</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.1.5</version>
</dependency>

</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<executions>
<execution>
<!--<phase>process-resources</phase>-->
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>com.blu.sca.dservice</packageName>
<keep>true</keep>
<sourceDestDir>${basedir}/src/main/java</sourceDestDir>
<wsdlDirectory>${basedir}/src/main/resources</wsdlDirectory>
<wsdlFiles>
<wsdlFile>pretrade.wsdl</wsdlFile>
</wsdlFiles>            
</configuration>
<dependencies>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.5</version>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.blu.sca.simple.agent.decision</mainClass>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>

First of all we build the project name sca-simple by maven tools and append all the necessary dependency on it. Download the wsdl file to the src\main\resources folder to generate proxy releated class from the decesion service. In the current project i use latest version of JAX-WS which you probably need to download and install manually on the local maven repositories.
Here is the command to install libraries manually on the maven local repositories.
mvn install:install-file -Dfile=D:\Distributors\java\webservice\jax-ws\jaxws-ri\lib\jaxws-rt.jar -DgroupId=com.sun.xml.ws -DartifactId=jaxws-rt -Dversion=2.1.5 -Dpackaging=jar -DgeneratePom=true

Project is now ready to coding. If we will run the following command in console,
$mvn clean compile
the maven will first generate all the stub class from the wsdl and compile the project. This may take a few minutes because maven will download a lot of tuscany modules and files to your local repositories.
For simplicity we will only take a look to the main parts of the project. Anyway the source code the project will be downlodable.
First we will create interface for the decision service as follows:
package com.blu.sca.simple.services;

import org.osoa.sca.annotations.Remotable;
@Remotable
public interface IRulesService {
String lookup(Customer customer, Product product);
}

and also the implemention:
package com.blu.sca.simple.impl;

import com.blu.sca.simple.services.IRulesService;
import com.blu.sca.rules.*;
import com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl;
import org.osoa.sca.annotations.Reference;
import org.osoa.sca.annotations.AllowsPassByReference;
import org.osoa.sca.annotations.Service;
import org.osoa.sca.ServiceRuntimeException;

import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import java.io.StringWriter;

@Service(IRulesService.class)
@AllowsPassByReference
public class RulesService implements IRulesService {
@Reference
protected DecisionServicePreTradeChecks dsrService;

public String lookup(Customer customer, Product product) {
// create request  
DecisionServiceRequest request = new DecisionServiceRequest();
CustomerParameter customarP = new CustomerParameter();

customarP.setCustomer(customer);
OrderParameter orderP = new OrderParameter();

orderP.setOrder(product);

request.setCustomerParameter(customarP);
request.setOrderParameter(orderP);

DecisionServiceResponse response = null;
String str="";
ReportParameter report=null;
try{
response = dsrService.executeDecisionService(request);
report = response.getReportParameter();
str = report.getOrder().getStatus();
}catch(DecisionServiceSoapFault fault){
str = fault.getMessage());
}
return str;
}
}

Finally we will create composite xml file to compose all the component.
<?xml version="1.0" encoding="UTF-8"?>
<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
targetNamespace="http://scadecision"
xmlns:sample="http://scadecision"
name="Decisionservice">

<component name="BookingAgentServiceComponent">
<implementation.java class="com.blu.sca.simple.impl.BookingAgentServiceComponent"/>
<reference name="customerService" target="CustomerServiceComponent" />
<reference name="orderService" target="OrderServiceComponent" />
<reference name="rulesService" target="RulesServiceComponent" />
</component>

<component name="RulesServiceComponent">
<implementation.java class="com.blu.sca.simple.impl.RulesService"/>
<reference name="dsrService">
<binding.ws uri="http://localhost:8080/DecisionService/ws/PreTradeChecksRuleApp/1.0/PreTradeChecks/1.0?WSDL" />
</reference>
</component>

<component name="CustomerServiceComponent">
<implementation.java class="com.blu.sca.simple.impl.CustomerService"/>
</component>

<component name="OrderServiceComponent">
<implementation.java class="com.blu.sca.simple.impl.OrderService"/>
</component>

</composite>

At these moment all the component is ready to compose. You can build and run the program by maven as follows:
$mvn clean compile
$mvn exec:java