Exiting the JVM ... !@#$%

Today I experienced a great victory, but the day sure didn't start that way. In the days leading up to OSGI I spent a lot of time reading about it, listening to discussions, etc. I wanted to understand what the big deal was. Among the list of benefits, one stuck out most for me.

"OSGI does the dependency management, at runtime, for you. So if you have Module A that is dependent on Module B, and all of the sudden Module B vanishes, OSGI will make sure your environment remains stable by stopping any other modules (ie. Module A) that are dependent. This way, your user is not able to start interacting with A at the risk of 500 server app errors or worse."

WOW. I mean, I don't often experience this problem, but I like the idea of not having to worry about it! So when I started my journey with Liferay 7, I was keen to see this in action. I follow the rules. I'm one of those people. But from the beginning I would have some odd situations where if I removed the wrong module I would get the usual "Import-Package" error message etc, but I would also see this.

[fileinstall-/home/aj/projects/ml/liferay/osgi/modules][org_apache_felix_fileinstall:112] Exiting the JVM 

I am on Linux. The process was still running, but the portal was not responsive. So the only way to fix this was to

  1. kill the process
  2. remove the module that caused the error (Module A)
  3. clear the osgi/state older
  4. start the server
  5. and redeploy in the right order

Ugh. And what a colossal waste of time. Over the past couple years I would ask people here and there about this error, maybe vent some frustrations, but everyone said the same thing -- "I've never seen that. I don't know what you are talking about". I figured -- pfft, mac users :)

But today, when it happened again I said to myself, there must be a reason -- so I started to search. As part of my search I took to slack. Piotr Paradiuk (who I had recently met in Amsterdam at DEVCON) was kind enough to rubber duck with me. If you don't know what Rubber Ducking is --

Piotr (and David actually, in another chat medium) both had the same reply "never seen it before". But over the course of try this and do that, Piotr sent me a link to github ( -- mocking my error message :). But. after staring at this file, muttering under my breath, something caught my eye.

if ((throwable != null) && (throwable instanceof BundleException) &&
	(_JENKINS_HOME != null)) {

	String throwableMessage = throwable.getMessage();

	if (throwableMessage.startsWith("Could not resolve module")) {
		log.error(_FORMAT, "Exiting the JVM", context, throwable);


More specifically --

private static final String _JENKINS_HOME = System.getenv("JENKINS_HOME");

:| ... I have jenkins running on my machine. Could that be it? So I stopped my instance and ran --


Restarted my portal and ran through the steps to try to reproduce. This time I get the Import-Package error stuff, but the JVM doesn't exit.


So, the moral of the story. If you are like me and you want to have jenkins on your dev machine to play with and such -- virtualize it or run it in a docker container. Oh .. and add --



Nice catch Andrew! Thank you for putting this in the from of valuable information for all Liferay developers. It's nice to see people doing that instead of rushing to call us names and publicly mock us (which, I personally think, we kind of deserve in this particularly embarrassing case). 


What you have discovered is a side effect of an attempt to deal with a nasty CI related issue: I have notified the team about it and they will prioritize and fix it accordingly. I'll keep you posted.


That said, and despite the fact your post explains it perfectly fine, it would be nice if you can open an issue so we can formally track it in Jira.  


Thanks Andrew for nice article, I am also facing the same issue "Exiting JVM" in my local machine. In my machine, JENKINS_HOME environment variable was set in my system settings variables. Which was causing to shutdown a liferay DXP tomcat.   

I have unset JENKINS_HOME variable, restarted liferay DXP and deployed plugin with import package error. Tomcat will remains on after throwing import package error by plugin.