Agent failed to start - Instrumentation has already value

User 4aa76e4623

25-08-2014 07:59:26

I am using
the following code in order to search in the structure tables of my relational
database but I am getting the following exception.


 


Code:


        JChemSearch searcher = new JChemSearch();


        searcher.setConnectionHandler(ch);


       
searcher.setStructureTable(structureTableName);


        searcher.setInfoToStdError(true);


        searcher.run();


 


Exception:


Exception
in thread "Attach Listener" java.lang.reflect.InvocationTargetException


                at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)


                at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)


                at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)


                at
java.lang.reflect.Method.invoke(Method.java:597)


                at
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)


                at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:348)


Caused by:
java.lang.IllegalStateException: Instrumentation has already value.


                at
chemaxon.agent.InstrumentationHolder.premain(InstrumentationHolder.java:31)


                at chemaxon.agent.InstrumentationHolder.agentmain(InstrumentationHolder.java:42)


                ... 6 more


Agent
failed to start!


 


This error
is displayed because of the setInfoToStdError(true), in case I set this to false
then I don’t get it.


(http://www.chemaxon.com/jchem/doc/dev/java/api/chemaxon/jchem/db/JChemSearch.html#setInfoToStdError%28boolean%29)


 


Can you explain
me why this exception is thrown from the InstrumentationHolder?


Thank you,

ChemAxon d4fff15f08

26-08-2014 14:26:33

Hi Nikolaos,


 


Thank you for your post. We will be back very soon with our answer.


 


Thank you for your patience.


Best regards,


Norbert

ChemAxon 42004978e8

27-08-2014 15:24:37

Hi,


I couldn't reproduce the exception so far.


Please specify your jchem version as well.


Thanks,


Robert

User 4aa76e4623

28-08-2014 07:51:15










rwagner wrote:

Hi,


I couldn't reproduce the exception so far.


Please specify your jchem version as well.


Thanks,


Robert



 


Implementation-Title: JChem
Implementation-Version: 5.10.2 2012-07-30


we use  jdk1.6.0_05

ChemAxon 42004978e8

28-08-2014 10:11:27

Hi,


I still couldn't reproduce the problem.


I can suggest you to upgrade to a 14.7.x version because there this option doesn't cause an invocation of this agent.


Alternatively you can switch off this option and get the needed data in an other way. Which information do you need?


Bye,


Robert

User 4aa76e4623

28-08-2014 11:51:45










rwagner wrote:

Hi,


I still couldn't reproduce the problem.


I can suggest you to upgrade to a 14.7.x version because there this option doesn't cause an invocation of this agent.


Alternatively you can switch off this option and get the needed data in an other way. Which information do you need?


Bye,


Robert



 


 


Hi Robert,


Thank you for the help. 

Unfortunately migrating the version of jchem is
not an option at this moment.




I would like to know if the
exception thrown is caused by the logger which is enabled by the
setInfoToStdError(true) or if it is an exception thrown by the JChemSearch and
is just visible because we enabled it.




So, if we change it to setInfoToStdError(false), will the exception still
be thrown in the background but not logged? Does it affect the functionality of
ChemSearch?



Thanks

ChemAxon 42004978e8

28-08-2014 11:59:25

Hi Nikolaos,


Switching on the setInfoToStd... causes that some additional information is written out to the console. One of this is the cache size. In your environment this is calculation throws the exception. which I couldn't reproduce. In newer version the size is calculated in an other way that doesn't use this agent.


To make the story short, it's not the search process that causes the exception but the calculation of the logged information.


Bye,


Robert

User 4aa76e4623

29-08-2014 07:31:10










rwagner wrote:

Hi Nikolaos,


Switching on the setInfoToStd... causes that some additional information is written out to the console. One of this is the cache size. In your environment this is calculation throws the exception. which I couldn't reproduce. In newer version the size is calculated in an other way that doesn't use this agent.


To make the story short, it's not the search process that causes the exception but the calculation of the logged information.


Bye,


Robert



 


Hi Robert,


I added some extra information about the cashe size.


So the instrumented cache size is not calculated correct and and the exception is thrown? So the Agent that failed to start is the Chemaxon logger?


Fri Aug 29 10:12:29 EEST 2014
Search mode: SUBSTRUCTURE
Structure table: ECICS2T.JCHEMTABLE
Query: <Empty query>
Total screened: -1
Unique screened: -1
Hits: 42738
Total time: 27 ms  Screening: 0 ms
Processing threads: 2

Exception in thread "Attach Listener" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:323)
    at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:348)
Caused by: java.lang.IllegalStateException: Instrumentation has already value.
    at chemaxon.agent.InstrumentationHolder.premain(InstrumentationHolder.java:31)
    at chemaxon.agent.InstrumentationHolder.agentmain(InstrumentationHolder.java:42)
    ... 6 more
Agent failed to start!

Fri Aug 29 10:12:29 EEST 2014
Search mode: SUBSTRUCTURE
Structure table: ECICS2T.JCHEMTABLE
Query: <Empty query>
Total screened: -1
Unique screened: -1
Hits: 42738
Cache update: 13 ms
Cache size (this table / total): 5.07 / 5.07 MBytes
Instrumented cache size: 5.33 MBytes
Total time: 29 ms  Screening: 1 ms
Processing threads: 2

ChemAxon 42004978e8

29-08-2014 14:10:05

Hi,


The logger works correctly, but switching on the debug info print out (this is not a logger but a bunch of stdouts), invokes cache size calculation. Here the estimated cache size is based on a formula, while the instrumented is based on the jvm's object size calculation. This latter requires the start of an agent, written by us, which is started in your case twice by the jvm. In such cases an exception is thrown by our code.


Bye,


Robert