Sunday, February 28, 2010

replace /dev/random with /dev/urandom

/dev/random can really slow down WebLogic startup on Linux;
/dev/urandom is much faster

see here for a  solution

add  “” (/dev/urandom does not work) to java parameters.

Hudson and Ant

Ever tried to run unit tests from Ant inside Hudson, and gotten the infamous:

Could not create task or type of type: junit
There is a (pathetic, just like everything concerning Ant technology) workaround:
-lib /weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar 
before the list of targets you want to be run.
YAPPOS ! (yet another pathetic piece of shit)
ALSO, don't forget to set your Java Otions to:
No wonder why people are migrating to .NET.... 
simple lack of any standardization in Java, everything turns into a complete hack. (No such file or directory)

I am getting this error when runnint junit with JUnit4 and Ant

Putting junit fork="no" instead of yes seems to fix the issue.
Probably the issue is in some jar files mismatching - I have no time to investigate this crap.

Friday, February 26, 2010

Java code analysers


JDepend has a very primitive UI, they should have done some effort to make it more usable....






Dependometer : if only I could make it work....I follow the instructions and I get a IOException... poor exception handling, forget it.

DependencyFinder : it comes with an impressive suite of tools... the Swing UI is quite primitive though, I am still struggling to understand how best to use the tool.... it looks like a tool developed a looong time ago and not really abiding to modern UI standards. Most commands if you run them they don't do anything and you a left with a black screen.... run DependencyFinder.bat rather than any other tool.

JAX-WS, JAX-RPC, XMLBeans and so on...

To clarify yourself the difference between JAX-RPC and JAX-WS I suggest this article:

For a critical analysis of Web Services and standards,

Thursday, February 25, 2010

Profiling a Ant build by logging with Log4J

You would think it's an easy task to profile your build, but Ant authors simply neglected this feature.
In order to timestamp each step, do this way:

1) create a file and put it in the classpath:

# Set root category priority to INFO and its only appender to CONSOLE.
log4j.rootCategory=DEBUG, CONSOLE
#log4j.rootCategory=DEBUG, CONSOLE, LOGFILE

# Set the enterprise logger category to FATAL and its only appender to CONSOLE., CONSOLE

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n

# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n

2) add to the classpath the log4j.jar file

3) run:
set ANT_OPTS=-Dlog4j.debug -Dlog4j.configuration=file:./
ant -listener -verbose -buildfile mybuild.xml build

Terrible, eh?

Tuesday, February 23, 2010

Reading XML files into Java Object, the JAXB way


import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;

import webservices.processes.CreatePrepaidSubscriberProcess.CreatePrepaidSubscriberwithReturn;

 * Helper class to load Java Objects from an XML document
 * See test methods for usage 
 * @author pierre
 * @param <T>

