I have been searching everywhere, but could not find where exactly hibernate uses HttpURLConnection. Theoretically I think it uses for its back end connectivity.
My issue is I have a java agent which instruments HttpURLConnection to set a header every time it gets called. I want to use that agent with my Hibernate application but it fails. When I don't use my Java Agent it works perfectly fine. Even if the JAVA Agent is changed to print only some codes that works fine. But when I try to add a header to it, it fails giving an exception -
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2163)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2075)
at com.javapapers.App.test(App.java:101)
at com.javapapers.App.main(App.java:19)
Caused by: org.dom4j.DocumentException: null Nested exception: null
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2155)
... 3 more
I searched and tried all the way to get rid of this, but failed.
JAVA Agent Code to instrument:
ctConstructor.insertAfter("System.out.println(10);"
+ "setRequestProperty(\"testHeader\",\"NewHeader\");");