klehmann / domino-jna

Java project to access the IBM/HCL Domino C API using Java Native Access (JNA)
Apache License 2.0
66 stars 16 forks source link

Thread is not enabled for auto GC. #79

Closed PatrickKwinten closed 11 months ago

PatrickKwinten commented 11 months ago

When running in XPages environment: NotesDatabase db = new NotesDatabase(ExtLibUtil.getCurrentSession(), "", fakenamesPath);

I get message:

HTTP JVM: java.lang.IllegalStateException: Thread is not enabled for auto GC. Either run your code via NotesGC.runWithAutoGC(Callable) or via try-with-resources on the object returned by NotesGC.initThread().

On https://www.mindoo.com/web/blog.nsf/dx/16.01.2017082125KLEAMY.htm?opendocument&comments I read

"Since they are integrated with the JSF lifecycle, memory management is automatically handled by the plugin. That means that code using the API does not have to be wrapped in NotesGC.runWithAutoGC() blocks to automatically recycle allocated C handles and memory after a HTTP request."

I installed version domino-jna-xpages-0.9.48

I am trying to run this sample application: http://linqed.eu/2018/10/02/query-domino-data-and-faceted-search-with-domino-jna-part-1/

perlausten commented 11 months ago

Are you running this on a Domino server?

klehmann commented 11 months ago

We discussed this via Discord. There was a second instance of Domino JNA on the server, probably in jvm/lib/ext to be used in agents, which is an unsupported scenario because it messes up the global JVM classloader that is used as fallback for Domino's HTTP OSGi stack. I have never used/tested Domino JNA in agents. I heard it's working (with SecurityManager tweaks like this https://support.hcltechsw.com/csm?id=kb_article&sysparm_article=KB0034343 ), but then the Domino JNA JAR and required dependencies should be added to the agent design element, not used in jvm/lib/ext.