You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by suresh <su...@vergiltech.com> on 2001/12/03 06:38:51 UTC

problem Mulithreading(xerces1.5.2)

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_ACCESS_VIOLATION
thrown when i try
to parse the contents passed in from java.
the same app runs fine if its singlethreaded.

iam using xerces1.5.2 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();

    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;

   -------------------------------------------------
	I have the exception thrown in the next step                        
   -------------------------------------------------              	                      


    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: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org