Tag Archives: JAVA

Store Content to FileNet server using LiveCycle Java APIs

- Pankaj Gakhar, Software Engineer @ Adobe

You should have LiveCycle server installed and LiveCycle connector for IBM FileNet should be configured with it.

Follow the steps below to store content to FileNet server using LiveCycle’s Java APIs:

1. Create ServiceClientFactory Object.

2. Create an object of IBMFileNetContentRepositoryConnectorServiceClient class using the object of ServiceClientFactory class.


Read the complete post at Adobe LiveCycle Blog.

LCDS Multi-Client Support: Native iOS, Android, HTML, Java, and Flex

– Christophe Coenraets

Last year at MAX, we announced and sneak peeked the new multi-client support in LCDS. LCDS will soon provide native client libraries for iOS, Java, Android, HTML / HTML 5 (with WebSockets support when available), and Flex. The engineering team has been hard at work on this. My friend Mete Atamel has been leading the charges, and he recently recorded the screencast below showing six different clients connecting to an LCDS server.


Original article at http://coenraets.org/blog/2011/05/lcds-multi-client-support-native-ios-android-html-java-and-flex/.

Extending LiveCycle ES 2.5 for Java Developers

The full courseware that Scott MacDonald, Gary Gilchrist and I delivered during MAX 2010 is not available online.  Anyone may use this material as a self paced tutorial to understand how Java Developers can extend the native capabilities of Adobe LiveCycle ES. 

The course is available as a ZIP file here (right click then save the target as …”)


This course covers the following topics:

Extending Livecycle ES for Java Developers


Task 2‐1: Start Eclipse and create a new project
Task 2‐2: Add the required Java library files
Task 2‐3: Defining the service interface
Task 2‐4: Defining the service implementation
Task 2‐5: Defining the component XML file

Task 3‐1: Package your component into a JAR file
Task 3‐2: Importing the component using Workbench ES2

Task 4‐1: Create the EncryptManyDocuments/EncryptManyDocuments process and invoke it from
Task 4‐2: Programmatically invoking the EncryptManyDocuments process.

Solution Code is provided as well as extra notes on the code for the programmatic invocation:

Original article at http://technoracle.blogspot.com/2011/04/extending-livecycle-es-25-for-java.html.

Using Java VisualVM to Profile LiveCycle ES2

– Jayan Kandathil

The 1.6 release of the Sun “HotSpot” JDK comes with a built-in profiling tool called Java VisualVM (jvisualvm.exe) You can find it in the /bin folder of the JDK.

You can monitor a JVM hosting LiveCycle remotely. You have to enable remote JMX monitoring first. Instructions are available here.

– Run jvisualvm.exe
– Choose the menu File->Add Remote Host
– In the left navigation pane, highlight the newly added remote host, right-click the mouse and choose ‘Add JMX Connection’
– In the ‘Connection’ field, type in the IP address of the remote host and the JMX port. For example
– Click OK
– In the left navigation pane, dbl-click on the newly added JMX Connection
– Click on the ‘Threads’ tab to see what the JVM threads are doing. You can perform a ‘Thread Dump’ from this tab.
– Click on the ‘Monitor’ tab if you want to perform a heap dump. The heap dump file (.hprof) will be saved on the remote host in the folder designated as -Djava.io.tmpdir

Original article at http://blogs.adobe.com/livecycle/2011/03/using-java-visualvm-to-profile-livecycle-es2.html.

Java exceptions and Flex

I’ve seen some articles on this subject but I have not found one dealing with all cases (webservices, BlazeDS, BlazeDS and Spring, data management). Also the approach for BlazeDS is different than the one used with Spring/BlazeDS integration, and this thing can be a little bit confusing for a beginner.

Let’s assume that you have a layer of services that should be invoked from your Flex application. You can expose these services as web services or as remote methods. Or you can use data management. The Java methods may throw errors and you want to display them in the Flex application.

For simplicity I will use a very short method as an example. The method signature is :

public String returnResults() throws DatabaseDownException;

There are four main use cases:

a)You have to write a webservice to return the result as XML. For example:

<?xml version="1.0" encoding="UTF-8"?>

In this case you will need to enhance your XML to add a structure for keeping error messages – like this:

<?xml version="1.0" encoding="UTF-8"?>

When building the XML the <error> body is going to envelope the exception message. Of course more information can be added, including exception type, severity, and so on. The same approach should be used also when working with SOAP services

b)You plan to use BlazeDS and Java remoting

In this case things are going to be easier,  because BlazeDS is able to automatically serialize the thrown exception and you can find the serialized exception in the FaultEvent object. Assume that you have the Java exception declared below. It extends the RuntimeException and it has a getter method for a custom field.

public class DatabaseDownException extends RuntimeException{
private String customField;
public String getCustomField(){
return customField;

The Flex code declares a remote object and registers a handler (which is also included) for failure.

<mx:RemoteObject id="test" destination="testDestination" result="resultHandler(event)" fault="faultHandler(event)"/>
private function faultHandler(event:FaultEvent):void{
var exception:Object = event.fault.rootCause;

There are four fields in the serialized exception. The first three are inherited from the Throwable object, the last one is declared in your exception. It is interesting to note that you need not have a pair of set/get function in order to have your property serialized. The Throwable object is the only object in which  it is enough to have get methods in order to serialize the values (you can take a look at flex.messaging.io.ThrowableProxy to check that).

The only drawback is that you are working with untyped objects..if you don’t like that you can throw instead instances of flex.messaging.MessageException. This Java class is part of the BlazeDS and it will be deserialized using the class mx.messaging.messages.ErrorMessage (obtained from the event.message property).

You can add your custom data in the MessageException class using the extended property. For example:

MessageException messageException = new MessageException();
HashMap<String,String> map = new HashMap<String,String>();
map.put("clientName", "JOHN");
map.put("clientSurname", "MASTER");
throw messageException;

And on the Flex side:

private function faultHandler(event:FaultEvent):void{
var errorMessage:ErrorMessage = event.message as ErrorMessage;

You probably do not want to have an explicit dependence between your service layer and the BlazeDS libraries, so in this case you should build a delegate on top of it, which will also act as an exception translator.

c)Using Spring BlazeDS Integration

You have several benefits when using Spring BlazeDS integration, and if your middle tier is already using Spring it’s a must. The benefit related to exception handling is the exception translator mechanism. This translator will catch all the exceptions thrown from the services invoked from Flex and you can translate them into something more meaningful for the client.

First you need to declare the exception translator:

<bean id="exceptionTranslator" class="com.test.exception.ExceptionTranslatorImpl" />
<flex:message-broker services-config-path="/WEB-INF/flex/services-config.xml">
<flex:exception-translator ref="exceptionTranslator" />

The exception translator is below:

public class ExceptionTranslatorImpl implements ExceptionTranslator{
//handles all
public boolean handles(final Class<?> clazz){
return true;
public MessageException translate(final Throwable throwable){
if (throwable instanceof DatabaseDownException){
MessageException exception = new MessageException();
return exception;
if ...........//check another things

Note that in the current version of Spring/BlazeDS integration it is mandatory to have an exception translator, otherwise the original error is going to be swallowed and you will receive some generic error.

d)Using data management

The same approach from point c) applies here. Basically your assembler – which is going to invoke some service to obtain/create data – will take care of translating the exceptions into something meaningful for the client. I wrote some time ago a short post about that here.

Note: this article was translated also in Belorussian (thanks Patricia), you can find it here.

Original article at http://cornelcreanga.com/2010/05/java-exceptions-and-flex/.