Spring MVC Portlet using Maven and custom jar, Liferay 7.1.2Spring MVC Portlet using Maven and custom jar, Liferay 7.1.2https://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1175387782024-03-29T02:34:39Z2024-03-29T02:34:39ZSpring MVC Portlet using Maven and custom jar, Liferay 7.1.2Ana Galvãohttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1175387772019-10-23T09:57:24Z2019-10-23T09:57:24ZHello all,<br />I am currently developing a Spring MVC portlet (using Maven) for Liferay 7.1.2, dist-list, that has a series of dependencies, including a custom external client jar, included in the pom as follows:<br /><br /> <dependency><br /> <groupId>eu.europa</groupId><br /> <artifactId>star-abm-client</artifactId><br /> <version>0.0.7-SNAPSHOT</version><br /> <exclusions><br /> <exclusion><br /> <groupId>commons-beanutils</groupId><br /> <artifactId>commons-beanutils</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>commons-beanutils</groupId><br /> <artifactId><br /> commons-beanutils-bean-collections<br /> </artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>commons-beanutils</groupId><br /> <artifactId>commons-beanutils-core</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-context</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-beans</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-core</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-context-support</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-webmvc-portlet</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-web</artifactId><br /> </exclusion><br /> <exclusion><br /> <groupId>org.springframework</groupId><br /> <artifactId>spring-tx</artifactId><br /> </exclusion><br /> </exclusions><br /> </dependency><br /><br />However, when I try to use the portlet, one of two things happen:<br />- The war includes the jar and a NullPointerException is thrown when referencing the classes present in the jar in runtime;<br />- The war does not include the jar and the following exception is thrown:<br />2019-10-23 09:45:00.753 ERROR [pipe-start 2023][DispatcherPortlet:279] Context initialization failed<br />org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'DistributionList': Failed to introspect bean class [eu.europa.portlet.DistributionList] for lookup method metadata: could not find class that it depends on; nested exception is java.lang.NoClassDefFoundError: ServiceLocator<br /> at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:267)<br /> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineConstructorsFromBeanPostProcessors(AbstractAutowireCapableBeanFactory.java:1123)<br /> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)<br /> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)<br /> at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)<br /> at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)<br /> at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)<br /> at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)<br /> at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:867)<br /> at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:543)<br /> at org.springframework.web.portlet.FrameworkPortlet.createPortletApplicationContext(FrameworkPortlet.java:368)<br /> at org.springframework.web.portlet.FrameworkPortlet.initPortletApplicationContext(FrameworkPortlet.java:297)<br /> at org.springframework.web.portlet.FrameworkPortlet.initPortletBean(FrameworkPortlet.java:271)<br /> at org.springframework.web.portlet.GenericPortletBean.init(GenericPortletBean.java:124)<br /> at javax.portlet.GenericPortlet.init(GenericPortlet.java:143)<br /> at com.liferay.portlet.internal.InvokerPortletImpl.init(InvokerPortletImpl.java:253)<br /> at com.liferay.portal.monitoring.internal.portlet.MonitoringInvokerPortlet.init(MonitoringInvokerPortlet.java:154)<br /> at com.liferay.portlet.internal.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:269)<br /> at com.liferay.portlet.internal.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:170)<br /> at com.liferay.portal.kernel.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:48)<br /> at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:210)<br /> at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:108)<br /> at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:932)<br /> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br /> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)<br /> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br /> at java.lang.reflect.Method.invoke(Method.java:498)<br /> at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)<br /> at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:125)<br /> at com.sun.proxy.$Proxy85.initWAR(Unknown Source)<br /> at com.liferay.portal.kernel.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:466)<br /> at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:228)<br /> at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:96)<br /> at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:232)<br /> at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:97)<br /> at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:27)<br /> at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:189)<br /> at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:179)<br /> at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)<br /> at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:77)<br /> at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:59)<br /> at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54)<br /> at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:141)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter._initializeContext(ServletContextListenerExceptionAdapter.java:119)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter.contextInitialized(ServletContextListenerExceptionAdapter.java:99)<br /> at sun.reflect.GeneratedMethodAccessor431.invoke(Unknown Source)<br /> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br /> at java.lang.reflect.Method.invoke(Method.java:498)<br /> at org.eclipse.equinox.http.servlet.internal.registration.ListenerRegistration$EventListenerInvocationHandler.invoke(ListenerRegistration.java:143)<br /> at com.sun.proxy.$Proxy676.contextInitialized(Unknown Source)<br /> at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddListenerRegistration(ContextController.java:350)<br /> at org.eclipse.equinox.http.servlet.internal.context.ContextController.addListenerRegistration(ContextController.java:303)<br /> at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:67)<br /> at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:1)<br /> at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943)<br /> at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)<br /> at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)<br /> at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)<br /> at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903)<br /> at org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)<br /> at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891)<br /> at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804)<br /> at org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)<br /> at org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:228)<br /> at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469)<br /> at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487)<br /> at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initListeners(WabBundleProcessor.java:571)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:217)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:184)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:106)<br /> at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:175)<br /> at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)<br /> at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)<br /> at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488)<br /> at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1)<br /> at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)<br /> at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)<br /> at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908)<br /> at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)<br /> at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)<br /> at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:230)<br /> at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:137)<br /> at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:129)<br /> at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:191)<br /> at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)<br /> at org.eclipse.osgi.container.Module.start(Module.java:467)<br /> at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)<br /> at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:447)<br /> at org.eclipse.equinox.console.commands.EquinoxCommandProvider.start(EquinoxCommandProvider.java:243)<br /> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br /> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)<br /> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<br /> at java.lang.reflect.Method.invoke(Method.java:498)<br /> at org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:139)<br /> at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)<br /> at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)<br /> at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)<br /> at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)<br /> at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416)<br /> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229)<br /> at org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59)<br /> at java.util.concurrent.FutureTask.run(FutureTask.java:266)<br /> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)<br /> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)<br /> at java.lang.Thread.run(Thread.java:748)<br />Caused by: java.lang.NoClassDefFoundError: ServiceLocator<br /> at java.lang.Class.getDeclaredMethods0(Native Method)<br /> at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)<br /> at java.lang.Class.getDeclaredMethods(Class.java:1975)<br /> at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:612)<br /> at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:523)<br /> at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:509)<br /> at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.determineCandidateConstructors(AutowiredAnnotationBeanPostProcessor.java:245)<br /> ... 107 more<br />Caused by: java.lang.ClassNotFoundException: ServiceLocator cannot be found by star-abm-dist-list_1.0.0<br /> at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)<br /> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:419)<br /> at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:411)<br /> at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)<br /> at java.lang.ClassLoader.loadClass(ClassLoader.java:357)<br /> ... 114 more<br /><br />Either way I am not being able to access the classes present in that jar. Can you help me understand how that correctly manage that dependency in the project?(Using Liferay Developer StudioVersion: 3.7.1.20191