Error at JChemSearch.setMaxCacheSize

User 2db1160666

10-06-2013 11:26:38

 


 


I am trying to migrate to JChem 6.0 from 5.10.3. (I do not use cartridge, I connect DB via JDBC)


I got the following error at structure search.


 


 


 java.lang.NullPointerException


 


     at chemaxon.jchem.db.JChemSearch.setMaxCacheSize(JChemSearch.java:1081)


 


My code was working correctly at 5.10.3, and I have not changed my code.


I only have changed library to 6.0.


Also, I changed argument of this function to -1. However the result same.


If I forget that I should do something for new version, please let me know.


Thank you,


 


 

ChemAxon abe887c64e

10-06-2013 12:26:02

Dear Customer,


Have you regenerated your database tables before running searches?


Table regeneration can be executed from command line by jcman u , or by JChem Manager. After connecting to the database, JChem Manager provides the list of tables that need regeneration.


Best regards,



Krisztina

User 2db1160666

10-06-2013 15:45:34

Hi Krisztina,


Thank you for reply.


After I install JChem 6.0, I connect database by JChem Manager 6.0 and I have updated the table according to the instructions.


Thank you,


yuji

ChemAxon abe887c64e

11-06-2013 05:41:21

Hi Yuji,


What kind of database are you using?


Krisztina

User 2db1160666

11-06-2013 10:16:35

I am using PostgreSQL 9.0.3 on CentOS 5.5.


Thank you,

ChemAxon abe887c64e

11-06-2013 10:31:50

Thanks for the details. One more question: could you send us some lines of Java code where setMaxCacheSize() is called?


Krisztina



User 2db1160666

11-06-2013 11:49:44

Thank you for your quick response.


My code is 


--------------------------------------------------------------------------------------------------------------------------


ConnectionHandler ch = new ConnectionHandler();

    ch.setDriver("org.postgresql.Driver");

    ch.setUrl("xxxxx");

    ch.setPropertyTable("xxxx.jchemproperties");

    ch.setLoginName("xxxxx");

    ch.setPassword("xxxxx");

    ch.connectToDatabase();

   

    JChemSearch searcher = new JChemSearch();

       searcher.setConnectionHandler(ch);

       searcher.setStructureTable("table_name");

       searcher.setResultTableMode(JChemSearch.NO_RESULT_TABLE);

       searcher.setInfoToStdError(false);

       searcher.setRunMode(JChemSearch.RUN_MODE_ASYNCH_COMPLETE);

    searcher.setQueryStructure(molString);

    JChemSearchOptions searchOptions = new JChemSearchOptions(JChemSearch.SUBSTRUCTURE);

       searcher.setSearchOptions(searchOptions);        

       searcher.setOrder(JChemSearch.ORDERING_BY_ID);

 

       searcher.setMaxCacheSize(2048); 

 

       searcher.run();

       

       while(searcher.isRunning()) {

        String msg = searcher.getProgressMessage();

        int cnt = searcher.getResultCount();

        int lastId = searcher.getCurrentId();

       

        log.debug("Progress message: " + msg + 

        ", result count: " + cnt + 

        ", last cd_id: " + lastId);

        Thread.sleep(500);

       }

       int[] cdIds = searcher.getResults();

--------------------------------------------------------------------------------------------------------------------------




Thank you,


 


yuji

ChemAxon 61b4fee994

11-06-2013 12:45:51

Hi,


We found out this is unfortunately a bug in the 6.0 version. We found a workaround for your problem. However, it is an undocumented feature, which means we can't guarantee it will work in later versions, so we suggest you change this line in your code for only this JChem Version and use the old code later.


The workaround is to change this line:



 searcher.setMaxCacheSize(2048); 


to


   CachePool.getInstance().setMemSize(2048, -1);


(-1 means that the minimum free cache size will not be set.)


 


This bug reflected on these cache size features which are set in the JchemSearch class. In the future they are likely to be deprecated and then these settings will be moved to the CacheManager class with the same functionality.


To get more knowledge about your use case, please, share with us some more details if you can about it. Why do you restrict the size of the cache, what is the purpose of this call? Do you need free space for other programs that run in the same JVM?


And please, tell us if this workaround works or doesn't work in your code?


Regards,


Tamas

User 2db1160666

12-06-2013 15:23:54

Thank you for your answer.


II am developing structure serach service system with Servlet container on my PC. The production server has enough memory. however my pc has poor ability. so I always get timeout error at first structure search since the time of cache is very long. (This timeout is occured intentionally by my thread, not JChem search)


I think that this option is very useful to shorten time of cache. (My real code can set this value by outside property file)


Also some service is running on our servlet container, so I have to set limitation of JVM as you said.



Thank you,


yuji

 


 


 

ChemAxon 61b4fee994

13-06-2013 10:45:53

Thank you for your details!


So the change we suggested helped for you?


Regards,


Tamas

User 2db1160666

13-06-2013 15:39:32

I changed my code as you suggested.


It works very well.


Thank you very much.