public class XMLLoader <T> {
    public static void main(String[] args) throws JAXBException {

    private static void testJAXBT() throws JAXBException {
        XMLLoader<CreatePrepaidSubscriberwithReturn> loader = new XMLLoader<CreatePrepaidSubscriberwithReturn>();        CreatePrepaidSubscriberwithReturn result = loader.getObjectFromXMLFile(CreatePrepaidSubscriberwithReturn.class, "resources/CreatePrepaidSubscriber.xml");

     * Loads an object from a XML file
     * @param theClass
     * @param fileName
     * @return
     * @throws JAXBException
    public T getObjectFromXMLFile(Class theClass, String fileName) throws JAXBException {
        T result = null;
        JAXBContext jc = JAXBContext.newInstance(theClass.getPackage().getName());
        Unmarshaller unmarshaller = jc.createUnmarshaller();
        result = (T)unmarshaller.unmarshal(new File(fileName));
        return result;


Monday, February 22, 2010

Clientgen and XMLBeans

I was using clientgen to generate a Java Client for our WLI processes, and I was getting very frustrated at having all the Data Types  generated as JAXB-annotated POJOs - which is not particularly advantageous when you already have the same Data Types in the project as XMLBeans object.
I am particularly fond of XMLBeans and I don't see why I should switch to another technology.

Well, it turns out that there is a UNDOCUMENTED (at least in 9.2) flag to have clientgen use XMLBeans:


Some more documentation here:

thanks to Luciano Fiandesio for bringing this to my attention.

Anyway I have tried to make XMLBeans work inside Weblogic Workshop, no way, always NoClassDefFoundError even if I set correctly the classpath, I give up and go back to JAXB.

Sunday, February 21, 2010

junit.framework.AssertionFailedError: No tests found in BLA

most likely you forgot to set ANT_HOME to the right value... I am using JUnit4, so I want to use the latest version of Ant:

export ANT_HOME=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.apache.ant_1.7.0.v200706080842
ant -verbose

and remember to set

export CLASSPATH=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar

Ant is a piece of crap, JUnit even  more so. Why should a man struggle so much to run Unit Tests.

Saturday, February 20, 2010

WSDL and Namespaces

This excellent article clarifies a few concepts (you need a lot of clarifications when working with WSDLs and XML... :o( )

WSDL sucks - anatomy of a WSDL, WSDL for dummies

A very good presentation on the differences between WSDL 1.1 and 2.0 is here

This is a sample WSDL 2.0 file:

service has binding, binding has interface, interface has operations, operation has input and output (and fault)

<?xml  version="1.0" encoding="UTF-8"?>
<wsdl:description targetNamespace="http://new.webservice.namespace" xmlns:wsdl="" xmlns:wsoap="" xmlns:whttp="" xmlns:xs="" xmlns:tns="http://new.webservice.namespace">
        <xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified">
            <xs:element name="NewMessageRequest" type="xs:string"/>
            <xs:element name="NewMessageResponse" type="xs:string"/>
    <wsdl:interface name="NewInterface">
        <wsdl:operation name="NewOperation" pattern="">
            <wsdl:input messageLabel="In" element="tns:NewMessageRequest"/>
            <wsdl:output messageLabel="Out" element="tns:NewMessageResponse"/>
    <wsdl:binding name="NewBinding" interface="tns:NewInterface" type="" wsoap:protocol="">
        <wsdl:operation ref="tns:NewOperation" wsoap:mep=""/>
    <wsdl:service name="NewService" interface="tns:NewInterface">
        <wsdl:endpoint name="NewEndpoint" binding="tns:NewBinding"/>

This is the same service in WSDL 1.1 - notice the verbosity compared to 2.0:

service has binding, binding has porttype, porttype has operations, operation has message... what a mess!

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="" xmlns:soap="" xmlns:http="" xmlns:xs="" xmlns:soapenc="" xmlns:mime="" xmlns:xsi="" xmlns:tns="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
        <xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified"/>
    <wsdl:message name="NewMessageRequest">
        <wsdl:part name="parameter" type="xs:string"/>
    <wsdl:message name="NewMessageResponse">
        <wsdl:part name="parameter" type="xs:string"/>
    <wsdl:portType name="NewPortType">
        <wsdl:operation name="NewOperation">
            <wsdl:input message="tns:NewMessageRequest"/>
            <wsdl:output message="tns:NewMessageResponse"/>
    <wsdl:binding name="NewBinding" type="tns:NewPortType">
        <soap:binding style="document" transport=""/>
        <wsdl:operation name="NewOperation">
            <soap:operation soapAction="urn:#NewOperation"/>
                <soap:body use="literal"/>
                <soap:body use="literal"/>
    <wsdl:service name="NewService">
        <wsdl:port name="NewPort" binding="tns:NewBinding">
            <soap:address location="No Target Adress"/>

I hate WSDL, and the whole XML paraphernalia created to implement distributed computing around the XML paradigm.
I am trying to understand why I hate this entire technology.
Being a Java developer, I like the extreme coherence of Data and Interfaces definitions implemented in Java:
if you break something, you will immediately notice at design time.
With XML and WSDL, you always have the impression of handling a wobbly jellyfish, overly complex and redundant, leaving open holes for ambiguity and crappy implementations.
In fact, in my own experience AXIS2, SOAPUI and Clientgen operate differently, a WSDL which works with the first 2 doesn't work in Clientgen.... CRAP!

In a WSDL you have DEFINITIONS of public services.

NAMESPACES are used to make names less ambiguous, and should regarded as packages. Their syntax in reality is obscure and ambiguous.

SERVICES are exposed in the service URL; http://host:port/WEB_CONTEXT_ROOT/service

A SERVICE is associated to a BINDING, which defines the protocol (SOAP) and the way to pass arguments (DOCUMENT).

in the BINDING you MAY redefine OPERATIONS, but they are already defined in the PORT TYPE.
OPERATIONS are associated at times with SOAP ACTION.

A PORT TYPE is a misnomer, in WSDL 2.0 it is called INTERFACE, which is what it actually is. It defines OPERATIONS (=method) and their MESSAGES (=parameters).

In TYPES there is the type definition of method parameters.

So all in all you have a very complex and articulated document to do very simple stuff:
Why all this could not be done in a simpler way....finally leaving the developer to rely on automated tools.... EJB 2.0 reloaded.... we already know that it will all end up in a EJB 3.0 where AT LAST the good stuff is done.... so why not do it since the beginning...

Let's look in Wikipedia the changes made in WSDL 2.0:

- Removal of message constructs
EXACTLY! There should be only OPERATIONS. MESSAGES are useless indirection.

- PortTypes renamed to interfaces
PortTypes are simply a list of Operations... so... call it Interface, no?

- Ports renamed to endpoints.
In fact it simply defines a URL for the Service

Furthermore, some definitions - like endpoint - have been inlined in WSDL 2.0, making the document more compact and readable.

WSDL 2.0 is barely tolerable, WDSL 1.0 is simply outrageous, my grand mother could have done a better job.

UNFORTUNATELY OSB 3.0 doesn't seem to recognize this WSDL 2.0 format, when I try to import the WSLD it complains about:

An error occurred creating the resource:
org.apache.xmlbeans.XmlException: error: The document is not a definitions@ document element mismatch got description@

Monday, February 15, 2010

WSDL import and XSD import

an interesting article on the mysteries of WSDLs... its conclusions are:
  • It is a good practice to use XSD imports to import schema, and to use WSDL imports to import WSDL.
  • It is a good practice to import all of the namespaces that you use.
  • An attribute value of the import namespace must match the imported targetNamespace value.
  • The primary purpose of an import statement is to import namespaces. The schemaLocation and location attributes, though sometimes necessary, are really only hints.

Saturday, February 13, 2010

In WLI, find out which Web Services are invoked by a given process

This is the first step for a Discovery and Monitoring and Testing tool:


import java.lang.annotation.Annotation;
import java.lang.reflect.Field;

public class ClassLoaderTest {
    private static final String COM_BEA_CONTROL_SERVICE_CONTROL$_LOCATION = "com.bea.control.ServiceControl$Location";

    public static void main(String[] args) throws MalformedURLException, Exception {
        ClassLoader cl = Thread.currentThread().getContextClassLoader();
        String processName = "adjustment.CancelAdjustmentProcess";
        Class cls = cl.loadClass(processName);
        Field[] fields = cls.getDeclaredFields();
        for (Field field : fields) {
            Class type = field.getType();
            System.out.println("type " + type.getCanonicalName() + "  " + field.getName());
            for (Class iface : type.getInterfaces()) {
                for (Annotation annotation : type.getAnnotations()) {
                    String name = annotation.annotationType().getName();
                    if (name.equals(COM_BEA_CONTROL_SERVICE_CONTROL$_LOCATION)) {
                        String[] urls = ((com.bea.control.ServiceControl.Location)annotation).urls();
                        for (String url : urls) {
                            System.out.println("             url=" + url);

of course some jars and the src folder containing the processes must be added to the classpath

Thursday, February 11, 2010

Failed to load weblogic client internal deployment descriptor

are you getting this error while running a Java WSEE client?
the solution SEEMS to be
unzipping $WEBLOGIC_10_3/wlserver_10.3/server/lib/ and add all jars to the classpath

This zip file contains a host of jar files...

here is the original error:

Exception in thread "Main Thread" javax.xml.rpc.ServiceException: Failed to load weblogic client internal deployment descriptor. weblogic.descriptor.DescriptorException: Unmarshaller failed
    at weblogic.wsee.jaxrpc.ServiceImpl.throwServiceException(
    at weblogic.wsee.jaxrpc.ServiceImpl.loadWeblogicDD(
    at weblogic.wsee.jaxrpc.ServiceImpl.loadInternalDD(
    at weblogic.wsee.jaxrpc.ServiceImpl.(
    at com.pierre.helloworld.HelloWorldSync_Impl.(Unknown Source)
    at com.pierre.helloworld.HelloWorldSync_Impl.(Unknown Source)
    at com.pierre.tests.TestWSDLJar.main(
Caused by: weblogic.descriptor.DescriptorException: Unmarshaller failed
    at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(
    at weblogic.descriptor.BasicDescriptorManager.createDescriptor(
    at weblogic.descriptor.BasicDescriptorManager.createDescriptor(
    at weblogic.descriptor.BasicDescriptorManager.createDescriptor(
    at weblogic.wsee.jaxrpc.ServiceImpl.loadWeblogicDD(
    ... 5 more
Caused by: com.bea.xml.XmlException: failed to load java type corresponding to e=weblogic-wsee-standaloneclient@
    at com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(
    at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(
    at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(
    at com.bea.staxb.runtime.internal.UnmarshalResult.determineRootType(
    at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalDocument(
    at com.bea.staxb.runtime.internal.UnmarshallerImpl.unmarshal(
    at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(
    ... 9 more

Monitor all Message Broker channels doesn't work and gives 404?

apparenly in wliconsole the link /wliconsole/msgbroker?xxexternal=true&com=monmsgbroker  is broken...

this is one of the joys of using WLI....

Automating clientgen from Java


import java.util.List;


public class ClientGenTool {
    public final static String wls_hostname = "";
    public final static String wls_port = "7001";
    public final static String process_name = "/processes/GetPrepaidAccountBalanceProcess";
    public final static String clientclass_dir = "output/clientclass";
    public static void main(String[] args) throws WsBuildException {
        ClientGenTool clientGenTool = new ClientGenTool();
    public void clientgen() throws WsBuildException {
        String wsdl = "http://" + wls_hostname + ":" + wls_port + "/ACME_INTEG_WEB" + process_name + ".jpd?WSDL";
        System.out.println("using wsdl " + wsdl);
        File destDir = new File(clientclass_dir);
        String packageName = "examples.webservices" + process_name.replace("/", ".");

        ClientGenImpl cgi = new ClientGenImpl();

this will generate the client classes.... it makes our life a lot easier when you have hundreds of Web Services to test....

remember to add tools.jar to the classpath, otherwise the javac compiler will not work.

Wednesday, February 10, 2010

Bash script to find the location of the currently running script

# bash - find path to script
abspath="$(cd "${0%/*}" 2>/dev/null; echo "$PWD"/"${0##*/}")"

# to get the path only - not the script name - add
path_only=`dirname "$abspath"`

#display the paths to prove it works
echo $abspath
echo $path_only

(not my script, I have copied from here )

Otherwise, this is much simpler:

SCRIPT=`readlink -f $0`

CVS and Windows paths... the nightmare reloaded

if some smart guy installed CVS on Windows (using cvsnt) and mapped a repository using a full path name, such as d:\cvsroot.... well, you MIGHT be able to access to it from Windows CVS Client, but forget about accessing from Unix... I have tried everything and it simply doesn't work.
The final solution is:
tar and feather the guy who made this mapping, and create a mapping without the d:\

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:JCRMTools/mycvsusername:mypwd@" login
Logging in to :pserver:weblogic@jcrmtools:2401/mycvsusername:mypwd@
CVS password:
Unknown host JCRMTools.

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
cvs login: CVSROOT may only specify a positive, non-zero, integer port (not `d:').
cvs login: Perhaps you entered a relative pathname?
cvs [login aborted]: Bad CVSROOT: `:pserver:mycvsusername:mypwd@'.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/home/CVS: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/CVS: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
cvs login: CVSROOT may only specify a positive, non-zero, integer port (not `d').
cvs login: Perhaps you entered a relative pathname?
cvs [login aborted]: Bad CVSROOT: `:pserver:mycvsusername:mypwd@'.

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/d//cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/d/cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
//d/cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/d:/cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@" login
Logging in to :pserver:mycvsusername@
/d:cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@\cvsroot" login
Logging in to :pserver:mycvsusername@\cvsroot
/d:\cvsroot: no such repository

[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@\cvsroot" login
Logging in to :pserver:mycvsusername@\cvsroot
//d:\cvsroot: no such repository

Furthermore, if you do (Hudson does it to check if anything new has been committed since the last build)

[weblogic@CRM-INTG-DEV ACME_INTEG_EAR]$ cvs -q -z3 update -PdC -D "Wednesday, February 10, 2010 1:01:29 PM UTC"

and you get:
cvs server: cannot open directory . for empty check: Input/output error
then you might have to give Full Control to Everyone on the TEMP directory used by CVSNT on the server....

CVS, who needs enemies when I have a friend like you!

Tuesday, February 9, 2010

WLI processes terminator!

a very similar utility has already been published here


import java.util.Iterator;
import java.util.Set;

import javax.naming.Context;
import javax.naming.NamingException;

import weblogic.jndi.Environment;

import com.bea.wli.bpm.runtime.ProcessInstanceNotFoundException;
import com.bea.wli.bpm.runtime.ProcessNotFoundException;
import com.bea.wli.bpm.runtime.ProcessStatus;
import com.bea.wli.knex.runtime.core.bean.ConversationNotFoundException;

public class WLITerminator {
   String SERVICE_URI = "url/to/your/process.jpd";

    private static final ProcessStatus[] processStatusToTerminate = new ProcessStatus[] {
        ProcessStatus.ABORTED, ProcessStatus.COMPLETED, ProcessStatus.FROZEN, ProcessStatus.RUNNING};
    public static void main(String[] args) throws NamingException {
        terminateAll("weblogic", "weblogic", "t3://localhost:7001");       

    private static void terminateAll(String username, String password, String url) throws NamingException {
        Environment env = new Environment();
        Context ctx = env.getInitialContext();
        MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
        System.out.println("Got the Server-specific MBeanHome: " + home);
        Set s = home.getMBeansByType("ProcessRuntime");
        Iterator it = s.iterator();   
        try {
            if (it.hasNext()) {
                ProcessRuntimeMBean bean = (ProcessRuntimeMBean);
                ProcessInstanceQuery query = new ProcessInstanceQuery();
                for (ProcessStatus p : processStatusToTerminate) {
                    terminateInstances(bean, query);
        } catch (Exception ex) {

    private static void terminateInstances(ProcessRuntimeMBean bean,
            ProcessInstanceQuery query) throws MBeanException,
            ConversationNotFoundException, ProcessNotFoundException,
            ProcessInstanceNotFoundException {
        ProcessInstanceQueryResult info = bean.getProcessInstances(query);
        int count = info.getResultCard();
        String[] instances = info.getInstanceIds();
        System.out.println("found " + instances.length + " instances");
        for (int i = 0 ; i <  instances.length; i++) {
            String instanceId = instances[i];
            ProcessInstanceInfo pi = bean.getProcessInstanceInfo(instanceId, false);
            System.out.println(pi.getServiceURI() + " " + instanceId);
            bean.terminate(pi.getServiceURI(), instanceId);

and here are the .classpath entries necessary:

classpathentry kind="lib" path="C:/beawli/wli_10.3/lib/jpdpublic.jar"  
classpathentry kind="lib" path="C:/beawli/wlserver_10.3/server/lib/wls-api.jar"  
classpathentry kind="lib" path="C:/beawli/modules/"
classpathentry kind="lib" path="C:/beawli/modules/com.bea.core.weblogic.workmanager_1.4.0.0.jar"
classpathentry kind="lib" path="C:/beawli/wlserver_10.3/server/lib/weblogic.jar"

Monday, February 8, 2010

Configuring Hudson for continuous integration

Unfortunately, you will have to download a VERY OLD CVS client here:

(I have downloaded, installed to C:\Program Files\cvsnt and added this path to the PATH system variable)

in Hudson, if your username contains the domain name (eg mydomain\myusername), remove mydomain\ from the connection string:


If you checkout multiple modules, they should be separated by BLANK, not by comma....

Hudson will checkout into

A Workshop Ant build.xml will not work unless it can find the .metadata directory in
C:\Users\pierre\.hudson\jobs\PVDemo\workspace, so you must copy it from your real workspace.
Copy here also the workshop-lib directory and the workspace.xml file.

Remember also to add Ant to your PATH, such as C:\beawli\modules\org.apache.ant_1.6.5\bin


creade a directory /home/weblogic/hudson
copy hudson.war in it
java -jar hudson.war (or nohup java -jar hudson.war &  to run in background)

it will create a /home/weblogic/.hudson  containing all the data files
in your browser, point to http://yourhostname:8080/

new job
build a free style software project, call it ACME_INTEG_WEB
Source Code Management, select CVS and enter a CVSROOT ":pserver:cvsusername:cvspassword@cvshost:/cvsrepository"

enter the modules you want to checkout (separated by blanks)

WebLogic: invoking web services and clientgen

From your Web Service  (or JPD process), generate the WSDL (say HelloWorldSyncContract.WSDL).

In Workshop, Right Click on the WSDL, and do "clientgen": this will generate a HelloWorldSyncContract.jar file.

Put the jar file in the lib directory of your Test project.

You are now ready to code tests.... once you sort our all the NoClassDefFound that you will get... you need to add some 10 modules to your classpath:

Here is a list of modules:

<?xml version="1.0" encoding="UTF-8"?>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/Oracle WebLogic Server v10.3 JRE"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
    <classpathentry kind="src" path=".apt_src">
            <attribute name="optional" value="true"/>
    <classpathentry kind="con" path="com.bea.workshop.wls.j2eelib/wls-commonslogging-bridge-war/exact/1.0"/>
    <classpathentry kind="lib" path="lib/CompanyDBWS.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/workshop_10.3/weblogic-beehive/lib/controls/weblogic-webservice-control.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/workshop_10.3/weblogic-beehive/lib/controls/runtime/weblogic-controls.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/org.apache.beehive_1.0.2.2/apache-beehive-svn-snapshot/lib/controls/beehive-controls.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/wlserver_10.3/server/lib/wseeclient.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.descriptor_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.descriptor.j2ee_1.1.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/glassfish.jaxws.rt_2.1.3.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.weblogic.saaj_1.3.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.xml.staxb.runtime_1.3.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.weblogic.workmanager_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.utils.classloaders_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.utils.full_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.logging_1.4.0.0.jar"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/"/>
    <classpathentry kind="lib" path="C:/beaosb/modules/"/>

    <classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.i18n_1.4.0.0.jar"/>

    <classpathentry kind="output" path="build/classes"/>

I have struggled with JavaClassFinder (precious tool!) to find out all these libraries.

Anyway we have 2 ways:
the JAX-WS
and the RPC way

You can learn from WebLogic examples file:///C:/beawli/wlserver_10.3/samples/server/docs/core/index.html

Later note: in fact WebLogic already gives you all the jars you need in the famous 

See here

So.... read carefully documentation before you start chasing things around...

Sunday, February 7, 2010

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/management/WebLogicMBean

While working in WebLogic, are you haunted by weblogic logging classes (which in 10.3 are spread into a miriad of jar files, and ultimately in any case you can't avoid including weblogic.jar in the classpath, messing around everything else)?

Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/management/WebLogicMBean
    at weblogic.kernel.KernelLogManager$LoggerMaker.(
    at weblogic.kernel.KernelLogManager.getLogger(
    at weblogic.logging.commons.LogImpl.(
    at weblogic.logging.commons.LogFactoryImpl.getInstance(
    at weblogic.logging.commons.LogFactoryImpl.getInstance(
    at org.apache.commons.logging.LogFactory.getLog(
    at org.apache.axis2.description.AxisDescription.(
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.populateAxisService(
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(
    at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(
    at com.pierre.acmetester.AcmePrepaidTester.main(

the solution is:
import org.apache.commons.logging.LogFactory;

System.setProperty(LogFactory.FACTORY_PROPERTY, "org.apache.commons.logging.impl.Log4jFactory");

This will force Apache Commons Logging to use Log4J rather than WebLogic... and don't listen to people saying that Log4J is the default implementation for Apache... IT IS NOT!

I can't believe in 2010 we are still in such a pathetic shape.... Java will die, it's too messy, everything is just a HUGE mess.... even the fact that in order to log a message I need to instantiate a WebLogicMBean is grotesque. And the fact that the WebLogicMBean initialization fails without a proper error message is grotesque.... EVERYTHING IS GROTESQUE. Why people can't do a proper job. Why do we have to suffer so much.

Axis2 : WSDL2Java options

Using AXIS2_HOME:   C:\downloads\axis2-1.5.1-bin\axis2-1.5.1
Using JAVA_HOME:    C:\beawli\jrockit_160_05
Usage: WSDL2Java [options] -uri : A url or path to a WSDL

where [options] include:
  -o                 Specify a directory path for the generated code.
  -a                       Generate async style code only (Default: off).
  -s                       Generate sync style code only (Default: off). Takes precedence over -a.
  -p                 Specify a custom package name for the generated code.
  -l             Valid languages are java and c (Default: java).
  -t                       Generate a test case for the generated code.
  -ss                      Generate server side code (i.e. skeletons) (Default: off).
  -sd                      Generate service descriptor (i.e. services.xml). (Default: off). Valid with -ss.
  -d          Valid databinding(s) are adb, xmlbeans, jibx and jaxbri (Default: adb).
  -g                       Generates all the classes. Valid only with -ss.
  -pn           Choose a specific port when there are multiple ports in the wsdl.
  -sn        Choose a specific service when there are multiple services in the wsdl.
  -u                       Unpacks the databinding classes
  -r                 Specify a repository against which code is generated.
  -ns2p ns1=pkg1,ns2=pkg2  Specify a custom package name for each namespace specified in the wsdls schema.
  -ssi                     Generate an interface for the service implementation (Default: off).
  -wv             WSDL Version. Valid Options : 2, 2.0, 1.1
  -S                 Specify a directory path for generated source
  -R                 Specify a directory path for generated resources
  -em           Specify an external mapping file
  -f                       Flattens the generated files
  -uw                      Switch on un-wrapping.
  -xsdconfig    Use XMLBeans .xsdconfig file. Valid only with -d xmlbeans.
  -ap                      Generate code for all ports
  -or                      Overwrite the existing classes
  -b                       Generate Axis 1.x backward compatible code.
  -sp                      Suppress namespace prefixes (Optimzation that reduces size of soap request/response)
  -E           Extra configuration options specific to certain databindings. Examples:
                           -Ebindingfile                    (for jibx) - specify the file path for the binding file
                           -Etypesystemname (for xmlbeans) - override the randomly generated type system name
                           -Ejavaversion 1.5                      (for xmlbeans) - generates Java 1.5 code (typed lists instead of arrays)
                           -Emp (for ADB) - extension mapper package name
                           -Eosv (for ADB) - turn off strict validation.
                           -Ewdc (for xmlbeans) - Generate code with a dummy schema. if someone use this option they have to generate the xmlbeans code seperately with the scomp command comes with the xmlbeans distribution and replace the Axis2 generated classes with correct classes
  --noBuildXML             Dont generate the build.xml in the output directory
  --noWSDL                 Dont generate WSDLs in the resources directory
  --noMessageReceiver      Dont generate a MessageReceiver in the generated sources
  --http-proxy-host Proxy host address if you are behind a firewall
  --http-proxy-port Proxy port address if you are behind a firewall
  -ep   Exclude packages - these packages are deleted after code generation
  -sin     Skeleton interface name - used to specify a name for skeleton interface other than the default one
  -scn         Skeleton class name - used to specify a name for skeleton class other than the default one
                           -EbindingFileName                (for jaxbri) - specify the file path for the episode file
  -oaa   -change the absolute http addresses to local file addresses generated by wsdl2java tool
  -ebc   -generated Exceptions are inherited from this exception rather than the java.lang.Exception class
  -uon   -by default the first letter of the generated method name changeed to lowercase. This option stops that and make it same as operation name

I am running it this way:

wsdl2java.bat -sd -d xmlbeans -uri http://localhost:7001/ACME_INTEG_WEB/processes/GetPrepaidAccountBalanceProcess.jpd?WSDL

and it produces:
- a CallbackHandler
- a Stub
- a ReturnDocument and ReturnResponse Document (Interfaces) and their implementations

Module MyEar was not found on the server. Unable to perform undeploy.

I get this error message when trying to publish an Ear from Workshop to an externally running WebLogic server.
It makes strictly no sense whatsoever, and the only workaround is to delete the server definition in Workshop and create it again. :o(((

Friday, February 5, 2010

Use WebLogic System Libraries

If in your code you need to refer to WebLogic libraries, don't add to the Java Build Path a direct reference to weblogic.jar and the other modules, but rather add "Weblogic System libraries".

If you get a message

'Weblogic System libraries can only be used with projects that target a weblogic server runtime'

you should add a Targeted Runtime to your project.

A Java Project doesn't support this, so you should rather create a Utility Project.
A Utility Project allows you also to add jpd-jar System Library, if you need to develop utilities on WLI.

Unfortunately Workshop doesn't let you morph a Project of a Type A into a Project of Type B.... bummer!
You might try morphing by hand editing the .project and .classpath files =:o( .

Thursday, February 4, 2010

How to deploy a EAR to WebLogic with WLST

excellent tutorial! As usual with James Bayer!

In a nutshell:

cd C:\beawli\user_projects\domains\JCRMIntegration_Domain\bin
java weblogic.WLST
connect( 'weblogic', 'weblogic', 't3://localhost:7001')
deploy('ACME_INTEG_EAR', 'C:/TEMP/WORKSHOP_ACME_INTEG_EAR.ear', targets='AdminServer')

The complete script is:

connect( 'weblogic', 'weblogic1', 't3://localhost:7001')
   print 'unable to stop'

   print 'unable to undeploy'

deploy('MQParserEAR', '/path/to/MQParserEAR/1.1.0-SNAPSHOT/MQParserEAR-1.1.0-SNAPSHOT.ear', targets='AdminServer')

Trouble starting WLI? Truncate everything!

here is what you should do to clean completely the environment:

1-      Execute the following script

truncate table WEBLOGICWLSTORE;
truncate table WLI_PROCESS_DEF;
truncate table WLI_PROCESS_DEF_ARCH;
truncate table WLI_PROCESS_EVENT;
truncate table WLI_PROCESS_EVENT_ARCH;
truncate table WLI_PROCESS_TRACKING;

2-      Delete all files on the $DomainPath$/WseeFileStore

Wednesday, February 3, 2010

Exporting WebLogic Workshop as Ant Script

this will create:

you should specify these properties:

the wizard suggests you to declare:

How to export Ant in Workshop :

this talks more on the subject

You can export ALL the build.xml in one go (select all the projects you need in the wizard).

To run the build:


cd C:\beawli\user_projects\workspaces\default\JAWWAL_INTEG_WEB


#this takes care of the java.lang.NoClassDefFoundError: weblogic/logging/NonCatalogLogger
set CLASSPATH=C:\beawli\wlserver_10.3\server\lib\wls-api.jar;%CLASSPATH%

set WL_HOME=c:\beawli\wlserver_10.3\
set WORKSHOP_HOME=C:\beawli\workshop_10.3
set WORKSHOP_WORKSPACE=C:\beawli\user_projects\workspaces\default\
set WORKSHOP_LIB_DIR=C:\beawli\user_projects\workspaces\default\workshop-lib

copy C:\beawli\wlserver_10.3\server\lib\wls-api.jar C:\beawli\user_projects\workspaces\defaultworkshop-lib

ant -verbose build archive

or if you want more info:

ant -verbose -diagnostics build archive > antlog.log

With log4j enabled:
set ANT_OPTS=-Dlog4j.debug -Dlog4j.configuration=file:./log4j.propertiesset CLASSPATH=C:\beawli\modules\org.apache.beehive_1.0.2.2\apache-beehive-svn-snapshot\lib\common\log4j-1.2.8.jar;%CLASSPATH%
ant -listener -verbose -buildfile build.xml build

To run an automate build from Hudson/CVS, remember to copy:
a build.xml per each project
a workspace.xml medatata file
the .metadata workspace directory
workshop-lib directory

XMLBeans Builder in Workshop

When the XMLBean Builder is active in a project, at every build the .xbean_src is regenerated (.java files) and consequently the build\classes is regenerated.

If you disable the Builder, you keep the old .java file, but it will still be recompiled - which is a waste of time.

For info on XMLBeans Builder, see

For more info on the XMLBeans tools, see

Tuesday, February 2, 2010

WLI processes: some useful configuration

in build/processoutput/WEB-INF you will find:


with things like:

<proc:ProcessManifest xmlns:proc="">
    <proc:project name="ACME_INTEG_WEB">
            <proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/installmentWithDiscountInfo/" SVUID="0" stateless="true"/>
            <proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/" SVUID="0" stateless="true"/>
            <proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/" SVUID="0" stateless="true"/>
            <proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/" SVUID="0" stateless="true"/>

and wli-subscriptions.xml

    <man:project projectUri="ACME_INTEG_WEB">
        <man:subscriptions jpdUri="/ACME_INTEG_WEB/processes/installmentWithDiscountInfo/ViewInstallmentWithDiscount.jpd"/>
        <man:subscriptions jpdUri="/ACME_INTEG_WEB/processes/ViewMonthlyChargesProcess.jpd"/>
        <man:subscriptions jpdUri="/ACME_INTEG_WEB/processes/UpdatePrepaidSubscriberProcess.jpd"/>
        <man:subscriptions jpdUri="/ACME_INTEG_WEB/processes/UpdatePostpaidSubscriberProcess.jpd"/>
        <man:subscriptions jpdUri="/ACME_INTEG_WEB/processes/UpdatePostpaidCustomerProcess.jpd"/>
        <man:subscriptions jpdUri="/ACME_INTEG_WEB/processes/UpdateInstallmentDiscount.jpd"/>

and wlw-manifest.xml

    <con:project name="ACME_INTEG_WEB">
        <con:top-level-component component-type="JPD" class-name="processes.installmentWithDiscountInfo.ViewInstallmentWithDiscount">
        <con:top-level-component component-type="JPD" class-name="processes.ViewMonthlyChargesProcess">