Saturday, 12 July 2014

Unable to start CQ instance. javax.jcr.RepositoryException while installing CQ

Couple of days back I was installing CQ5.5 back on my Linux machine. So, I started the instance from command line using command 
"java -XX:MaxPermSize=512m -Xmx1520m -XX:-UseSplitVerifier -jar cq5-author-8502.jar
and everything went fine. But when installation was completed and it came up with url in the browser that should have shown Login page instead it came with 503 ERROR : Service Unavailable. On investigating in the error logs i found the following error stack :

10.07.2014 22:02:31.526 *INFO* [FelixStartLevel] org.apache.jackrabbit.core.RepositoryImpl Shutting down repository...
10.07.2014 22:02:31.529 *INFO* [FelixStartLevel] org.apache.jackrabbit.core.RepositoryImpl Repository has been shutdown
10.07.2014 22:02:31.551 *ERROR* [FelixStartLevel] com.day.crx.sling.server [com.day.crx.sling.server.impl.jmx.ManagedRepository] The activate method has thrown an exception (javax.jcr.RepositoryException: Unable to register data store in cluster.) javax.jcr.RepositoryException: Unable to register data store in cluster.
at com.day.crx.core.data.ClusterDataStore.init(ClusterDataStore.java:183)
at com.day.crx.core.CRXRepositoryImpl.createClusterNode(CRXRepositoryImpl.java:999)
at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:294)
at com.day.crx.core.CRXRepositoryImpl.<init>(CRXRepositoryImpl.java:283)
at com.day.crx.core.CRXRepositoryImpl.create(CRXRepositoryImpl.java:258)
at com.day.crx.core.CRXRepositoryImpl.create(CRXRepositoryImpl.java:243)
at com.day.crx.sling.server.impl.jmx.ManagedRepository.activate(ManagedRepository.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.felix.scr.impl.helper.BaseMethod.invokeMethod(BaseMethod.java:227)
at org.apache.felix.scr.impl.helper.BaseMethod.access$500(BaseMethod.java:38)
at org.apache.felix.scr.impl.helper.BaseMethod$Resolved.invoke(BaseMethod.java:591)
at org.apache.felix.scr.impl.helper.BaseMethod.invoke(BaseMethod.java:472)
at org.apache.felix.scr.impl.helper.ActivateMethod.invoke(ActivateMethod.java:146)
at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createImplementationObject(ImmediateComponentManager.java:226)
at org.apache.felix.scr.impl.manager.ImmediateComponentManager.createComponent(ImmediateComponentManager.java:118)
at org.apache.felix.scr.impl.manager.DelayedComponentManager.createRealComponent(DelayedComponentManager.java:95)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$Registered.getService(AbstractComponentManager.java:1296)
at org.apache.felix.scr.impl.manager.DelayedComponentManager.getService(DelayedComponentManager.java:88)
at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:310)
at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:221)
at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:292)
at org.apache.felix.framework.Felix.getService(Felix.java:3010)
at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:329)
at org.osgi.util.tracker.ServiceTracker.addingService(ServiceTracker.java:442)
at org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:101)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:871)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:733)
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3765)
at org.apache.felix.framework.Felix.registerService(Felix.java:2877)
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:456)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerComponentService(AbstractComponentManager.java:508)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:1157)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:334)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:158)
at org.apache.felix.scr.impl.config.ImmediateComponentHolder.enableComponents(ImmediateComponentHolder.java:313)
at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:241)
at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:147)
at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:111)
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:274)
at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:192)
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3754)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1780)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1156)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.UnknownHostException: AnkitGubrani: AnkitGubrani: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:198)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at java.net.Socket.<init>(Socket.java:425)
at java.net.Socket.<init>(Socket.java:241)
at com.day.crx.core.cluster.ClusterMaster$3.execute(ClusterMaster.java:385)
at com.day.crx.core.cluster.ClusterController.attempt(ClusterController.java:1385)
at com.day.crx.core.cluster.ClusterMaster.listen(ClusterMaster.java:383)
at com.day.crx.core.cluster.ClusterMaster.startListener(ClusterMaster.java:196)
at com.day.crx.core.cluster.ClusterController.startMasterListener(ClusterController.java:840)
at com.day.crx.core.cluster.ClusterController.start(ClusterController.java:684)
at com.day.crx.core.cluster.ClusterController.register(ClusterController.java:919)
at com.day.crx.core.data.ClusterDataStoreSkeleton.init(ClusterDataStoreSkeleton.java:94)
at com.day.crx.core.data.ClusterDataStore.init(ClusterDataStore.java:177)
... 56 more
Caused by: java.net.UnknownHostException: AnkitGubrani: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
... 72 more
10.07.2014 22:02:31.552 *ERROR* [FelixStartLevel] com.day.crx.sling.server [com.day.crx.sling.server.impl.jmx.ManagedRepository] Failed creating the component instance; see log for reason
10.07.2014 22:02:31.554 *ERROR* [FelixStartLevel] org.apache.aries.jmx.whiteboard.JmxWhiteboardSupport registerMBean: Cannot register MBean service null with MBean servers: Not an instanceof DynamicMBean or not MBean spec compliant standard MBean
10.07.2014 22:02:31.555 *INFO* [FelixStartLevel] com.day.crx.sling.server Service [com.day.crx.sling.server.impl.jmx.ManagedRepository,74] ServiceEvent REGISTERED
10.07.2014 22:02:31.554 *ERROR* [FelixDispatchQueue] com.day.crx.sling.server FrameworkEvent ERROR (org.osgi.framework.ServiceException: Service factory returned null.) org.osgi.framework.ServiceException: Service factory returned null.
at org.apache.felix.framework.ServiceRegistrationImpl.getFactoryUnchecked(ServiceRegistrationImpl.java:343)
at org.apache.felix.framework.ServiceRegistrationImpl.getService(ServiceRegistrationImpl.java:221)
at org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:292)
at org.apache.felix.framework.Felix.getService(Felix.java:3010)
at org.apache.felix.framework.BundleContextImpl.getService(BundleContextImpl.java:329)
at org.osgi.util.tracker.ServiceTracker.addingService(ServiceTracker.java:442)
at org.apache.aries.jmx.whiteboard.Activator$MBeanTracker.addingService(Activator.java:101)
at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:896)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:261)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:233)
at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:840)
at org.apache.felix.framework.util.EventDispatcher.invokeServiceListenerCallback(EventDispatcher.java:871)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:733)
at org.apache.felix.framework.util.EventDispatcher.fireServiceEvent(EventDispatcher.java:662)
at org.apache.felix.framework.Felix.fireServiceEvent(Felix.java:3765)
at org.apache.felix.framework.Felix.registerService(Felix.java:2877)
at org.apache.felix.framework.BundleContextImpl.registerService(BundleContextImpl.java:251)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerService(AbstractComponentManager.java:456)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.registerComponentService(AbstractComponentManager.java:508)
at org.apache.felix.scr.impl.manager.AbstractComponentManager$Unsatisfied.activate(AbstractComponentManager.java:1157)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.activateInternal(AbstractComponentManager.java:334)
at org.apache.felix.scr.impl.manager.AbstractComponentManager.enable(AbstractComponentManager.java:158)
at org.apache.felix.scr.impl.config.ImmediateComponentHolder.enableComponents(ImmediateComponentHolder.java:313)
at org.apache.felix.scr.impl.BundleComponentActivator.loadDescriptor(BundleComponentActivator.java:241)
at org.apache.felix.scr.impl.BundleComponentActivator.initialize(BundleComponentActivator.java:147)
at org.apache.felix.scr.impl.BundleComponentActivator.<init>(BundleComponentActivator.java:111)
at org.apache.felix.scr.impl.Activator.loadComponents(Activator.java:274)
at org.apache.felix.scr.impl.Activator.bundleChanged(Activator.java:192)
at org.apache.felix.framework.util.EventDispatcher.invokeBundleListenerCallback(EventDispatcher.java:807)
at org.apache.felix.framework.util.EventDispatcher.fireEventImmediately(EventDispatcher.java:729)
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:610)
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:3754)
at org.apache.felix.framework.Felix.startBundle(Felix.java:1780)
at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1156)
at org.apache.felix.framework.StartLevelImpl.run(StartLevelImpl.java:266)
at java.lang.Thread.run(Thread.java:745)







Solution:

On investing I found that CQ was trying to resolve to a server named as AnkitGubrani which was the hostname of my machine (i.e name in /etc/hostname file). So adding this entry in the /etc/hosts file resolved the problem. Following entry resolved the problem :

127.0.0.1   localhost AnkitGubrani

After adding above line /etc/hosts file should be saved and apache2 service should be restarted. 

And if everything went fine following command should give name of the host : hostname -f

In my case it returned localhost after adding entry into /etc/hosts while earlier it returned AnkitGubrani: Name or service not known.

Your comments and suggestions are welcome.