hi ,

        I have a JNI application running on PIII win2000.The java application loads
a runtime vc dll that parses the content.This   app is multithreaded in the
sense it loads the dll for each thread.I have an exception thrown when i try
to parse the contents passed in from java.
the same app runs fine if its singlethreaded.

iam using xerces1.5.0 and SAX parser (the dll built is a mulithreaded dll)


NATIVE call

JNIEXPORT void JNICALL Java_Dispatcher_cppParser
  (JNIEnv * m_environment, jobject jobj, jstring m_jxmlData)
{   
    cout<<"here..."<<endl;
    m_environment->MonitorEnter(jobj);
    jclass cls = m_environment->GetObjectClass(jobj);
    jfieldID memberId = m_environment->GetFieldID(cls, "ptr", "I");
    XMLParser* objParser = (XMLParser*) m_environment->GetIntField(jobj,memberId);
    const char* m_xmlData = m_environment->GetStringUTFChars(m_jxmlData, 0);
    MessageFormat objMessageFormat;
    objMessageFormat.setpptName(m_xmlData);
    m_xmlData  = (objMessageFormat.getXmlData()).c_str();

   -------------------------------------------------
        exception thrown in the next step
-----------------------------------------------------

    objMessageFormat = objParser->parse(m_xmlData); 
    m_environment->MonitorExit(jobj);
}

/* PARSE METHOD*/

MessageFormat XMLParser::parse(string strParseBuffer) 
{

        try {
        XMLPlatformUtils::Initialize();
    }
    catch (const XMLException& toCatch) {
        cout << "Error during initialization! :\n"
             << toCatch.getMessage() << "\n";
    }
    
        SAXParser::ValSchemes    valScheme = SAXParser::Val_Auto;
    bool doNamespaces    = false;
    bool doSchema        = false;
    m_parser = XMLReaderFactory::createXMLReader();
        
    XmlFunctionHandler m_Handler;

        m_parser->setContentHandler(&m_Handler);
        m_parser->setLexicalHandler(&m_Handler);
    m_parser->setErrorHandler(&m_Handler);

        m_DataBuf = strParseBuffer.c_str();

        m_ParseBuf = new MemBufInputSource (
                (const XMLByte*)m_DataBuf
        ,strlen(m_DataBuf)
        ,m_MemBufId
        ,true
    );


    try {
       
                m_parser->parse(*m_ParseBuf);
        
                }
    catch (const XMLException& toCatch) {
        cout << "\nFile not found: '" <<"'\n"
             << "Exception message is: \n"
             << toCatch.getMessage() << "\n" ;
    }
         catch (...)
    {
        cerr << "\nUnexpected exception during parsing: '"<< "'\n";
        XMLPlatformUtils::Terminate();
    }
  
        m_objMessageFormat = m_Handler.getMessageFormat();

    return m_objMessageFormat; 

}    


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to