Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-68512

Liferay 7 will not startup if JAVA_HOME/bin is not added to OS environment PATH

    Details

      Description

      Liferay requires a JAVA_HOME and PATH variables set. However, Liferay really only needs JAVA_HOME set. If someone were to either not set JAVA_HOME/bin in their PATH variable, or point PATH to an unsupported version of JAVA, then Liferay will throw errors and fail to start up.
      This seems to only apply to Unix-based operating systems, as I was not able to reproduce it on Windows.

      Steps to Reproduce
      Make sure you're on a Unix-based operating system; I used CentOS 6
      1. Download Java 8
      2. Set your JAVA_HOME environment variable, but make sure not to set JAVA_HOME/bin in your PATH variable.
      See http://stackoverflow.com/questions/16271316/setting-java-home-classpath-in-centos-6 for instructions on how to set these variables. You can verify if the variable is set by running this command echo $JAVA_HOME and seeing if your JDK location shows up.
      3. Download a bundle of Liferay 7, and start it
      Expected: Liferay will start up
      Actual: Liferay will throw an error that it is unable to find java.

      Errors

      04-Oct-2016 23:00:35.827 SEVERE [localhost-startStop-1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class com.liferay.portal.spring.context.PortalContextLoaderListener
       java.lang.RuntimeException: com.liferay.portal.kernel.process.ProcessException: java.io.IOException: Cannot run program "java": error=2, No such file or directory
      	at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:256)
      	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812)
      	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255)
      	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
      	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
      	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
      	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
      	at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:585)
      	at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1794)
      	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      	at java.lang.Thread.run(Thread.java:745)
      Caused by: com.liferay.portal.kernel.process.ProcessException: java.io.IOException: Cannot run program "java": error=2, No such file or directory
      	at com.liferay.portal.kernel.process.local.LocalProcessExecutor.execute(LocalProcessExecutor.java:230)
      	at com.liferay.portal.lpkg.deployer.internal.LPKGIndexValidator._getTargetPlatformIndexURIs(LPKGIndexValidator.java:318)
      	at com.liferay.portal.lpkg.deployer.internal.LPKGIndexValidator.validate(LPKGIndexValidator.java:234)
      	at com.liferay.portal.lpkg.deployer.internal.DefaultLPKGDeployer._doActivate(DefaultLPKGDeployer.java:263)
      	at com.liferay.portal.lpkg.deployer.internal.DefaultLPKGDeployer.activate(DefaultLPKGDeployer.java:91)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:222)
      	at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:37)
      	at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:615)
      	at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:499)
      	at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:295)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:302)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:113)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:866)
      	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:833)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:724)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:954)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:915)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)
      	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:120)
      	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:917)
      	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)
      	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:954)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:915)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)
      	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:120)
      	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:917)
      	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)
      	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:954)
      	at org.apache.felix.scr.impl.manager.DependencyManager$SingleStaticCustomizer.addedService(DependencyManager.java:915)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1215)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.customizerAdded(ServiceTracker.java:1136)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.trackAdding(ServiceTracker.java:945)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$AbstractTracked.track(ServiceTracker.java:881)
      	at org.apache.felix.scr.impl.manager.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:1167)
      	at org.apache.felix.scr.impl.BundleComponentActivator$ListenerInfo.serviceChanged(BundleComponentActivator.java:120)
      	at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:917)
      	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:862)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:801)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
      	at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:225)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:464)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:869)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager$3.register(AbstractComponentManager.java:857)
      	at org.apache.felix.scr.impl.manager.RegistrationManager.changeRegistration(RegistrationManager.java:133)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:915)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:715)
      	at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:399)
      	at org.apache.felix.scr.impl.config.ConfigurableComponentHolder.enableComponents(ConfigurableComponentHolder.java:676)
      	at org.apache.felix.scr.impl.BundleComponentActivator.initialEnable(BundleComponentActivator.java:339)
      	at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:360)
      	at org.apache.felix.scr.impl.Activator.access$000(Activator.java:53)
      	at org.apache.felix.scr.impl.Activator$ScrExtension.start(Activator.java:260)
      	at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
      	at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
      	at org.apache.felix.utils.extender.AbstractExtender.addingBundle(AbstractExtender.java:192)
      	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:469)
      	at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
      	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
      	at org.osgi.util.tracker.AbstractTracked.trackInitial(AbstractTracked.java:183)
      	at org.osgi.util.tracker.BundleTracker.open(BundleTracker.java:156)
      	at org.apache.felix.utils.extender.AbstractExtender.startTracking(AbstractExtender.java:150)
      	at org.apache.felix.utils.extender.AbstractExtender.doStart(AbstractExtender.java:142)
      	at org.apache.felix.scr.impl.Activator.doStart(Activator.java:170)
      	at org.apache.felix.utils.extender.AbstractExtender.start(AbstractExtender.java:114)
      	at org.apache.felix.scr.impl.Activator.restart(Activator.java:140)
      	at org.apache.felix.scr.impl.config.ScrConfiguration.configure(ScrConfiguration.java:215)
      	at org.apache.felix.scr.impl.config.ScrConfiguration.start(ScrConfiguration.java:136)
      	at org.apache.felix.scr.impl.Activator.start(Activator.java:110)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:774)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl$3.run(BundleContextImpl.java:1)
      	at java.security.AccessController.doPrivileged(Native Method)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.startActivator(BundleContextImpl.java:767)
      	at org.eclipse.osgi.internal.framework.BundleContextImpl.start(BundleContextImpl.java:724)
      	at org.eclipse.osgi.internal.framework.EquinoxBundle.startWorker0(EquinoxBundle.java:951)
      	at org.eclipse.osgi.internal.framework.EquinoxBundle$EquinoxModule.startWorker(EquinoxBundle.java:328)
      	at org.eclipse.osgi.container.Module.doStart(Module.java:566)
      	at org.eclipse.osgi.container.Module.start(Module.java:434)
      	at org.eclipse.osgi.framework.util.SecureAction.start(SecureAction.java:454)
      	at org.eclipse.osgi.container.ModuleContainer.applyDelta(ModuleContainer.java:717)
      	at org.eclipse.osgi.container.ModuleContainer.resolveAndApply(ModuleContainer.java:491)
      	at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:437)
      	at org.eclipse.osgi.container.ModuleContainer.resolve(ModuleContainer.java:427)
      	at org.eclipse.osgi.container.Module.start(Module.java:411)
      	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1582)
      	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1562)
      	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1533)
      	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1476)
      	at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.dispatchEvent(ModuleContainer.java:1)
      	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
      	at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
      Caused by: java.io.IOException: Cannot run program "java": error=2, No such file or directory
      	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
      	at com.liferay.portal.kernel.process.local.LocalProcessExecutor.execute(LocalProcessExecutor.java:145)
      	... 128 more
      Caused by: java.io.IOException: error=2, No such file or directory
      	at java.lang.UNIXProcess.forkAndExec(Native Method)
      	at java.lang.UNIXProcess.<init>(UNIXProcess.java:247)
      	at java.lang.ProcessImpl.start(ProcessImpl.java:134)
      	at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
      	... 129 more
      

      See attached java-error.txt

      Testing
      I was able to reproduce this in 7.0.x 475b9805d040f0ce2a046955bd68bf16fe1c2f0e.

      Able to reproduce alternative error in liferay-portal/master 6fa8aa21931ae3d62e4516db4dd4f3528ed37c0c.

      There is a workaround - set $JAVA_HOME/bin in PATH. However, not all users will do this, and this is our bug since we shouldn't have to call PATH, we can just call JAVA_HOME.

        Attachments

          Activity

            People

            Assignee:
            shanon.mathai Shanon Mathai
            Reporter:
            christopher.lui Christopher Lui
            Participants of an Issue:
            Recent user:
            Esther Sanz
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              4 years, 41 weeks, 1 day ago

                Packages

                Version Package