Running CallRemoteXADisk in WIldfly 8.2

111 views
Skip to first unread message

Hobo Joe

unread,
May 8, 2015, 1:33:01 PM5/8/15
to xad...@googlegroups.com
All,
 I am trying to run XADisk.rar in Wildfly 8.2 with the following descriptor in standalone.xml. When I run CallRemoteXADisk from the same box that the XADisk.rar is deployed on I get the below error. JBoss logs look ok and the XADisk.rar deployed? Can anyone see my obvious mistake?

        <subsystem xmlns="urn:jboss:domain:resource-adapters:2.0">
<resource-adapters> 
 <resource-adapter> 
            <archive> 
                XADisk.rar 
            </archive> 
            <transaction-support>XATransaction</transaction-support> 
            <config-property name="xaDiskHome"> 
                F:\work\XADISKHOME
            </config-property> 
            <config-property name="instanceId"> 
                xadisk1 
            </config-property> 
            <connection-definitions> 
                <connection-definition class-name="org.xadisk.connector.outbound.XADiskManagedConnectionFactory" jndi-name="java:global/XADiskCF" pool-name="XADiskConnectionFactoryPool"> 
                    <config-property name="instanceId"> 
                        xadisk1 
                    </config-property> 
                    <xa-pool> 
                        <min-pool-size>1</min-pool-size> 
                        <max-pool-size>5</max-pool-size> 
                    </xa-pool> 
                </connection-definition> 
            </connection-definitions> 
  </resource-adapter> 
         </resource-adapters> 
</subsystem>


OUTPUT:
Connected to the target VM, address: '127.0.0.1:55476', transport: 'socket'
Executing the application-module1...
Obtaining a reference to the remote XADisk instance...
Obtaining a session from the remote XADisk instance...
org.xadisk.filesystem.exceptions.ConnectionException: java.net.ConnectException: Connection refused: connect
at org.xadisk.bridge.proxies.facilitators.RemoteMethodInvoker.invokeRemoteMethod(RemoteMethodInvoker.java:116)
at org.xadisk.bridge.proxies.facilitators.RemoteObjectProxy.invokeRemoteMethod(RemoteObjectProxy.java:39)
at org.xadisk.bridge.proxies.impl.RemoteXAFileSystem.createSessionForLocalTransaction(RemoteXAFileSystem.java:61)
at com.leidos.aimes.fmv.webservice.RemoteXADisk.runApplicationModule1(RemoteXADisk.java:69)
at com.leidos.aimes.fmv.webservice.RemoteXADisk.main(RemoteXADisk.java:53)
Caused by: java.net.ConnectException: Connection refused: connect
at sun.nio.ch.Net.connect0(Native Method)
at sun.nio.ch.Net.connect(Net.java:458)
at sun.nio.ch.Net.connect(Net.java:450)
at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:648)
at java.nio.channels.SocketChannel.open(SocketChannel.java:189)
at org.xadisk.bridge.proxies.facilitators.RemoteMethodInvoker.ensureConnected(RemoteMethodInvoker.java:54)
at org.xadisk.bridge.proxies.facilitators.RemoteMethodInvoker.invokeRemoteMethod(RemoteMethodInvoker.java:77)
... 4 more
Disconnected from the target VM, address: '127.0.0.1:55476', transport: 'socket'

Nitin Verma

unread,
May 9, 2015, 4:07:16 AM5/9/15
to xad...@googlegroups.com, stvgo...@gmail.com
Hi Hobo,

Even though your xadisk-client is on the same machine, but it is on a different jvm than the one where xadisk is deployed. So, you need to enable remote-invocation in the xadisk instance. For that, in addition to the xaDiskHome and instanceId properties, you also need to specify the below <config-property> values inside the xadisk subsystem element of standalone.xml:

enableRemoteInvocations (true)
serverAddress (e.g. localhost)
serverPort (e.g. 5151)

