/dev/random can really slow down WebLogic startup on Linux;
/dev/urandom is much faster
see here for a solution
http://www.itonguard.com/20090313/weblogic-starts-slow/
add “-Djava.security.egd=file:/dev/./urandom” (/dev/urandom does not work) to java parameters.
Sunday, February 28, 2010
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:
add
-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:
-DLOCALCLASSPATH=/weblogic/bea10.3/tools/eclipse_pkgs/2.0/eclipse_3.3.2/eclipse/plugins/org.junit4_4.3.1/junit.jar
No wonder why people are migrating to .NET....
simple lack of any standardization in Java, everything turns into a complete hack.
java.io.FileNotFoundException: junitvmwatcherNNN.properties (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.
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
http://java-source.net/open-source/code-analyzers
FindBugs
PMD
JDepend has a very primitive UI, they should have done some effort to make it more usable....
JSCS
ClassicStyle
XRadar
Macker
Condenser
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.
FindBugs
PMD
JDepend has a very primitive UI, they should have done some effort to make it more usable....
JSCS
ClassicStyle
XRadar
Macker
Condenser
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:
http://finallyigotit.blogspot.com/2009/05/jax-rpc-vs-jax-ws.html
For a critical analysis of Web Services and standards,
http://www.predic8.com/axis2-cxf-jax-ws-comparison.htm
http://finallyigotit.blogspot.com/2009/05/jax-rpc-vs-jax-ws.html
For a critical analysis of Web Services and standards,
http://www.predic8.com/axis2-cxf-jax-ws-comparison.htm
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 log4j.properties 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.
log4j.logger.org.apache.tools.ant=DEBUG, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=DEBUG
log4j.appender.LOGFILE.layout=org.apache.log4j.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:./log4j.properties
ant -listener org.apache.tools.ant.listener.Log4jListener -verbose -buildfile mybuild.xml build
Terrible, eh?
In order to timestamp each step, do this way:
1) create a log4j.properties 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.
log4j.logger.org.apache.tools.ant=DEBUG, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=- %m%n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=axis.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.Threshold=DEBUG
log4j.appender.LOGFILE.layout=org.apache.log4j.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:./log4j.properties
ant -listener org.apache.tools.ant.listener.Log4jListener -verbose -buildfile mybuild.xml build
Terrible, eh?
Labels:
ant
Tuesday, February 23, 2010
Reading XML files into Java Object, the JAXB way
package com.acme.integration.tools;
import java.io.File;
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 {
testJAXBT();
}
private static void testJAXBT() throws JAXBException {
XMLLoader<CreatePrepaidSubscriberwithReturn> loader = new XMLLoader<CreatePrepaidSubscriberwithReturn>(); CreatePrepaidSubscriberwithReturn result = loader.getObjectFromXMLFile(CreatePrepaidSubscriberwithReturn.class, "resources/CreatePrepaidSubscriber.xml");
System.out.println(result.getSiebelMessage().getListOfAcmeCreatePrepaidAccountIo().getAcmeAccountLite().get(0).getListOfAcmeSubscriberLite().getAcmeSubscriberLite().get(0).getName());
}
/**
* 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;
}
}
import java.io.File;
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 {
testJAXBT();
}
private static void testJAXBT() throws JAXBException {
XMLLoader<CreatePrepaidSubscriberwithReturn> loader = new XMLLoader<CreatePrepaidSubscriberwithReturn>(); CreatePrepaidSubscriberwithReturn result = loader.getObjectFromXMLFile(CreatePrepaidSubscriberwithReturn.class, "resources/CreatePrepaidSubscriber.xml");
System.out.println(result.getSiebelMessage().getListOfAcmeCreatePrepaidAccountIo().getAcmeAccountLite().get(0).getListOfAcmeSubscriberLite().getAcmeSubscriberLite().get(0).getName());
}
/**
* 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:
http://forums.oracle.com/forums/thread.jspa?messageID=3008420
<clientgen
wsdl="SimpleClientImplService.wsdl"
destDir="${clientclasses.dir}"
JaxRPCWrappedArrayStyle="false"
typeFamily="XMLBEANS_APACHE"
packageName="some.pagage">
</clientgen>
Some more documentation here:
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webserv_ref/anttasks.html#wp1039270
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.
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:
http://forums.oracle.com/forums/thread.jspa?messageID=3008420
<clientgen
wsdl="SimpleClientImplService.wsdl"
destDir="${clientclasses.dir}"
JaxRPCWrappedArrayStyle="false"
typeFamily="XMLBEANS_APACHE"
packageName="some.pagage">
</clientgen>
Some more documentation here:
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webserv_ref/anttasks.html#wp1039270
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.
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( )
http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html
http://www.oracle.com/technology/pub/articles/srivastava_namespaces.html
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
http://people.apache.org/~hughesj/woden/WodenWSDL2Processor_WE12.pdf
This is a sample WSDL 2.0 file:
service has binding, binding has interface, interface has operations, operation has input and output (and fault)
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="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
<wsdl:types>
<xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified"/>
</wsdl:types>
<wsdl:message name="NewMessageRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="NewMessageResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="NewPortType">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewMessageRequest"/>
<wsdl:output message="tns:NewMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NewBinding" type="tns:NewPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="urn:#NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NewService">
<wsdl:port name="NewPort" binding="tns:NewBinding">
<soap:address location="No Target Adress"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
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!
http://en.wikipedia.org/wiki/Web_Services_Description_Language
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:
defining ENDPOINTS, PROTOCOL, PUBLIC INTERFACES, DATA TYPES
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@http://schemas.xmlsoap.org/wsdl/: document element mismatch got description@http://www.w3.org/ns/wsdl
http://people.apache.org/~hughesj/woden/WodenWSDL2Processor_WE12.pdf
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="http://www.w3.org/ns/wsdl" xmlns:wsoap="http://www.w3.org/ns/wsdl/soap" xmlns:whttp="http://www.w3.org/ns/wsdl/http" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://new.webservice.namespace">
<wsdl:types>
<xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified">
<xs:element name="NewMessageRequest" type="xs:string"/>
<xs:element name="NewMessageResponse" type="xs:string"/>
</xs:schema>
</wsdl:types>
<wsdl:interface name="NewInterface">
<wsdl:operation name="NewOperation" pattern="http://www.w3.org/ns/wsdl/in-out">
<wsdl:input messageLabel="In" element="tns:NewMessageRequest"/>
<wsdl:output messageLabel="Out" element="tns:NewMessageResponse"/>
</wsdl:operation>
</wsdl:interface>
<wsdl:binding name="NewBinding" interface="tns:NewInterface" type="http://www.w3.org/ns/wsdl/soap" wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">
<wsdl:operation ref="tns:NewOperation" wsoap:mep="http://www.w3.org/2003/05/soap/mep/request-response/"/>
</wsdl:binding>
<wsdl:service name="NewService" interface="tns:NewInterface">
<wsdl:endpoint name="NewEndpoint" binding="tns:NewBinding"/>
</wsdl:service>
</wsdl:description>
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="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://new.webservice.namespace" targetNamespace="http://new.webservice.namespace">
<wsdl:types>
<xs:schema targetNamespace="http://new.webservice.namespace" elementFormDefault="qualified"/>
</wsdl:types>
<wsdl:message name="NewMessageRequest">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:message name="NewMessageResponse">
<wsdl:part name="parameter" type="xs:string"/>
</wsdl:message>
<wsdl:portType name="NewPortType">
<wsdl:operation name="NewOperation">
<wsdl:input message="tns:NewMessageRequest"/>
<wsdl:output message="tns:NewMessageResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="NewBinding" type="tns:NewPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="NewOperation">
<soap:operation soapAction="urn:#NewOperation"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="NewService">
<wsdl:port name="NewPort" binding="tns:NewBinding">
<soap:address location="No Target Adress"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
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!
http://en.wikipedia.org/wiki/Web_Services_Description_Language
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:
defining ENDPOINTS, PROTOCOL, PUBLIC INTERFACES, DATA TYPES
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@http://schemas.xmlsoap.org/wsdl/: document element mismatch got description@http://www.w3.org/ns/wsdl
Monday, February 15, 2010
WSDL import and XSD import
http://www.ibm.com/developerworks/xml/library/ws-tip-imports.html
an interesting article on the mysteries of WSDLs... its conclusions are:
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
andlocation
attributes, though sometimes necessary, are really only hints.
Labels:
wsdl
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:
package com.acme.integration.tools;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
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
package com.acme.integration.tools;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
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
Labels:
wli
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
http://kr.forums.oracle.com/forums/thread.jspa?threadID=723357&tstart=-1
unzipping $WEBLOGIC_10_3/wlserver_10.3/server/lib/wseeclient.zip 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(ServiceImpl.java:174)
at weblogic.wsee.jaxrpc.ServiceImpl.loadWeblogicDD(ServiceImpl.java:449)
at weblogic.wsee.jaxrpc.ServiceImpl.loadInternalDD(ServiceImpl.java:382)
at weblogic.wsee.jaxrpc.ServiceImpl.(ServiceImpl.java:121)
at com.pierre.helloworld.HelloWorldSync_Impl.(Unknown Source)
at com.pierre.helloworld.HelloWorldSync_Impl.(Unknown Source)
at com.pierre.tests.TestWSDLJar.main(TestWSDLJar.java:9)
Caused by: weblogic.descriptor.DescriptorException: Unmarshaller failed
at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:152)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:306)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:270)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:336)
at weblogic.wsee.jaxrpc.ServiceImpl.loadWeblogicDD(ServiceImpl.java:440)
... 5 more
Caused by: com.bea.xml.XmlException: failed to load java type corresponding to e=weblogic-wsee-standaloneclient@http://www.bea.com/ns/weblogic/weblogic-wsee-standaloneclient
at com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:361)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:316)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:326)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineRootType(UnmarshalResult.java:307)
at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalDocument(UnmarshalResult.java:158)
at com.bea.staxb.runtime.internal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:65)
at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:141)
... 9 more
the solution SEEMS to be
http://kr.forums.oracle.com/forums/thread.jspa?threadID=723357&tstart=-1
unzipping $WEBLOGIC_10_3/wlserver_10.3/server/lib/wseeclient.zip 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(ServiceImpl.java:174)
at weblogic.wsee.jaxrpc.ServiceImpl.loadWeblogicDD(ServiceImpl.java:449)
at weblogic.wsee.jaxrpc.ServiceImpl.loadInternalDD(ServiceImpl.java:382)
at weblogic.wsee.jaxrpc.ServiceImpl.
at com.pierre.helloworld.HelloWorldSync_Impl.
at com.pierre.helloworld.HelloWorldSync_Impl.
at com.pierre.tests.TestWSDLJar.main(TestWSDLJar.java:9)
Caused by: weblogic.descriptor.DescriptorException: Unmarshaller failed
at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:152)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:306)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:270)
at weblogic.descriptor.BasicDescriptorManager.createDescriptor(BasicDescriptorManager.java:336)
at weblogic.wsee.jaxrpc.ServiceImpl.loadWeblogicDD(ServiceImpl.java:440)
... 5 more
Caused by: com.bea.xml.XmlException: failed to load java type corresponding to e=weblogic-wsee-standaloneclient@http://www.bea.com/ns/weblogic/weblogic-wsee-standaloneclient
at com.bea.staxb.runtime.internal.UnmarshalResult.getPojoBindingType(UnmarshalResult.java:361)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:316)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineTypeForGlobalElement(UnmarshalResult.java:326)
at com.bea.staxb.runtime.internal.UnmarshalResult.determineRootType(UnmarshalResult.java:307)
at com.bea.staxb.runtime.internal.UnmarshalResult.unmarshalDocument(UnmarshalResult.java:158)
at com.bea.staxb.runtime.internal.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:65)
at weblogic.descriptor.internal.MarshallerFactory$1.createDescriptor(MarshallerFactory.java:141)
... 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....
this is one of the joys of using WLI....
Labels:
wli
Automating clientgen from Java
package com.acme.integration.tools;
import java.io.File;
import java.util.List;
import weblogic.wsee.tools.WsBuildException;
import weblogic.wsee.tools.clientgen.jaxws.ClientGenImpl;
public class ClientGenTool {
public final static String wls_hostname = "10.10.10.20";
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();
clientGenTool.clientgen();
}
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();
cgi.setWsdl(wsdl);
cgi.setDestDir(destDir);
cgi.setPackageName(packageName);
cgi.execute();
}
}
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.
import java.io.File;
import java.util.List;
import weblogic.wsee.tools.WsBuildException;
import weblogic.wsee.tools.clientgen.jaxws.ClientGenImpl;
public class ClientGenTool {
public final static String wls_hostname = "10.10.10.20";
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();
clientGenTool.clientgen();
}
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();
cgi.setWsdl(wsdl);
cgi.setDestDir(destDir);
cgi.setPackageName(packageName);
cgi.execute();
}
}
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.
Labels:
clientgen,
webservices
Wednesday, February 10, 2010
Bash script to find the location of the currently running script
#!/bin/bash
#==========================
# 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 http://forums.macosxhints.com/archive/index.php/t-73839.html )
Otherwise, this is much simpler:
SCRIPT=`readlink -f $0`
SCRIPTPATH=`dirname $SCRIPT`
echo $SCRIPTPATH
#==========================
# 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 http://forums.macosxhints.com/archive/index.php/t-73839.html )
Otherwise, this is much simpler:
SCRIPT=`readlink -f $0`
SCRIPTPATH=`dirname $SCRIPT`
echo $SCRIPTPATH
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@10.20.30.40:d:/cvsroot" login
Logging in to :pserver:weblogic@jcrmtools:2401/mycvsusername:mypwd@10.20.30.40:d:/cvsroot
CVS password:
Unknown host JCRMTools.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:d:/cvsroot" 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@10.20.30.40:d:/cvsroot'.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/home/CVS" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/home/CVS
/home/CVS: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/
/: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/cvsroot
/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/CVS" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/CVS
/CVS: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:d//cvsroot" 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@10.20.30.40:d//cvsroot'.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d//cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d//cvsroot
/d//cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d/cvsroot
/d/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40://d/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401//d/cvsroot
//d/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d:/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d:/cvsroot
/d:/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d:cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d:cvsroot
/d:cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d:\cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d:\cvsroot
/d:\cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40://d:\cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401//d:\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!
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@10.20.30.40:d:/cvsroot" login
Logging in to :pserver:weblogic@jcrmtools:2401/mycvsusername:mypwd@10.20.30.40:d:/cvsroot
CVS password:
Unknown host JCRMTools.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:d:/cvsroot" 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@10.20.30.40:d:/cvsroot'.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/home/CVS" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/home/CVS
/home/CVS: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/
/: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/cvsroot
/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/CVS" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/CVS
/CVS: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:d//cvsroot" 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@10.20.30.40:d//cvsroot'.
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d//cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d//cvsroot
/d//cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d/cvsroot
/d/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40://d/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401//d/cvsroot
//d/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d:/cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d:/cvsroot
/d:/cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d:cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d:cvsroot
/d:cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40:/d:\cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401/d:\cvsroot
/d:\cvsroot: no such repository
[weblogic@CRM-INTG-DEV ~]$ cvs -d ":pserver:mycvsusername:mypwd@10.20.30.40://d:\cvsroot" login
Logging in to :pserver:mycvsusername@10.20.30.40:2401//d:\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!
Labels:
cvs
Tuesday, February 9, 2010
WLI processes terminator!
a very similar utility has already been published here
http://javamonamour.blogspot.com/2009/11/querying-and-terminating-wli-instances.html
package com.acme.integration.tools;
import java.util.Iterator;
import java.util.Set;
import javax.management.MBeanException;
import javax.naming.Context;
import javax.naming.NamingException;
import weblogic.jndi.Environment;
import weblogic.management.MBeanHome;
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;
import com.bea.wli.management.runtime.ProcessInstanceInfo;
import com.bea.wli.management.runtime.ProcessInstanceQuery;
import com.bea.wli.management.runtime.ProcessInstanceQueryResult;
import com.bea.wli.management.runtime.ProcessRuntimeMBean;
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();
env.setSecurityPrincipal(username);
env.setSecurityCredentials(password);
env.setProviderUrl(url);
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)it.next();
ProcessInstanceQuery query = new ProcessInstanceQuery();
//query.setServiceURI(SERVICE_URI);
for (ProcessStatus p : processStatusToTerminate) {
query.setStatus(p);
terminateInstances(bean, query);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
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/com.bea.core.weblogic.security.identity_1.1.0.0.jar"
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"
http://javamonamour.blogspot.com/2009/11/querying-and-terminating-wli-instances.html
package com.acme.integration.tools;
import java.util.Iterator;
import java.util.Set;
import javax.management.MBeanException;
import javax.naming.Context;
import javax.naming.NamingException;
import weblogic.jndi.Environment;
import weblogic.management.MBeanHome;
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;
import com.bea.wli.management.runtime.ProcessInstanceInfo;
import com.bea.wli.management.runtime.ProcessInstanceQuery;
import com.bea.wli.management.runtime.ProcessInstanceQueryResult;
import com.bea.wli.management.runtime.ProcessRuntimeMBean;
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();
env.setSecurityPrincipal(username);
env.setSecurityCredentials(password);
env.setProviderUrl(url);
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)it.next();
ProcessInstanceQuery query = new ProcessInstanceQuery();
//query.setServiceURI(SERVICE_URI);
for (ProcessStatus p : processStatusToTerminate) {
query.setStatus(p);
terminateInstances(bean, query);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
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/com.bea.core.weblogic.security.identity_1.1.0.0.jar"
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:
http://www.wincvs.org/download.html
(I have downloaded WinCvs2_0_2-4.zip, 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:
:pserver:mycvsusername:mycvspassword@10.130.123.229:d:/cvsroot
If you checkout multiple modules, they should be separated by BLANK, not by comma....
Hudson will checkout into
C:\Users\myusername\.hudson\jobs\PVDemo\workspace
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
ON LINUX:
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)
http://www.wincvs.org/download.html
(I have downloaded WinCvs2_0_2-4.zip, 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:
:pserver:mycvsusername:mycvspassword@10.130.123.229:d:/cvsroot
If you checkout multiple modules, they should be separated by BLANK, not by comma....
Hudson will checkout into
C:\Users\myusername\.hudson\jobs\PVDemo\workspace
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
ON LINUX:
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"?>
<classpath>
<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">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<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/com.bea.core.management.core.binding_2.3.0.0.jar"/>
<classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.management.core_2.3.0.0.jar"/>
<classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.i18n_1.4.0.0.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
I have struggled with JavaClassFinder (precious tool!) to find out all these libraries.
Anyway we have 2 ways:
the JAX-WS
http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/webserv/client.html
and the RPC way
http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/webserv_rpc/client.html
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
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"?>
<classpath>
<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">
<attributes>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<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/com.bea.core.management.core.binding_2.3.0.0.jar"/>
<classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.management.core_2.3.0.0.jar"/>
<classpathentry kind="lib" path="C:/beaosb/modules/com.bea.core.i18n_1.4.0.0.jar"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
I have struggled with JavaClassFinder (precious tool!) to find out all these libraries.
Anyway we have 2 ways:
the JAX-WS
http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/webserv/client.html
and the RPC way
http://download-llnw.oracle.com/docs/cd/E12840_01/wls/docs103/webserv_rpc/client.html
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
wseeclient.zip
See here
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/webserv/client.html#wp229351
So.... read carefully documentation before you start chasing things around...
Labels:
clientgen,
webservices
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.(KernelLogManager.java:22)
at weblogic.kernel.KernelLogManager.getLogger(KernelLogManager.java:28)
at weblogic.logging.commons.LogImpl.(LogImpl.java:14)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.apache.axis2.description.AxisDescription.(AxisDescription.java:76)
at org.openuri.www.GetPrepaidAccountBalanceProcessStub.populateAxisService(GetPrepaidAccountBalanceProcessStub.java:41)
at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:91)
at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:78)
at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:124)
at org.openuri.www.GetPrepaidAccountBalanceProcessStub.(GetPrepaidAccountBalanceProcessStub.java:117)
at com.pierre.acmetester.AcmePrepaidTester.main(JawwalPrepaidTester.java:14)
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.
Exception in thread "Main Thread" java.lang.NoClassDefFoundError: weblogic/management/WebLogicMBean
at weblogic.kernel.KernelLogManager$LoggerMaker.
at weblogic.kernel.KernelLogManager.getLogger(KernelLogManager.java:28)
at weblogic.logging.commons.LogImpl.
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:21)
at weblogic.logging.commons.LogFactoryImpl.getInstance(LogFactoryImpl.java:18)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.apache.axis2.description.AxisDescription.
at org.openuri.www.GetPrepaidAccountBalanceProcessStub.populateAxisService(GetPrepaidAccountBalanceProcessStub.java:41)
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(JawwalPrepaidTester.java:14)
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
C:\downloads\axis2-1.5.1-bin\axis2-1.5.1\bin>wsdl2java.bat
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
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
where [options] include:
-o
-a Generate async style code only (Default: off).
-s Generate sync style code only (Default: off). Takes precedence over -a.
-p
-l
-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
-g Generates all the classes. Valid only with -ss.
-pn
-sn
-u Unpacks the databinding classes
-r
-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
-S
-R
-em
-f Flattens the generated files
-uw Switch on un-wrapping.
-xsdconfig
-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
-Ebindingfile
-Etypesystemname
-Ejavaversion 1.5 (for xmlbeans) - generates Java 1.5 code (typed lists instead of arrays)
-Emp
-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
--http-proxy-port
-ep
-sin
-scn
-EbindingFileName
-oaa
-ebc
-uon
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(((
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( .
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
http://blogs.oracle.com/jamesbayer/2007/10/automate_wls_console_tasks_wit.html
excellent tutorial! As usual with James Bayer!
In a nutshell:
cd C:\beawli\user_projects\domains\JCRMIntegration_Domain\bin
setDomainEnv.cmd
java weblogic.WLST
connect( 'weblogic', 'weblogic', 't3://localhost:7001')
stopApplication('ACME_INTEG_EAR')
undeploy('ACME_INTEG_EAR')
deploy('ACME_INTEG_EAR', 'C:/TEMP/WORKSHOP_ACME_INTEG_EAR.ear', targets='AdminServer')
startApplication('ACME_INTEG_EAR')
disconnect()
The complete script is:
excellent tutorial! As usual with James Bayer!
In a nutshell:
cd C:\beawli\user_projects\domains\JCRMIntegration_Domain\bin
setDomainEnv.cmd
java weblogic.WLST
connect( 'weblogic', 'weblogic', 't3://localhost:7001')
stopApplication('ACME_INTEG_EAR')
undeploy('ACME_INTEG_EAR')
deploy('ACME_INTEG_EAR', 'C:/TEMP/WORKSHOP_ACME_INTEG_EAR.ear', targets='AdminServer')
startApplication('ACME_INTEG_EAR')
disconnect()
The complete script is:
connect( 'weblogic', 'weblogic1', 't3://localhost:7001') try: stopApplication('MQParserEAR') except: print 'unable to stop' try: undeploy('MQParserEAR') except: print 'unable to undeploy' deploy('MQParserEAR', '/path/to/MQParserEAR/1.1.0-SNAPSHOT/MQParserEAR-1.1.0-SNAPSHOT.ear', targets='AdminServer') startApplication('MQParserEAR') disconnect()
Trouble starting WLI? Truncate everything!
here is what you should do to clean completely the environment:
1- Execute the following script
2- Delete all files on the $DomainPath$/WseeFileStore
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_INSTANCE_INFO;
truncate table WLI_PROCESS_TRACKING;
Wednesday, February 3, 2010
Exporting WebLogic Workshop as Ant Script
this will create:
${workspace-dir}/workshop-lib/
${workspace-dir}/workspace.xml
${workspace-dir}/${project-dir}/build.xml
you should specify these properties:
workspace
wl.home
workshop.home
(
the wizard suggests you to declare:
wl.home=C:/beawli/wlserver_10.3
workshop.home=C:/beawli/workshop_10.3
workspace.dir=C:/beawli/user_projects/workspaces/default
)
How to export Ant in Workshop :
http://download.oracle.com/docs/cd/E13224_01/wlw/docs102/guide/ideuserguide/build/conUseCustomAntBuild.html
this http://www.oracle.com/technology/pub/articles/liptak-workshop-ant.html 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:
declare
cd C:\beawli\user_projects\workspaces\default\JAWWAL_INTEG_WEB
c:\beawli\wlserver_10.3\common\bin\commEnv.cmd
#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 org.apache.tools.ant.listener.Log4jListener -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
${workspace-dir}/workshop-lib/
${workspace-dir}/workspace.xml
${workspace-dir}/${project-dir}/build.xml
you should specify these properties:
workspace
wl.home
workshop.home
(
the wizard suggests you to declare:
wl.home=C:/beawli/wlserver_10.3
workshop.home=C:/beawli/workshop_10.3
workspace.dir=C:/beawli/user_projects/workspaces/default
)
How to export Ant in Workshop :
http://download.oracle.com/docs/cd/E13224_01/wlw/docs102/guide/ideuserguide/build/conUseCustomAntBuild.html
this http://www.oracle.com/technology/pub/articles/liptak-workshop-ant.html 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:
declare
cd C:\beawli\user_projects\workspaces\default\JAWWAL_INTEG_WEB
c:\beawli\wlserver_10.3\common\bin\commEnv.cmd
#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 org.apache.tools.ant.listener.Log4jListener -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 http://download.oracle.com/docs/cd/E13224_01/wlw/docs103/guide/ideuserguide/conUsingXMLBeans.html
For more info on the XMLBeans tools, see http://xmlbeans.apache.org/docs/2.0.0/guide/tools.html
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 http://download.oracle.com/docs/cd/E13224_01/wlw/docs103/guide/ideuserguide/conUsingXMLBeans.html
For more info on the XMLBeans tools, see http://xmlbeans.apache.org/docs/2.0.0/guide/tools.html
Tuesday, February 2, 2010
WLI processes: some useful configuration
in build/processoutput/WEB-INF you will find:
wli-processes.xml
with things like:
<proc:ProcessManifest xmlns:proc="http://www.bea.com/wli/management/processmanifest">
<proc:project name="ACME_INTEG_WEB">
<proc:ProcessDefinitions>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/installmentWithDiscountInfo/ViewInstallmentWithDiscount.java" SVUID="0" stateless="true"/>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/ViewMonthlyChargesProcess.java" SVUID="0" stateless="true"/>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/UpdatePrepaidSubscriberProcess.java" SVUID="0" stateless="true"/>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/UpdatePostpaidSubscriberProcess.java" 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:async-request-queue>ACME_INTEG_WEB.queue.AsyncDispatcher</con:async-request-queue>
<con:async-request-error-queue>ACME_INTEG_WEB.queue.AsyncDispatcher_error</con:async-request-error-queue>
<con:top-level-component component-type="JPD" class-name="processes.installmentWithDiscountInfo.ViewInstallmentWithDiscount">
<con:external-callbacks/>
<con:security-roles>
<con:role-name/>
</con:security-roles>
</con:top-level-component>
<con:top-level-component component-type="JPD" class-name="processes.ViewMonthlyChargesProcess">
<con:external-callbacks/>
<con:security-roles>
<con:role-name/>
</con:security-roles>
</con:top-level-component>
wli-processes.xml
with things like:
<proc:ProcessManifest xmlns:proc="http://www.bea.com/wli/management/processmanifest">
<proc:project name="ACME_INTEG_WEB">
<proc:ProcessDefinitions>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/installmentWithDiscountInfo/ViewInstallmentWithDiscount.java" SVUID="0" stateless="true"/>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/ViewMonthlyChargesProcess.java" SVUID="0" stateless="true"/>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/UpdatePrepaidSubscriberProcess.java" SVUID="0" stateless="true"/>
<proc:Process ejbModuleName="ACME_INTEG_WEB_WLI_ComponentBeans" URI="/ACME_INTEG_WEB/processes/UpdatePostpaidSubscriberProcess.java" 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:async-request-queue>ACME_INTEG_WEB.queue.AsyncDispatcher</con:async-request-queue>
<con:async-request-error-queue>ACME_INTEG_WEB.queue.AsyncDispatcher_error</con:async-request-error-queue>
<con:top-level-component component-type="JPD" class-name="processes.installmentWithDiscountInfo.ViewInstallmentWithDiscount">
<con:external-callbacks/>
<con:security-roles>
<con:role-name/>
</con:security-roles>
</con:top-level-component>
<con:top-level-component component-type="JPD" class-name="processes.ViewMonthlyChargesProcess">
<con:external-callbacks/>
<con:security-roles>
<con:role-name/>
</con:security-roles>
</con:top-level-component>
Subscribe to:
Posts (Atom)