webservice crashed? HTTP/1.0 500 Internal Server Error

User 1a3b6cd85b

05-03-2010 05:26:10

It appears after several SOAP calls into the JChemSearch web service,  the axis2 webserver will eventually respond back with an internal server error. It seems the application server has to be restarted to get things functional again.


Is there a "proper" way to clean up after SOAP calls via php? I am wondering if there is possibly a memory leak?


Also, please confirm where the  license.cxl should be placed for the webservice. I am wondering if the below noted failure is possibly a result of a license issue (perhaps restricting the number of calls).


Looping over several different values for $smi in a php file:


$maxhits=20;


$soap = new SoapClient('http://myserver.com:8180/axis2/services/JChemSearchWS?wsdl');


 


$conn_param = array( 'driver' => 'com.mysql.jdbc.Driver',


                     'url' => 'jdbc:mysql://myserver.com/mysqlDb',


                     'username' => 'myusername',


                     'password' => 'mypassword',


                     'propertyTable' => 'JChemProperties');  


 


 


$result= strip_tags($soap->getConnectionAndTableInfo($conn_param)->return);


$id=substr($result,0,strpos($result,"\n"));


 $search_param = array(  'connectionHandlerId' => $id,


 


                        'tableName' => 'jchemmol',


                        'queryMolecule' => $smi,


                        'queryOptions' => 'sep=! t:s!maxHitCount:0!maxTime:60000!returnNonHits:n!',


                        'beginIndex' => '0',


                        'count' => $maxhits,


                        'outputFormat' => 'smiles',


                        'dataFieldNames' => 'mr_id',


                        'hitColorAndAlignmentOptions' => ''


); 


 


$search_result = $soap->runCompleteSearch($search_param)->return;

ChemAxon ebbce65bcf

05-03-2010 09:23:43

Steve,


You can use endSearch() (in JChemSearchWS or RelSearchWS) to free up memory after the result set of a particular search is not used anymore, and you can use the close() method of ConnectionWS to free up the entire connection. Anyway, could you attach the corresponding tomcat log when this error occurs, please? Internal server error is a quite general message.


The default location of the license file is inside the user's home who starts the web services (e.g.  /home/user/.chemaxon, or C:\Documents and Settings\User\chemaxon) but if there is a problem, the error message will contain the exact path where the license file should be put. Here is an FAQ about the licenses:


http://www.chemaxon.com/marvin-archive/5_2_04/marvin/help/licensedoc/licenseFAQ.html


Regards,


Roland

User 1a3b6cd85b

05-03-2010 11:10:11

Thanks Roland - can you be more specific given the code excerpt I provided?


For example, would a endSearch call be:


$soap->endSearch($id);


I am not sure how to use close() since JChemSearchWS is being used (not ConnectionWS). Please illustrate.


Thanks!

ChemAxon ebbce65bcf

05-03-2010 13:52:02

Your runCompleteSearchResponse should be something similar like this


<Complete><SearchId>searchID-1770662540</SearchId><ResultCount>9745</ResultCount><Rows>
<Row><Molecule>CC1=CC(=O)C=CC1=O</Molecule><mr_id>1</mr_id></Row>
<Row><Molecule>CC(=NO)C(C)=NO</Molecule><mr_id>9</mr_id></Row>
...

which returns a search id inside (here: searchID-1770662540) that belongs to this specific search. You have to retrieve this with an xml parser or a regular expression to use it later e.g. as the endSearch($searchId) parameter. Unfortunately you cannot use strip_tags() here because it would combine SearchId and ResultCount to one single string.


To execute a ConnectionWS.close() I suppose you need to create another SoapClient object in PHP as you created the one which used the JChemSearchWS wsdl.


$soap = new SoapClient('http://myserver.com:8180/axis2/services/ConnectionWS?wsdl'); 
$soap->close($id);

Regards,


Roland

User 1a3b6cd85b

05-03-2010 19:38:22



Roland, 


  I can extract the searchId from the result (i.e. $search_result) and issue a endSearch (i.e. $soap->endSearch($searchId);), but this does not clean things up much.  Indeed, "runCompleteSearch()" suggests it should end the search anyway and still doesn't address the connection handler.


  Taking your approach of creating another SoapClient object using the JChemSearchWS wsdl (i.e. $soap = new SoapClient('http://myserver.com:8180/axis2/services/ConnectionWS?wsdl'); $soap->close($id); ) and then close it ($soap->close($id);) does not help release the original $id created. 


