Java callback from C

I'm trying to call Java class method from C code (via JNI), but Java VM dies with
# An unexpected error has been detected by HotSpot Virtual Machine:
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d6c79dd, pid=128, tid=2192
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode)
# Problematic frame:
# V  [jvm.dll+0x879dd]
# An error report file with more information is saved as hs_err_pid128.log
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
Hello world!
Hello world, from Java to C!This is Java code:
Hello.java
class Hello
     public native void sayHello();
     public native void sayHello(String hello);
     public native void sayHello(Callback callback);
     static
          try
               System.loadLibrary("hello");
          catch(Exception e)
               System.out.println("exception " + e.getMessage());
     public static void main(String[] args)
          Hello h = new Hello();
          h.sayHello ();
          h.sayHello("Hello world, from Java to C!");
          Callback callback = new Callback();
          h.sayHello(callback);
}Callback.java
public class Callback
     public void sayHello(int num)
          for(int i=0; i<num; i++)
               System.out.println("Hello world, from C to Java!");
}This is C code:
Hello.c
#include <mingw/_mingw.h> //because there are some types needed for JNI
#include <jni.h>
#include "Hello.h"
#include <stdio.h>
JNIEXPORT void JNICALL Java_Hello_sayHello__
  (JNIEnv *env, jobject obj)
     printf("Hello world!\n");
     return;
JNIEXPORT void JNICALL Java_Hello_sayHello__Ljava_lang_String_2
  (JNIEnv *env, jobject obj, jstring hello)
     const char *str = (*env)->GetStringUTFChars(env, hello, 0);
     printf("%s", str);
     (*env)->ReleaseStringUTFChars(env, hello, str);
     return;
JNIEXPORT void JNICALL Java_Hello_sayHello__LCallback_2
  (JNIEnv *env, jobject obj, jobject call)
     jclass clazz = (*env)->GetObjectClass(env, call);
     jmethodID id = (*env)->GetMethodID(env, clazz, "sayHello", "(I)V");
     if(id == NULL)
          //(*env)->ExceptionDescribe(env);
          (*env)->ExceptionClear(env);
          printf("Method not found!\n");
}C if linked with
gcc -mno-cygwin -Wl,--add-stdcall-alias,--kill-at -shared -Wl,--output-def=Hello.def -o"hello.dll"  ./Hello.oand 'def' file is:
EXPORTS
Java_Hello_sayHello__
Java_Hello_sayHello__Ljava_lang_String_2
Java_Hello_sayHello__LCallback_2I can't see what am I doing wrong, but I'm sure thats something plain that I'm missing. Code is compiled with latest Cygwin in Eclipse 3.2.2 under WinXP OS. It is runned under jre1.5.0_11.
Any help is appreciated. Thanks.

Now I commented two calls for printing on screen in C code, and left just callback call, and same error is still there:
# An unexpected error has been detected by HotSpot Virtual Machine:
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d6c79dd, pid=3656, tid=3660
# Java VM: Java HotSpot(TM) Client VM (1.5.0_11-b03 mixed mode)
# Problematic frame:
# V  [jvm.dll+0x879dd]
# An error report file with more information is saved as hs_err_pid3656.log
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#Can anyone tell me what does this mean (or how to fix my code)?
Thank you for your reply.

