0

I'm working on a project that makes use of Hibernate.

When I try to do mvn clean install from command line (Terminal), the build passes (once the SOCKS proxy is disabled).

When I try to run a mvn clean install from within Eclipse (Run As > Run Configuration), I get a Caused by: java.net.ConnectException: Connection refused (Connection refused) for pretty much every test (involving Hibernate) we have. (Top of stack: org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection; Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Network error IOException: Connection refused (Connection refused)))

I have tried to force the bash environment variables into Eclipse using the suggestion from here: https://stackoverflow.com/a/28424943/2018047

So, in theory - I thought - both, maven from Terminal, and maven from Eclipse should run with the exact same settings. But apparently they don't (as only the Eclipse one fails). Any suggestions where to start to figure out what's wrong? (My bet is on the proxy settings, but I don't even know how to figure out what the test is trying to connect to at runtime, and if the host name is correct or if a proxy does get picked up...)

Community
  • 1
  • 1
Christian
  • 6,070
  • 11
  • 53
  • 103
  • Can you confirm you have already tried setting up your proxy in Eclipse? As far as I know, Eclipse won't try to use Maven's proxy settings – Adonis Mar 20 '17 at 16:32
  • I have. But from what I understand, Eclipse merely launches maven. I'm not sure how much influence it has on its settings (i.e. if it passes its proxy settings to maven). Having said that, I might add a test class that just prints out the system properties and environment variables, and debug a Hibernate test remotely: http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html Hopefully that will give me a hint as to what is and isn't set at runtime. – Christian Mar 21 '17 at 08:45
  • In eclipse, we specify a `mvn -P` profile flag, which compiles additional modules with additional tests. One of those tests overrides an environment variable, which then causes haywire down the line (e.g. picking up the wrong port for a server connection, which caused the exception above), even after the `.bash_profile` is sourced. There was some misunderstanding regarding what maven profile would be loaded by default. In short, it comes down to a chain of configuration issues, and as such the problem is very specific to our set-up. I have thus cast a vote to close this question. – Christian Mar 21 '17 at 15:55
  • P.S.: To figure it out, I added an `@BeforeClass` to one of the first JUnit class that's executed, and made the method print all System properties, environment variables and the classpath. I also remote debugged the maven setup (cf. link in comment above) and closely examined the POM file and all form fields in Eclipse's Run configuration again. – Christian Mar 21 '17 at 15:57

0 Answers0