I think what is necessary is that a close() operation needs to be added to JChemSearchWS, or perhaps for the ConnectionWS to attach to a handle created by other WS's, to then use it's close. Of course, if you attempt to close a handle not created by ConnectionWS, you will also crash your app server.


Do you have a suggested work around in the meantime?  This seems to be a big show stopper.


The catalina unrecoverable error that results after many calls without "adequate cleanup:"



[ERROR] Data source rejected establishment of connection,  message from server: "Too many connections"


java.lang.reflect.InvocationTargetException


        at sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source)


        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)


        at java.lang.reflect.Method.invoke(Unknown Source)


        at org.apache.axis2.rpc.receivers.RPCUtil.invokeServiceClass(RPCUtil.java:194)


        at org.apache.axis2.rpc.receivers.RPCMessageReceiver.invokeBusinessLogic(RPCMessageReceiver.java:102)


        at org.apache.axis2.receivers.AbstractInOutMessageReceiver.invokeBusinessLogic(AbstractInOutMessageReceiver.java:40)                                    



        at org.apache.axis2.receivers.AbstractMessageReceiver.receive(AbstractMessageReceiver.java:100)


        at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:176)


        at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)


        at org.apache.axis2.transport.http.AxisServlet.doPost(AxisServlet.java:131)


        at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)


        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)


        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)


        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)


        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)


        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)


        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)


        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)


        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)


        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)


        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)


        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)


        at java.lang.Thread.run(Unknown Source)


Caused by: com.mysql.jdbc.exceptions.MySQLNonTransientConnectionException: Data source rejected establishment of connection,  message from server: "Too many connections"


        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:980)   



       at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)


        at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1102)


        at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2142)


        at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:773)


        at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:348)


        at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)


        at java.sql.DriverManager.getConnection(Unknown Source)


        at java.sql.DriverManager.getConnection(Unknown Source)


        at chemaxon.util.ConnectionHandler.setConnected(ConnectionHandler.java:270)


        at chemaxon.util.ConnectionHandler.connect(ConnectionHandler.java:307)


        at chemaxon.jchem.webservice.ConnectionProvider.getInstance(ConnectionProvider.java:60)


        at chemaxon.jchem.webservice.ConnectionWS.createConnection(ConnectionWS.java:80)


        at chemaxon.jchem.webservice.ConnectionWS.getConnection(ConnectionWS.java:61)


        at chemaxon.jchem.webservice.JChemSearchWS.getConnectionAndTableInfo(JChemSearchWS.java:111)


        ... 24 more                      







ChemAxon ebbce65bcf

08-03-2010 08:33:06

Steve,


This error shouldn't occur if you use ConneectionWS.close() method and it works well. I am investigating whether we have a relatively new bug here (because we have tested this part in the past). Please, sent me the entire code you are using for the stress test to help us, if you can. First of all I have one thing in my mind which could cause the issue. Your script might start more threads simultaneously than your database can handle or maybe it generates new connections faster than it closes the obsolete ones. Are you sure it is not the case?


Regards,


Roland

ChemAxon ebbce65bcf

08-03-2010 09:00:07

Steve,


Try this:


$soap->close(array('connectionHandlerId' => $id)); 

Otherwise the value the WS gets is null.


Anyway, you can create different PHP objects for different wsdl-s for the easier use.


Roland

User 1a3b6cd85b

08-03-2010 10:13:00

 


Well, so far so good. After ~700 calls, no failure yet. I'll let my stress run for a few thousand sequential calls to confirm.


So in sum, using my original code excerpt, after the


$search_result = $soap->runCompleteSearch($search_param)->return;


A "new" SoapClient call is issued. Then the $id from the first call is used as below:


 


$soap = new SoapClient('http://myserver.com:8180/axis2/services/ConnectionWS?wsdl');


$soap->close(array('connectionHandlerId' => $id));  



I am pleasantly surprised that this is working so far. Will keep you posted.

 


 

User 1a3b6cd85b

08-03-2010 21:43:23

After 10K queries, no crash. Thanks for your help Roland!