Similar Messages

  • App crash when using JAVA callbacks from native threads in solaris

    Hi all,
    Sorry for putting the thread here. I did use the native methods forum, I wasnt lucky. I Hope more people would look into this forum, which brings me here.
    I have a solaris application which crashes when I try to callback the JAVA methods and variables from the native code. The description of the problem is below
    Written a native library, the library is multithreaded (i.e) I create a thread using pthread_create() in the native code which performs the operation of calling a JAVA method from the native code. The routine of calling the JAVA method works perfectly elsewhere outside the new thread.
    There are two scenarios I've tested it in
    1. I created a thread (say X) from the main thread (say Y) and made the y to wait until the X is complete using the pthread_join(). The JAVA callbacks works fine when called from Y but the app crashes if done from X.
    2. Did not make the Y to wait until the X is complete, hoping that both will run paralelly and even the the App crashes.
    And to be precise the Y is the thread where the native method is called from JAVA.
    I have tested for any memory leaks or stack corruption by removing the JAVA callbacks and bulding a executable and using purify, the report doesnot hint any such occurances.
    The linker options used for building the shared library is as follows
    ${GPP} ${INC} -G ${LIB} -mt -g -lCstd -lCrun -lpthread ${OBJS} -o <lib-name>
    I wonder if we can create threads in the native code when using JAVA callbacks and even if we can whether it would be appropiate to use the callbacks with in the threads
    Looking forward for any help.
    Regards,
    Vamsi

    Guys... can't any one help me with this problem :(

  • Java callback from bpel

    As i read somewhere the type of the handle.getResult type is DOM Element...
    it gives returns java.lang.ClassCastException
    the code is the following.
    java.util.Properties props = new java.util.Properties();
    props.setProperty("orabpel.platform", "oc4j_10g");
    props.setProperty("java.naming.factory.initial", "com.evermind.server.rmi.RMIInitialContextFactory");
    props.setProperty("java.naming.provider.url", "ormi://localhost:23791/orabpel");
    props.setProperty("java.naming.security.principal", "admin");
    props.setProperty("java.naming.security.credentials", "welcome");
    com.oracle.bpel.client.Locator locator = new Locator("default","bpel",props);
    IInstanceHandle handle = locator.lookupInstance("2");
    Object res = handle.getResult();
    org.w3c.dom.Element element = (org.w3c.dom.Element)res;
    any clues as to how to get the result from an async process?

    Hello globo,
    if you have a synchronous process you simple use
    NormalizedMessage nmRet = deliveryService.request(processName, processMethod, normalizedMessage);
    nmRet.getPayload();
    And here you have the payload of your return.
    For callbacks and values from an asynchronous process have a look at clemens' blog:
    http://clemensblog.blogspot.com/2006/04/bpel-implementing-async-callback-with.html
    Greets Jens

  • Call Java Method from Callback function

    I am writing a JNI wrapper in c++ for a particular event driven DLL. The DLL makes a network connection to another device and then calls a callback function when events are raised on the device. The DLL has 3 basic functions: connect, disconnect, and registerEventListener. RegisterEventListener takes a function pointer which is called each time an event is raised on the device.
    My wrapper DLL exposes connect and disconnect functions via JNI. I can call these functions just fine from my Java code. Now the question... How do I call a Java method from my c++ callback function? I can call a Java method using env->CallXXXMethod(...) from within a function that is accessible to Java but I don't have access to the JNI parameters in my Callback function.
    So how do I call a Java method from a callback function? If this cannot be done then what is the "right way" to handle native event notification with JNI?

    jschell wrote:
    JNI parameters? Meaning what exactly?
    General outline of a callback
    1. Entry
    2. Get the VM, env - there are methods for this
    3. Attach the thread
    4. Get a java object - how depends on what you are doing, but create it or a static reference.
    5. Get the java method
    6. Call the java method.That is exactly correct. The callback function is called from a separate thread so using a cached pointer to JNIEnv, obtained from the original native method, crashes the JVM. The jmethodID and jclass objects (which are needed to call the static Java method) can be cached without problem. The following is the code I used to attach the current thread and call my static method.
    void MyClass::onEvent(int system_id, char* data)
         //get a pointer to the Java Environment
         JNIEnv *env;
         jvm->AttachCurrentThread((void **)&env, NULL);
         //Call the Java method with the newly aquired data
         jstring js = env->NewStringUTF(data);
         env->CallStaticVoidMethod(cls, mid, system_id, js);
    }My last question is about cleanup in this function. When I use NewStringUTF to "convert" my char* to jstring do I need to do anything special to clean up or will the Java garbage collector take care of it since the jstring is being passed to a Java method?
    Thanks for you help

  • CallBack Java method from C

    Hi there,
    i'm trying to write method which will call java method from C++. Problem is that i'm waiting for an event which is in separate thread. I tryed to assign JNIEnv and jobject to the glabal variable but it is seems not working, not valid for other thread. Could someone suggest another way around ?
    Regards,

    Look back through this forum - this question has been answered before.

  • Instantiate Java objects from C++ and the ability for callbacks

    I've been reading up on JNI and I've been able to
    1) load a C++ DLL and call C++ functions from Java and
    2) call Java functions from a C++ DLL.
    However, I haven't been able to find a way to pass a C++ interface class to a Java method (from a C++ DLL), where the Java method will call functions in that interface. (That is; I need to initiate the C++ DLL before any Java code is called.) I'll illustrate below if I'm unclear.
    // Java
    public class javaClass
         public void doStuff(WrapperInterface wi)
              wi.foobar();
    // C++
    class WrapperInterface
         virtual void foobar() = 0;
    class cppClass : public WrapperInterface
         virtual void foobar()
              printf("helloworld");
    int main()
         // initiate JVM, environment etc
         javaClass javaInstance;
         WrapperInterface* cppInstance = new cppClass();
         javaInstance.doStuff(cppInstance);
    }How can I accomplish this?
    I can't seem to instantiate a class in C++, that have been compiled as C++ with the javah command, so I can't instantiate it and set its initial values. (The functions are not declared as static in my Java class at least...) I can on the other hand instantiate it as a Java class. However, nothing happens when I call (from C++) the functions of the instantiated Java class.
    Also, it seems according to my tests and the documentation that I could find that you are required to use a System.LoadLibrary() from Java. Will not that make the DLL it loads load again, thus creating two instantiations of that DLL?
    As a final thought, if this is not possible with SUN's JNI, will it be possible to do with other native interfaces for Java?

    You can pass a pointer back to java by using a java long data type. You can pass that to other java native (JNI) methods and write code that casts the long back to the C++ class and then calls a class method for that class.

  • How to get the callback from an asynchronous BPEL?

    Hi, I have deployed an asynchronous BPEL on Oracle Application Server as a Web Service. The BPEL is named CreditRatingBPEL. The input is a social security number (Ssn) and the output is a credit rating.
    Now I have some troubles in consuming BPEL with Axis1.4. I have generated the client stubs by WSDL2Java tools. I have initiated the asynchronous BPEL successfully. Now I want to get the callback from the BPEL, but I don't know how to do it.Here are some Java snippets:
    public static void main(String[] args) throws ServiceException, RemoteException {
    // TODO Auto-generated method stub
    CreditRatingBPEL_Service service = new CreditRatingBPEL_ServiceLocator();
    CreditRatingBPEL_PortType requestPortType = service.getCreditRatingBPELPort();
    CreditRatingBPELProcessRequest request = new CreditRatingBPELProcessRequest();
    request.setSsn("31060931");
    // asynchronous invoke
    requestPortType.initiate(request);
    // how can I get the callback from the web service?
    I will be very appreciated if you can give me some suggestions. Best regards!

    Checkout following link -
    http://www.sapfans.com/sapfans/forum/intface/messages/4289.html
    Cheers
    Sanjeev

  • JNI Callback from remote process

    I have an application that calls back from C to Java in multiple situations. In some, I have been successful using the technique of calling AttachCurrentThread as described, for example, in various places, e.g.,
    http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jniref.html#invoke
    and recently in this forum
    http://forum.java.sun.com/thread.jspa?threadID=763205&tstart=45`
    This is an accessibility application and one of the situations I need to callback from is a global keyboard hook. In this context, I call from Java to a C DLL which sets up the keyboard hook using the standard Windows procedure SetWindowsHookEx.
          SetWindowsHookEx(    
                      WH_KEYBOARD,    // type of hook to install
                     (HOOKPROC) mykeyboardProc,    // address of hook procedure
                    ( HINSTANCE__* )hDll,    // handle of application instance
                    0     // identity of thread to install hook for  (all threds)      );The keyboard hook functions in Windows by being "injected" into running applications so that it runs in their process space and therein, apparently, lies the problem.
    The keyboard hook gets callbacks from Windows whenever a key is pressed. This is the information I want to learn about back in Java. Our current approach is to have the keyboard hook write the key data to shared memory. Then the Java application makes polling calls into the previously mentioned C DLL which checks the shared memory and returns anything it finds. The C DLL is compiled with the current MinGW compiler.
    This procedure works alright-- I can access the information using shared memory in C and polling that from Java. It is, however, a tad slow. I'd like to use a callback from C directly to eliminate the extra layer of polling. I could, of course, do the polling in the C DLL and call back to Java from there. That would eliminate a process switch every time we poll, but would still leave the polling.
    In my attempts to set up a direct callback from the keyboard hook to Java, the C code uses AttachCurrentThread using the env pointer obtained from the JNI_OnLoad method. When my application has the focus and I type, I get print statements from the C DLL and the callbacks work fine. When any other application has focus, the callback does not work and there are no print statements. In fact, the keyboard hook crashes and stops responding to any key events.
    Since I do not get print statements when another application has focus (or they go into the ether), I do not know directly whether the JNI_OnLoad function actually gets called each time the DLL is loaded into another application. However, the JVM pointer I cache in the JNI_OnLoad function is NULL when I get a key event callback (when another application has focus). I tested this by putting an "exit" call if the cached JVM was NULL in the keyboard procedure (mykeyboardProc above). When any application has focus and I type a key, that application exits. From this I assume that JNI_OnLoad is not getting called, but since the cached JVM is NULL, that is irrelevant.
    One option I have attempted is to use JNI_GetCreatedJavaVMs to get a list of the JVMs running on the machine. From this, I hoped to somehow deduce which JVM was running my application and use its pointer. However, despite putting some of the the directories` with the jvm.dll into my library path:
       g++ -I/c/Programs/Java/JDK15~1.0_0/include
           -I/c/Programs/Java/JDK15~1.0_0/include/win32
           -L/c/Programs/Java/JDK15~1.0_0/jre/bin \
           ....I get the error:
    undefined reference to `JNI_GetCreatedJavaVMs@12'
    I would be grateful for any suggestions or solutions.
    Rick

    Thanks for the reply Jim,
    I've been compiling in the Msys environment.
    I created the jvm.def and generated the jvm.a as you
    suggested.
    This apparently required copying the jvm.dll from
    /c/Programs/Java/JDK15~1.0_0/jre/bin/client
    de]
    to my working directory.  Before I did that I got a
    message
    about stripping the path components from the dll
    name.
    Then I tried to make the DLL in the fashion I had
    been:g++ -I/c/Programs/Java/JDK15~1.0_0/include \
    -I/c/Programs/Java/JDK15~1.0_0/include/win32 \
    L/c/Programs/Java/JDK15~1.0_0/jre/bin/client \
    -shared -o JKeyboardInterface.dll \     
    jvm.a \
    JKeyboardInterface_wrapper.cpp \
    JKeyboardDllMain.cpp \
    JKeyboardInterface.cpp \
    -Wl,--out-implib,libJKeyboardInterface.a \
         -Wl,--add-stdcall-alias -mno-cygwin \
    -fno-rtti -fno-exceptions -s
    This resulted in this error:
    Creating library file: libJKeyboardInterface.a
    K:/DOCUME~1/rick/LOCALS~1/Temp/ccU1daaa.o:JKeyboardInt
    erface.cpp:(.text+0xafb):
    undefined reference to
    `_imp__JNI_GetCreatedJavaVMs@12'
    collect2: ld returned 1 exit status
    Hmmmmm. What happens if you remove the '-Wl,--out-implib,libJKeyboardInterface.a'? It seems to be failing in the step creating the static lib, which may prevent the DLL from being properly created.
    Since this was a different undefined reference, I
    re-did the jmv.def step
    using imp_JNI_GetCreatedJavaVMs@12 instead of
    JNI_GetCreatedJavaVMs@12
    This generated the same error.Yeah. I'm sure I never had to do anything like that.
    >
    Then I tried to use dllwrap with both versions of the
    jvm.a generated above::
    dllwrap --driver-name=c++ \
    --add-stdcall-alias \
    -o JKeyboardInterface.dll \
           jvm.a \
           JKeyboardInterface_wrapper.cpp \
           JKeyboardDllMain.cpp \
           JKeyboardInterface.cpp \With both versions of the jvm.a, I got the error:
    K:/DOCUME~1/rick/LOCALS~1/Temp/ccSccaaa.o:JKeyboardInt
    erface.cpp:(.text+0xafb):
    undefined reference to `JNI_GetCreatedJavaVMs@12'
    ollect2: ld returned 1 exit statusI'm not clear why the two approaches (g++ -shared and
    dllwrap) yield different reference problems.
    I've read that dllwrap is "deprecated" Probably.
    (http://www.mingw.org/MinGWiki/index.php/dllwrap).
    Do you have any other suggestions about how to do
    this?Have a look at:
    http://www.inonit.com/cygwin/
    Msys (which is Mingw) follows cygwin pretty closely.
    I'm not near a Windows machine to try this at the moment. All I can say is that I have an application using CreateJavaVM, compiled with MSYS and it works. CreateJavaVM has the same problems as GetCreatedJavaVMs that you are seeing. The root cause is that the jvm.lib shipped with the JDK for Windows is not compatible with GCC. Hence the need to create the jvm.a library.
    I build my code using an ANT script. It build the objects first and then links them. Deciphering the build script, it looks like the two steps would have the following command line syntax:
    Compile to object files:
    gcc -D REENTRANT -I <paths to include> somefiles.cpp somefiles.c
    (I have a mix of C and C++)
    Link object files to create DLL:
    gcc -shared -D REENTRANT --kill-at -lstdc++ somefiles.o jvm.a
    Try it in two steps and see if it makes a difference.
    >
    Is trying to use GetCreatedJavaVMs the correct
    approach here?
    If more than one exists, how do I determine which one
    I want to attach to and get an env pointer for?From you original post, it is difficult to understand exactly what you are trying to achieve.
    It seems like you are starting with a Java app that calls into some native code to create the keyboard hook. This hook will then call a callback method in native code when a key is pressed. You want the Java code to see this and act appropriately.
    In Java callbacks are usually handled with events. Just have your native code fire an event in Java and have a Listener on the Java side. I do this in some of my code. Say I have an event called FooEvent and a listener called FooListener. There is also an object called Bar which can fire FooEvents and have FooListeners attached to it. The Bar class has an addFooListener() method which is actually a native method. The native implementation sets up the callback stuff on the native side. When an event occurs on the native side, the callback function is called and it does something like this:
    jclass cls;
    jmethodID mid;
    cls = env->GetObjectClass(javaSource);
    mid = env->GetMethodID(cls, "fireSomeEvent", "()V");
    env->CallVoidMethod(javaSource, mid);In the code above, the 'cls' variable would be the Bar class object and the 'javaSource' variable is a global reference ot the Bar object to which the event listener was added. The 'env' variable is acquired by calling 'AttachCurrentThread' on a cached JavaVM pointer stored in a global reference.
    The Bar class has a fireSomeEvent() method, which calls the event listeners using the event generator idiom:
    http://www.javaworld.com/javaworld/jw-09-1998/jw-09-techniques.html
    The listener on the Java side gets notification when the event occurs and you can take the appropriate action. No polling, no shared memory.
    Jim S.

  • Test waits forever for a callback from a human task

    Hi,
    I've create a test to test a BPEL process. Now within the BPEL process there is a call to a human task service. I've emulated the task initiation message which is fine. I also tried to emulate the receive message from the human task service but during the test execution, the test waits forever to receive the callback from the human task service, even though i've specified the return message. Would appreciate help with this! I've posted my testbpel.bpel and the test case (CreditCardInvalidTest.xml) below. For both these files I've highlighted in bold the relevant bits of code that's giving me problems. Thanks
    testbpel.bpel:
    <?xml version = "1.0" encoding = "UTF-8" ?>
    <process name="testbpel" targetNamespace="http://xmlns.oracle.com/testbpel"
    xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:wfcommon="http://xmlns.oracle.com/bpel/workflow/common"
    xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/"
    xmlns:xp20="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.Xpath20"
    xmlns:ns4="http://www.oracle.com/XSL/Transform/java/oracle.tip.xref.xpath.XRefXPathFunctions"
    xmlns:ns7="http://xmlns.oracle.com/testbpel/creditFault"
    xmlns:ldap="http://schemas.oracle.com/xpath/extension/ldap"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wf="http://schemas.oracle.com/bpel/extension/workflow"
    xmlns:ns5="http://oracle.com/esb/namespaces/Fufillment"
    xmlns:client="http://xmlns.oracle.com/testbpel"
    xmlns:ns6="http://www.creditcardagency.com/CreditCardService"
    xmlns:ora="http://schemas.oracle.com/xpath/extension"
    xmlns:taskservice="http://xmlns.oracle.com/bpel/workflow/taskService"
    xmlns:ns9="http://xmlns.oracle.com/testbpel/orderRejected"
    xmlns:ns1="http://xmlns.oracle.com/bpel/workflow/xpath"
    xmlns:ns3="http://www.oracle.com/XSL/Transform/java/oracle.tip.esb.server.headers.ESBHeaderFunctions"
    xmlns:ns2="http://xmlns.oracle.com/bpel/services/IdentityService/xpath"
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    xmlns:task="http://xmlns.oracle.com/bpel/workflow/task"
    xmlns:orcl="http://www.oracle.com/XSL/Transform/java/oracle.tip.pc.services.functions.ExtFunc"
    xmlns:ns8="http://xmlns.oracle.com/testbpel/genericFault">
    <!--
    PARTNERLINKS
    List of services participating in this BPEL process
    -->
    <partnerLinks>
    <!--
    The 'client' role represents the requester of this service. It is
    used for callback. The location and correlation information associated
    with the client role are automatically set using WS-Addressing.
    -->
    <partnerLink name="client" partnerLinkType="client:testbpel"
    myRole="testbpelProvider" partnerRole="testbpelRequester"/>
    <partnerLink name="ShipmentService" partnerRole="execute_pptProvider"
    partnerLinkType="ns5:execute_pptLT"/>
    <partnerLink name="CreditCardService"
    partnerRole="CreditCardServiceProvider"
    partnerLinkType="ns6:CreditCardService"/>
    <partnerLink myRole="TaskServiceCallbackListener" name="TaskService"
    partnerRole="TaskService"
    partnerLinkType="taskservice:TaskService"/>
    </partnerLinks>
    <!--
    VARIABLES
    List of messages and XML documents used within this BPEL process
    -->
    <variables>
    <!-- Reference to the message passed as input during initiation -->
    <!-- Reference to the message that will be sent back to the requester during callback -->
    <variable name="inputVariable"
    messageType="client:testbpelRequestMessage"/>
    <variable name="outputVariable"
    messageType="client:testbpelResponseMessage"/>
    <variable name="n" type="xsd:integer"/>
    <variable name="Invoke_ShipmentService_execute_InputVariable"
    messageType="ns5:orderRequest_request"/>
    <variable name="paymentFault"
    messageType="client:testbpelFaultMessage"/>
    <variable name="ApproveOrder_1_globalVariable"
    messageType="taskservice:taskMessage"/>
    <variable name="orderRejectedFault"
    messageType="client:testbpelFaultMessage"/>
    </variables>
    <faultHandlers>
    <catchAll>
    <sequence name="Sequence_6">
    <throw name="Throw_AllFaults"
    faultName="ns8:testbpelGenericFault"
    faultVariable="paymentFault"/>
    </sequence>
    </catchAll>
    </faultHandlers>
    <!--
    ORCHESTRATION LOGIC
    Set of activities coordinating the flow of messages across the
    services integrated within this business process
    -->
    <sequence name="main">
    <!-- Receive input from requestor. (Note: This maps to operation defined in testbpel.wsdl) -->
    <receive name="receiveInput" partnerLink="client"
    portType="client:testbpel" operation="initiate"
    variable="inputVariable" createInstance="yes"/>
    <!--
    Asynchronous callback to the requester. (Note: the callback location and correlation id is transparently handled using WS-addressing.)
    -->
    <scope name="CheckForApproval">
    <sequence name="Sequence_4">
    <sequence name="Sequence_5">
    <scope name="ApproveOrder_1"
    xmlns:wf="http://schemas.oracle.com/bpel/extension/workflow"
    wf:key="ApproveOrder_1_globalVariable">
    <bpelx:annotation>
    <bpelx:pattern patternName="bpelx:workflow"></bpelx:pattern>
    </bpelx:annotation>
    <variables>
    <variable name="initiateTaskInput"
    messageType="taskservice:initiateTaskMessage"/>
    <variable name="initiateTaskResponseMessage"
    messageType="taskservice:initiateTaskResponseMessage"/>
    </variables>
    <correlationSets>
    <correlationSet name="WorkflowTaskIdCor"
    properties="taskservice:taskId"/>
    </correlationSets>
    <sequence>
    <assign name="ApproveOrder_1_AssignTaskAttributes">
    <copy>
    <from expression="concat(ora:getProcessURL(), string('/ApproveOrder/ApproveOrder.task'))"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:taskDefinitionURI"/>
    </copy>
    <copy>
    <from expression="number(3)"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:priority"/>
    </copy>
    <copy>
    <from>
    <payload xmlns="http://xmlns.oracle.com/bpel/workflow/task"/>
    </from>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:payload"/>
    </copy>
    </assign>
    <assign name="ApproveOrder_1_AssignSystemTaskAttributes">
    <copy>
    <from expression="ora:getInstanceId()"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:processInfo/task:instanceId"/>
    </copy>
    <copy>
    <from expression="ora:getProcessId()"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:processInfo/task:processName"/>
    </copy>
    <copy>
    <from expression="ora:getProcessId()"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:processInfo/task:processId"/>
    </copy>
    <copy>
    <from expression="ora:getProcessVersion()"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:processInfo/task:processVersion"/>
    </copy>
    <copy>
    <from expression="ora:getDomainId()"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:processInfo/task:domainId"/>
    </copy>
    <copy>
    <from expression="string('BPEL')"/>
    <to variable="initiateTaskInput"
    part="payload"
    query="/taskservice:initiateTask/task:task/task:processInfo/task:processType"/>
    </copy>
    </assign>
    <invoke name="initiateTask_ApproveOrder_1"
    partnerLink="TaskService"
    portType="taskservice:TaskService"
    operation="initiateTask"
    inputVariable="initiateTaskInput"
    outputVariable="initiateTaskResponseMessage">
    <correlations>
    <correlation initiate="yes"
    set="WorkflowTaskIdCor"
    pattern="in"/>
    </correlations>
    </invoke>
    *<receive name="receiveCompletedTask_ApproveOrder_1"*
    partnerLink="TaskService"
    portType="taskservice:TaskServiceCallback"
    operation="onTaskCompleted"
    variable="ApproveOrder_1_globalVariable"
    createInstance="no">
    *<correlations>*
    *<correlation initiate="no"*
    set="WorkflowTaskIdCor"/>
    *</correlations>*
    *</receive>* </sequence>
    </scope>
    <switch name="taskSwitch">
    <case condition="bpws:getVariableData('ApproveOrder_1_globalVariable', 'payload', '/task:task/task:systemAttributes/task:state') = 'COMPLETED' and bpws:getVariableData('ApproveOrder_1_globalVariable', 'payload', '/task:task/task:systemAttributes/task:outcome') = 'REJECT'">
    <bpelx:annotation>
    <bpelx:pattern patternName="case">Task outcome is REJECT</bpelx:pattern>
    </bpelx:annotation>
    <sequence>
    <assign name="AssignOrderRejected">
    <copy>
    <from expression="string('Order rejected by manager')"/>
    <to variable="paymentFault"
    part="payload"
    query="/client:testbpelProcessFault/client:status"/>
    </copy>
    </assign>
    <throw name="ThrowOrderRejected"
    faultName="ns9:orderRejectedFault"
    faultVariable="orderRejectedFault"/>
    </sequence>
    </case>
    <case condition="bpws:getVariableData('ApproveOrder_1_globalVariable', 'payload', '/task:task/task:systemAttributes/task:state') = 'COMPLETED' and bpws:getVariableData('ApproveOrder_1_globalVariable', 'payload', '/task:task/task:systemAttributes/task:outcome') = 'APPROVE'">
    <bpelx:annotation>
    <bpelx:pattern patternName="case">Task outcome is APPROVE</bpelx:pattern>
    </bpelx:annotation>
    <sequence>
    <empty name="Empty_1"/>
    </sequence>
    </case>
    <otherwise>
    <bpelx:annotation>
    <bpelx:pattern>Task is outcome is EXPIRED, STALE, WITHDRAWN or ERRORED</bpelx:pattern>
    </bpelx:annotation>
    <sequence>
    <empty name="Empty_2"/>
    </sequence>
    </otherwise>
    </switch>
    </sequence>
    </sequence>
    </scope>
    <scope name="CheckCreditCard">
    <variables>
    <variable name="InvokeCreditCardService_process_InputVariable"
    messageType="ns6:CreditCardServiceRequestMessage"/>
    <variable name="InvokeCreditCardService_process_OutputVariable"
    messageType="ns6:CreditCardServiceResponseMessage"/>
    </variables>
    <sequence name="Sequence_2">
    <assign name="Assign_1">
    <copy>
    <from variable="inputVariable" part="payload"
    query="/client:testbpelProcessRequest/client:CreditCardNumber"/>
    <to variable="InvokeCreditCardService_process_InputVariable"
    part="payload"
    query="/ns6:CreditCardServiceProcessRequest/ns6:CreditCardNumber"/>
    </copy>
    </assign>
    <scope name="Scope_1">
    <compensationHandler>
    <sequence name="Sequence_7">
    <empty name="Empty_3"/>
    </sequence>
    </compensationHandler>
    <invoke name="InvokeCreditCardService"
    partnerLink="CreditCardService"
    portType="ns6:CreditCardService" operation="process"
    inputVariable="InvokeCreditCardService_process_InputVariable"
    outputVariable="InvokeCreditCardService_process_OutputVariable"/>
    </scope>
    <switch name="CheckCreditCardValid">
    <case condition="bpws:getVariableData('InvokeCreditCardService_process_OutputVariable','payload','/ns6:CreditCardServiceProcessResponse/ns6:result') = 'false'">
    <sequence name="Sequence_3">
    <assign name="AssignCreditFault">
    <copy>
    <from expression="string('Invalid credit card number')"/>
    <to variable="paymentFault" part="payload"
    query="/client:testbpelProcessFault/client:status"/>
    </copy>
    </assign>
    <throw name="ThrowCreditFault"
    faultName="ns7:CreditCardNumberFault"
    faultVariable="paymentFault"/>
    </sequence>
    </case>
    </switch>
    </sequence>
    </scope>
    <assign name="AssignInitial">
    <copy>
    <from expression="string('Select Manufacturer')"/>
    <to variable="outputVariable" part="payload"
    query="/client:testbpelProcessResponse/client:result"/>
    </copy>
    <copy>
    <from expression="1"/>
    <to variable="n"/>
    </copy>
    <copy>
    <from expression="0.0"/>
    <to variable="outputVariable" part="payload"
    query="/client:testbpelProcessResponse/client:price"/>
    </copy>
    </assign>
    <while name="While_1"
    condition="bpws:getVariableData('n') &lt;= count(bpws:getVariableData('inputVariable','payload','/client:testbpelProcessRequest/client:input'))">
    <sequence name="Sequence_1">
    <assign name="DoCalculation">
    <copy>
    <from expression="bpws:getVariableData('inputVariable','payload', concat('/client:testbpelProcessRequest/client:input[', bpws:getVariableData('n'), ']/client:quantity')) * bpws:getVariableData('inputVariable','payload',concat('/client:testbpelProcessRequest/client:input[', bpws:getVariableData('n'), ']/client:bookPrice')) + bpws:getVariableData('outputVariable','payload','/client:testbpelProcessResponse/client:price')"/>
    <to variable="outputVariable" part="payload"
    query="/client:testbpelProcessResponse/client:price"/>
    </copy>
    <copy>
    <from expression="bpws:getVariableData('n') + 1"/>
    <to variable="n"/>
    </copy>
    </assign>
    </sequence>
    </while>
    <assign name="Transform_2">
    <bpelx:annotation>
    <bpelx:pattern>transformation</bpelx:pattern>
    </bpelx:annotation>
    <copy>
    <from expression="ora:processXSLT('TransformOrder.xsl',bpws:getVariableData('inputVariable','payload'))"/>
    <to variable="Invoke_ShipmentService_execute_InputVariable"
    part="orderRequest"/>
    </copy>
    </assign>
    <invoke name="Invoke_ShipmentService" partnerLink="ShipmentService"
    portType="ns5:execute_ppt" operation="execute"
    inputVariable="Invoke_ShipmentService_execute_InputVariable"/>
    <invoke name="callbackClient" partnerLink="client"
    portType="client:testbpelCallback" operation="onResult"
    inputVariable="outputVariable"/>
    </sequence>
    </process>
    CreditCardInvalidTest.xml:
    <?xml version='1.0' encoding='utf-8'?>
    <BPELTest processName="testbpel"
    xmlns="http://xmlns.oracle.com/bpel/instancedriver"
    xmlns:client="http://xmlns.oracle.com/testbpel">
    <initiate operation="initiate">
    <inboundMessage>
    <part fileName="testInput.xml" name="payload"/>
    </inboundMessage>
    </initiate>
    <activityDriver name="callbackClient">
    <assertValue variableName="outputVariable" partName="payload"
    comparisonMethod="string" fatal="false" patternMatch="false">
    <message>Expected "Select Manufacturer"</message>
    <actualPath>/client:testbpelProcessResponse/client:result</actualPath>
    <expected>Select Manufacturer</expected>
    </assertValue>
    <assertValue variableName="outputVariable" partName="payload"
    comparisonMethod="string" fatal="true" patternMatch="false">
    <message>Expected price of "1"</message>
    <actualPath>/client:testbpelProcessResponse/client:price</actualPath>
    <expected>1</expected>
    </assertValue>
    </activityDriver>
    *<activityDriver name="receiveCompletedTask_ApproveOrder_1">*
    *<emulate duration="PT">*
    *<inboundMessage>*
    *<part fileName="approverResponse.xml" name="payload"/>*
    *</inboundMessage>*
    *</emulate>*
    *</activityDriver>* <activityDriver name="InvokeCreditCardService">
    <emulate duration="PT">
    <inboundMessage>
    <part fileName="creditCardServiceResponse.xml" name="payload"/>
    </inboundMessage>
    </emulate>
    </activityDriver>
    <activityDriver name="initiateTask_ApproveOrder_1">
    <emulate duration="PT">
    <inboundMessage>
    <part fileName="getApproval.xml" name="payload"/>
    </inboundMessage>
    </emulate>
    </activityDriver>
    </BPELTest>

    Hi hi, on a hunch I previewed the page in the browser, and copy pasted the faces/untitled1 portion of the URL there and pasted on the http://<server_address>:8001/BasicAPPDemo_Root therefore ending with http://<server_address>:8001/BasicAPPDemo_Root/faces/untitled1 and lo and behold I saw the little text box saying "Hello World" ;D
    So with that i escalated, switched to the application where the page from BPM was located, deployed it and did the same trick.
    But it borked it gave this error:
    JBO-29115 Unable to construct the error message due to error java.lang.NullPointerException. Use the exception stack trace and error code to investigate the root cause of this exception. Root cause error code is JBO-.
    I figured that the Default generation could be faulty so i created a new page and only recycled the data controls, created everything in read mode, just to test and deployed, when i tested, i was optimistic as the 1st tab didn't had any error (also does not have anything related to the HumanTask, even the data controls) the problem was in the other tabs as I show here.
    Many thanks sirs, and sorry for wasting thy time.

  • Error implementing dynamic callback from BPEL process

    Hi,
    I am trying to use dynamic callback from a BPEL process..
    Created a variable of type EndpointReference by importing the ws-addressing.xsd. in the partnerlink wsdl..
    I assigned the URL to the variable's address field ...
    <copy>
    <from expression="'http://172.31.171.123:8888/PubSubWLPOC-CallbackSvc2-context-root/EIPWFServiceCallbackPort'"/>
    <to variable="ep_var" query="/ns3:EndpointReference/ns3:Address"/>
    </copy>
    Gives no error till now...
    But when I try to assign the same variable to the partnerlink, I get an error..
    <assign name="Assign_7">
    <copy>
    <from variable="ep_var"/>
    <to partnerLink="MyWebService1"/>
    </copy>
    </assign>
    The error is like this(from the $SOA_HOME\bpel\domains\default\logs) :-
    java.lang.NullPointerException
    at com.collaxa.cube.engine.types.bpel.CXPartnerLink.copy(CXPartnerLink.java:246)
    at com.collaxa.cube.engine.ext.wmp.BPELAssignWMP.performCopyTo(BPELAssignWMP.java:1151)
    at com.collaxa.cube.engine.ext.wmp.BPELAssignWMP.__executeStatements(BPELAssignWMP.java:215)
    at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:199)
    at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3698)
    at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1655)
    at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75)
    at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:217)
    at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:314)
    at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5765)
    at com.collaxa.cube.engine.CubeEngine.callbackPerformer(CubeEngine.java:1885)
    at com.collaxa.cube.engine.delivery.DeliveryHelper.callbackPerformer(DeliveryHelper.java:845)
    at com.collaxa.cube.engine.delivery.DeliveryService.handleCallback(DeliveryService.java:794)
    at com.collaxa.cube.engine.ejb.impl.CubeDeliveryBean.handleCallback(CubeDeliveryBean.java:378)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    The confusing part is when I use xml fragment instead of the variable ep_var, it works fine ...
    But I cannot use the same as the callback can be made to any url(which is decided on runtime)
    Can someone pls help me with this ?
    saptarishi

    Hi,
    I have done following for dynamic call back and it works..
    <copy>
    <from>
    <_EndpointReference xmlns="http://schemas.xmlsoap.org/ws/2003/03/addressing">
    <Address/>
    </EndpointReference>
    </from>
    <to variable="EndpointUrl"/>
    </copy>
    <copy>
    In the above assignment from part is an xml fragment assigned to Endpoint Url
    <copy>
    <from expression="'http://172.31.171.123:8888/PubSubWLPOC-CallbackSvc2-context-root/EIPWFServiceCallbackPort'"/>
    <to variable="ep_var" query="/ns3:EndpointReference/ns3:Address"/>
    </copy>
    </copy>
    <copy>
    <from variable="EndpointUrl"/>
    <to partnerLink="SFDC_plt"/>
    </copy>

  • Java callouts from bpel  - 11g

    I had Oracle Soa Suite 10.1.3 with Toplink/WSIF. I used to generate classes using bpel/schemac and place them in systems/classes directory.
    But we migrated to Oracle Soa suite 11g. In 11g we don't see bpel folder. Are there any examples to handle the above in 11g?
    Questions are:
         Where is schemac located?
         Where should the generated classes go?
         How can I use java callouts from bpel?
         Where can I examples?

    Hello globo,
    if you have a synchronous process you simple use
    NormalizedMessage nmRet = deliveryService.request(processName, processMethod, normalizedMessage);
    nmRet.getPayload();
    And here you have the payload of your return.
    For callbacks and values from an asynchronous process have a look at clemens' blog:
    http://clemensblog.blogspot.com/2006/04/bpel-implementing-async-callback-with.html
    Greets Jens

  • Calling Java methods from C program

    After a year or so using these excellent forums to answer my queries, without ever having to post a question, I've finally had to ask for help with this one. I've already looked through the JNI tutorial, and these forums, extensively, but I'm still not quite sure of how best to solve my problem.
    I need to call Java methods from a C program. I've already used JNI to call a simple C program from Java, and that's fine, but I just can't determine exactly what I need to do for the reverse to work.
    What is the definitive solution for calling Java from C? Is it to use the invocation APIs to create a JVM, and then access it through the various GetMethod, FindClass methods? Or can I 'reverse engineer' the process I followed to get Java to call C?? The tutorial is a bit confusing, as the example it gives uses Callback stuff, but I guess that's only useful when you want to go Java-C-Java??
    Advice appreciated,
    Rich

    Forgive my blatant bumping, but anyone, please?

  • Reading Java files from a EAR file

    I want to read all Java files from a EAR file and from inner (inside EAR) EAR or WAR file with out unpacking.
    suppose "Demo.ear" contaions the following files:
    abc.java
    programs / a.java
    programs / b.java
    src / index.java
    src / com / myFolder / main.java
    src.war
    and suppose "src.war" again contains some java files inside differenet folders.
    The main problem is that i can read all java files from "Demo.ear" but unable to reading from "src.war" b'coz my program is using JarFile class constructor which needs a archive file path, So only top level archive having the path but not the inner archives.
    So, pls help me out to this problems
    Thanks in advance

    Maybe you can use java.util.zip.ZipInputStream to
    open the Ear and recursively to open the files in
    it; I'm not sure whether this will result in a full
    unpacking of the file in some temporary directory,
    though.
    Please let me know if it worked the way you wanted,
    I'm curious about it.This jerk just created the third thread about the same topic, because he didn't understand your suggestion, which I already provided earlier.
    http://forum.java.sun.com/thread.jspa?threadID=790015

  • How to reference multiple instances of the same Java object from PL/SQL?

    Dear all,
    I'm experimenting with calling Java from PL/SQL.
    My simple attempts work, which is calling public static [java] methods through PL/SQL wrappers from SQL (and PL/SQL). (See my example code below).
    However it is the limitation of the public static methods that puzzels me.
    I would like to do the following:
    - from PL/SQL (in essence it needs to become a forms app) create one or more objects in the java realm
    - from PL/SQL alter properties of a java object
    - from PL/SQL call methods on a java object
    However I fail to see how I can create multiple instances of an object and reference one particular object in the java realm through public static methods.
    My current solution is the singleton pattern: of said java object I have only 1 copy, so I do not need to know a reference to it.
    I can just assume that there will only ever be 1 of said object.
    But I should be able to make more then 1 instance of an object.
    To make it more specific:
    - suppose I have the object car in the java realm
    - from PL/SQL I want to create a car in the java realm
    - from PL/SQL I need to give it license plates
    - I need to start the engine of a scpecific car
    However if I want more then 1 car then I need to be able to refrence them. How is this done?
    Somehow I need to be able to execute the following in PL/SQL:
    DECLARE
    vMyCar_Porsche CAR;
    vMyCar_Fiat CAR;
    BEGIN
    vMyCar_Porsche = new CAR();
    vMyCar_Fiat = new CAR();
    vMyCar_Porsche.setLicensePlates('FAST');
    vMyCar_Porsche.startEngine();
    vMyCar_Fiat.killEngine();
    END;
    Thanks in advance.
    Best Regards,
    Ruben
    My current example code is the following:
    JAVA:
    ===
    CREATE OR REPLACE AND RESOLVE JAVA SOURCE NAMED CODAROUL."RMG/BO/RMG_OBJECT" as package RMG.BO;
    public class RMG_OBJECT {
    private static RMG_OBJECT instance = new RMGOBJECT();
    private String rmgObjectNaam;
    private RMG_OBJECT(){
    this.rmgObjectNaam = "NonDetermined";
    public static String GET_RMGOBJECT_NAAM () {
    String toestand = null;
    if (_instance == null) {toestand = "DOES NOT EXIST";} else { toestand = "EXISTS";};
    System.out.println("instance : " + toestand);
    System.out.println("object name is : " + _instance.rmgObjectNaam);
    return _instance.rmgObjectNaam;
    public static Integer SET_RMGOBJECT_NAAM (String IN)
    try
    _instance.rmgObjectNaam = IN;
    return 1;
    catch (Exception e)//catch
    System.out.println("Other Exception: " + e.toString());
    e.printStackTrace();
    return 5;
    } //catch
    PL/SQL Wrapper:
    ==========
    CREATE OR REPLACE FUNCTION CODAROUL.SET_RMGOBJECT_NAAM(NAAM IN VARCHAR2) return NUMBER AS
    LANGUAGE JAVA NAME 'RMG.BO.RMG_OBJECT.SET_RMGOBJECT_NAAM (java.lang.String) return java.lang.Integer';
    Calling from SQL:
    ==========
    CALL dbms_java.set_output(2000);
    select CODAROUL.GET_RMGOBJECT_NAAM() from dual;
    Edited by: RubenS_BE on Apr 6, 2012 5:35 AM
    Edited by: 925945 on Apr 6, 2012 5:41 AM

    You can do this by manually creating a new iterator binding in your binding tab.
    So instead of dragging the VO directly to the page, go to the binding tab, add a new executable iterator binding, and point to that one from your ELs in the page itself.

  • Is there an easy way to call a java class from an applet?

    Does anyone know of an easy way to call a server based java class from an applet? Has anyone done it or came across it? If yes how/where?
    Cheers, Chris.

    I'm not sure about the issue. Are you talking about "servelets"? "RMI"? Take a look at those issues.

Maybe you are looking for

  • How do I put back my boyfriend's preferences on his side of this DELL optiplex 330?

    I had been getting potential problem results from every recent scan with Malwarebytes. I Searched using Windows Explorer. I could not find the exact letters at the end of the items that were on the scan results. I found items that had the first few "

  • GRC AC 5.3

    Is there any option or report in GRC AC tools which will show that there was a risk and it has been mitigated and who has mitigated the risk.

  • KB2918614 Breaks MDT2012 Update 1 Task Sequence "Install Application" Items on Windows 7 deployments

    Consider the following scenario: You have a WDS deployment environment for your enterprise running on Windows Server 2008 R2. You use MDT 2012 Update 01 to create a Windows 7 Task Sequence for workstation deployment.  The task sequence has an "Instal

  • Any way to search a particular forum?

    I suppose I should know this by now... I can't find a way to search a particular forum. I do see the "Search Communities" in the upper right, but it is too broad. Example: Right now I'm trying to search the Pages forum for information about the forma

  • Point-n-Shoot Videos in Gallery via iPhoto

    I uploaded my first video into my Gallery today using iPhoto. I had recorded the video using my point-n-shoot digital camera and uploaded it to the Gallery via iPhoto. I was dissappointed that the Gallery placed the movie into a photo album instead o