logancillo wrote:
hi Dave, thx for your response!

i build again xalan-c and xerces-c from sources generating libxalanc.so and
libxercesc.so, copied into /usr/lib and linked in my c project, and it
worked! well, almost! ;)

this is implementation code:
This is not a Java development newsgroup, so this is not the appropriate forum for questions about JNI. I suggest you get your code working outside of the JNI environment first, then attempt to integrate it.


JNIEXPORT void JNICALL
Java_es_yell_frontlite_mvc_View_RenderizarVistaXalanC_renderView
  (JNIEnv *env, jobject obj, jstring xml, jstring xsl) {

    XALAN_USING_STD(cout)
    XALAN_USING_STD(endl)
    cout<<"what the fuck!, joder, vamos avanzando!!!!!"<<endl;

    jboolean blnIsCopy;

    XALAN_USING_STD(cerr)
    //XALAN_USING_STD(cout)
    //XALAN_USING_STD(endl)
    XALAN_USING_STD(istrstream)
    XALAN_USING_STD(ofstream)
    XALAN_USING_STD(ostrstream)
#if defined(XALAN_STRICT_ANSI_HEADERS)
        using std::strlen;
    #endif
XALAN_USING_XERCES(XMLPlatformUtils)

    XALAN_USING_XALAN(XalanTransformer)

    // Call the static initializer for Xerces.

    XMLPlatformUtils::Initialize();

    // Initialize Xalan.
    XalanTransformer::initialize();

    // Create a XalanTransformer.
    XalanTransformer theXalanTransformer;
You need to make sure all Xalan-C and Xerces-C objects are destroyed before you call XalanTransformer::terminate() and XMLPlatformUtils::Terminate(). In the case, you are creating a XalanTransformer instance on the stack, which will not go out of scope until the end of the block. Since you terminate Xalan-C and Xerces-C _before_ the end of the block, your application will likely crash.

The easiest way to work around this is to add an extra scope:

    // Initialize Xalan.
    XalanTransformer::initialize();

    {
        // Create a XalanTransformer.
        XalanTransformer theXalanTransformer;

        ...
    }

    XalanTransformer::terminate();

    XMLPlatformUtils::Terminate();

    const char* const  theInputXmlDocument
=env->GetStringUTFChars(xml,&blnIsCopy);
//printf("datos en bruto\n: %s\n",theInputXmlDocument);

    const char* const theInputXslDocument =
env->GetStringUTFChars(xsl,&blnIsCopy);
//printf("plantilla xsl\n: %s\n",theInputXslDocument);
    // Our input streams...
    istrstream  theXMLStream(theInputXmlDocument,
strlen(theInputXmlDocument));
istrstream theXSLStream(theInputXslDocument,
strlen(theInputXslDocument));
XALAN_USING_XALAN(XalanDOMString)
    XALAN_USING_XALAN(XSLTInputSource)

    XSLTInputSource             inputSource(&theXSLStream);

    inputSource.setSystemId(XalanDOMString("foo").c_str());
// Do the transform.
    int theResult = theXalanTransformer.transform(&theXMLStream,
inputSource, cout);
if(theResult != 0)
    {
        cerr << "StreamTransform Error: \n" <<
theXalanTransformer.getLastError()
        << endl
        << endl;
    }
// Terminate Xalan...
    XalanTransformer::terminate();
if i put this two terminate sentences together, it will crash with jvm
panic! if i put only one, everything ok! would you explain me whats happening?

// Terminate Xerces...
    XMLPlatformUtils::Terminate();
    // Clean up the ICU, if it's integrated...
    //XalanTransformer::ICUCleanUp();
    cout<<"hasta aqui bien, seguimos!!"<<endl;
}


#
# An unexpected error has been detected by Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0xb7f6c162, pid=8475, tid=3043253136
#
# Java VM: Java HotSpot(TM) Client VM (10.0-b19 mixed mode, sharing
linux-x86)
# Problematic frame:
# C  [libc.so.6+0x13e162]
#
# An error report file with more information is saved as:
# /usr/local/apache-tomcat-6.0.14/bin/hs_err_pid8475.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

this is log output
Please don't post this much to the list, unless someone explicitly asks for it.

Dave

Reply via email to