Please refer to the user-guide (http://java.net/projects/xadisk/downloads/download/XADisk%201.2.2%20User%20Guide.pdf) appendix-A for description of these properties. I am also copying that here:

"An XADisk instance can be configured to receive remote invocations. This allows remote application clients to perform operations over the XADisk instance. This feature also allows XADisk JCA Resource Adapter to facilitate inbound messaging from remote XADisk instances to the MDBs deployed in the same JavaEE Server. The following configuration is required to enable an XADisk instance to accept such remote invocations:

i. enableRemoteInvocations flag must be set to true.

ii. serverAddress should be set such that the applications running on the remote JVMs can contact this XADisk instance using this address.
39

iii. serverPort should be set to a port available on the machine. The XADisk instance would listen at the specified port to receive calls from remote applications."

Thanks,
Nitin

Hobo Joe

unread,
May 9, 2015, 11:19:58 AM5/9/15
to xad...@googlegroups.com, stvgo...@gmail.com
Thank you Nitin, that got me connected thank you. However when the runApplicationMudule1 method calls session.fileExists the program hangs forever in RemoteMethodInvoker ln:95 trying to read off the input stream socket.

      <subsystem xmlns="urn:jboss:domain:resource-adapters:2.0">
<resource-adapters> 
 <resource-adapter> 
            <archive> 
                XADisk.rar 
            </archive> 
            <transaction-support>XATransaction</transaction-support> 
            <config-property name="xaDiskHome"> 
                F:\work\XADISKHOME
            </config-property> 
            <config-property name="instanceId"> 
                xadisk1 
            </config-property> 
<config-property name="enableRemoteInvocations"> 
                true 
            </config-property> 
<config-property name="serverAddress"> 
                10.35.58.217 
            </config-property> 
<config-property name="serverPort"> 
                5151 
            </config-property> 
            <connection-definitions> 
                <connection-definition class-name="org.xadisk.connector.outbound.XADiskManagedConnectionFactory" jndi-name="java:global/XADiskCF" pool-name="XADiskConnectionFactoryPool"> 
                    <config-property name="instanceId"> 
                        xadisk1 
                    </config-property> 
                    <xa-pool> 
                        <min-pool-size>1</min-pool-size> 
                        <max-pool-size>5</max-pool-size> 
                    </xa-pool> 
                </connection-definition> 
            </connection-definitions> 
  </resource-adapter> 
         </resource-adapters> 
</subsystem>

Nitin Verma

unread,
May 9, 2015, 1:00:44 PM5/9/15
to xad...@googlegroups.com, stvgo...@gmail.com
Hi Hobo,

In general that should not happen. Please send a simplified version of the client code which connects to xadisk, creates session, calls fileExists etc.

Thanks,
Nitin

Hobo Joe

unread,
May 9, 2015, 1:24:27 PM5/9/15
to xad...@googlegroups.com, stvgo...@gmail.com
Sure, it is just what came in an example. The code is below. I took the XADisk.rar from the binaries sub-folder and deployed it to Wildfly. Then, in intellij I run the org.xadisk.examples.CallRemoteXADisk class and step through it in the debugger. The XADisk log file shows entries for startup/shutdown but no errors. 




/*
Copyright © 2010-2011, Nitin Verma (project owner for XADisk https://xadisk.dev.java.net/). All rights reserved.

This source code is being made available to the public under the terms specified in the license
"Eclipse Public License 1.0" located at http://www.opensource.org/licenses/eclipse-1.0.php.
*/


import java.io.File;


        import java.io.File;
        import org.xadisk.additional.XAFileOutputStreamWrapper;
        import org.xadisk.bridge.proxies.interfaces.Session;
        import org.xadisk.bridge.proxies.interfaces.XAFileOutputStream;
        import org.xadisk.bridge.proxies.interfaces.XAFileSystem;
        import org.xadisk.bridge.proxies.interfaces.XAFileSystemProxy;
        import org.xadisk.filesystem.exceptions.XAApplicationException;


/**
 * This is a very basic example to show how to work with remotely running XADisk instances. Such
 * remote XADisk instance could either be deployed as a JCA Resource Adapter inside a JavaEE server, or
 * it could be running in any JVM (e.g. as done in "BootXADisk" example).
 * The below example will work in both cases as long as the correct remote address/port are specified.
 */
/**
 * How to run this example:
 *
 * 1) Change the various constants used in the code below: remoteXADiskAddress, remoteXADiskPort and testFile.
 * 2) Bring the remote XADisk instance up, if it is not up already.
 * 3) To compile/run this example, one needs:
 *      - XADisk.jar
 *      - JCA API jar, which can be downloaded from http://download.java.net/maven/1/javax.resource/jars/connector-api-1.5.jar
 *      - Java 5 or above
 */
/**
 * Please refer to the XADisk JavaDoc and User Guide for knowing more about using XADisk.
 */
public class RemoteXADisk {

    //network address of the machine on which the remote XADisk instance is running.
    private static final String remoteXADiskAddress = "localhost";
    //network port on which the remote XADisk is instance listening.
    private static final int remoteXADiskPort = 5151;
    //test file, on the file-system wrapped by the remote XADisk instance.
    private static final String testFile = "F:\\work\\XADISKHOME\\orders2.csv";

    public static void main(String args[]) {
        try {
            runApplicationModule1();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static void runApplicationModule1() throws Exception {

        System.out.println("Executing the application-module1...");

        File businessData = new File(testFile);

        System.out.println("Obtaining a reference to the remote XADisk instance...");
        XAFileSystem remoteXAF = XAFileSystemProxy.getRemoteXAFileSystemReference(remoteXADiskAddress, remoteXADiskPort);

        System.out.println("Obtaining a session from the remote XADisk instance...");
        Session session = remoteXAF.createSessionForLocalTransaction();

        try {
            System.out.println("Doing some operations on the file-system via XADisk...");
            if (!session.fileExists(businessData)) {
                session.createFile(businessData, false);
            }

            XAFileOutputStream xaFOS = session.createXAFileOutputStream(businessData, false);
            XAFileOutputStreamWrapper wrapperOS = new XAFileOutputStreamWrapper(xaFOS);
            wrapperOS.write("Coffee Beans, 5, 100, Street #11, Moon - 311674 \n".getBytes());
            wrapperOS.close();

            System.out.println("Committing the transaction...");
            session.commit();

            System.out.println("The application-module1 completed successfully.");
        } catch (XAApplicationException xaae) {
            System.out.println("The application-module1 could not execute successfully.");
            xaae.printStackTrace();
            System.out.println("Rolling back the transaction...");
            session.rollback();
        } finally {
            System.out.println("Disconnecting from the remote XADisk instance...");
            remoteXAF.shutdown();
        }
    }
}

Hobo Joe

unread,
May 9, 2015, 8:24:43 PM5/9/15
to xad...@googlegroups.com
Nitin, 
  I am using Java 1.8.0_31 to build CallRemoteXADisk.java. The app server is Wildfly 8.1 and 8.2 both pointed at Java 1.8._31. The xadisk version is 1.2.1.

Hobo Joe

unread,
May 10, 2015, 12:44:44 PM5/10/15
to xad...@googlegroups.com
So I debugged this more. In the client I get into the RemoteMethodInvoker and it hangs on line 95 while reading off the InputStream. In the XADisk RAR  it receives the fileExists() invocation, does the check and correctly figures out if the file exists. Then in RemoteMethodInvocationHandler.java ln:77 this code occurs...

while (toSend.remaining() > 0 && enabled) {
int n = writeSelector.select();
if (n == 0) {
//release() got called...thats the only possibility.
break;
}

n is always zero on the fileExists() invocation though toSend.remainin() == 54. 

This happens for me with Jboss 7.2 final, wildfly 8.1 and 8.2. I am running on a windows7 box and don't get any errors from the appserver or in the XAdisk logs.

Nitin Verma

unread,
May 11, 2015, 1:11:40 PM5/11/15
to xad...@googlegroups.com, stvgo...@gmail.com
Hello Hobo,

I tried the above RemoteXADisk client code with xadisk 1.2.1 running on another jvm. It ran successfully multiple times. I do not have the other environment factors available to really confirm. But I would suggest that you can try diagnosing the 0-return from the writeSelector.select() call. As per the javadoc, it may return 0 in specific conditions:

"It returns only after at least one channel is selected, this selector's {@link #wakeup wakeup} method is invoked, or the current thread is interrupted, whichever comes first."

You can pause the debugger just before the select() (during fileExists) and observe:
1. the value of "enabled" boolean flag of this class. It will tell you if release() method of the class was called.
2. the value of Thread.currentThread().isInterrupted() flag, to find out if the RemoteMethodInvocationHandler thread was interrupted.

Thanks,
Nitin

Reply all
Reply to author
Forward
0 new messages