Fórum

JSF Portlet on Liferay 7 Wildfly bundle

Oleksandr Druzhynin, modificado 7 Anos atrás.

JSF Portlet on Liferay 7 Wildfly bundle

New Member Postagens: 6 Data de Entrada: 15/11/13 Postagens Recentes
Hello all,

I'm trying to get working the JSF demo Portlet .
I have a fresh installation of Liferay 7 bundled with wildfly.
I checked out sources from https://github.com/liferay/liferay-faces-bridge-impl.git 4.x branch and built demo jsf-applicant-portlet project with maven :
mvn clean install  -P liferay,jboss

and deployed the resulting war file while getting the following exception stacktrace:

[HotDeployImpl:240] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for comliferayfacesdemojsfapplicantportlet-401-SNAPSHOT
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for comliferayfacesdemojsfapplicantportlet-401-SNAPSHOT
	at com.liferay.portal.kernel.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:38)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:98)
	at com.liferay.portal.deploy.hot.HotDeployImpl.doFireDeployEvent(HotDeployImpl.java:237)
	at com.liferay.portal.deploy.hot.HotDeployImpl.fireDeployEvent(HotDeployImpl.java:104)
	at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:28)
	at com.liferay.portal.kernel.servlet.PluginContextListener.fireDeployEvent(PluginContextListener.java:164)
	at com.liferay.portal.kernel.servlet.PluginContextListener.doPortalInit(PluginContextListener.java:154)
	at com.liferay.portal.kernel.util.BasePortalLifecycle.portalInit(BasePortalLifecycle.java:44)
	at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:74)
	at com.liferay.portal.kernel.util.PortalLifecycleUtil.register(PortalLifecycleUtil.java:58)
	at com.liferay.portal.kernel.util.BasePortalLifecycle.registerPortalLifecycle(BasePortalLifecycle.java:54)
	at com.liferay.portal.kernel.servlet.PluginContextListener.contextInitialized(PluginContextListener.java:116)
	at com.liferay.portal.osgi.web.wab.extender.internal.adapter.ServletContextListenerExceptionAdapter.contextInitialized(ServletContextListenerExceptionAdapter.java:51)
	at sun.reflect.GeneratedMethodAccessor441.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.eclipse.equinox.http.servlet.internal.registration.ListenerRegistration$EventListenerInvocationHandler.invoke(ListenerRegistration.java:132)
	at com.sun.proxy.$Proxy489.contextInitialized(Unknown Source)
	at org.eclipse.equinox.http.servlet.internal.context.ContextController.doAddListenerRegistration(ContextController.java:359)
	at org.eclipse.equinox.http.servlet.internal.context.ContextController.addListenerRegistration(ContextController.java:312)
	at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:67)
	at org.eclipse.equinox.http.servlet.internal.customizer.ContextListenerTrackerCustomizer.addingService(ContextListenerTrackerCustomizer.java:1)
	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:941)
	at org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
	at org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:901)
	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.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:482)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1001)
	at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.initListeners(WabBundleProcessor.java:526)
	at com.liferay.portal.osgi.web.wab.extender.internal.WabBundleProcessor.init(WabBundleProcessor.java:152)
	at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer._initWabBundle(WebBundleDeployer.java:186)
	at com.liferay.portal.osgi.web.wab.extender.internal.WebBundleDeployer.doStart(WebBundleDeployer.java:106)
	at com.liferay.portal.osgi.web.wab.extender.internal.WabFactory$WABExtension.start(WabFactory.java:162)
	at org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
	at org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:482)
	at org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1)
	at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
	at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:444)
	at org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:905)
	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.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:165)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:75)
	at org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:67)
	at org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:102)
	at org.eclipse.osgi.container.Module.publishEvent(Module.java:461)
	at org.eclipse.osgi.container.Module.start(Module.java:452)
	at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:402)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundle(DirectoryWatcher.java:1252)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.startBundles(DirectoryWatcher.java:1224)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.doProcess(DirectoryWatcher.java:512)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.process(DirectoryWatcher.java:361)
	at org.apache.felix.fileinstall.internal.DirectoryWatcher.run(DirectoryWatcher.java:313)
Caused by: java.util.ServiceConfigurationError: javax.portlet.faces.Bridge: Provider com.liferay.faces.bridge.internal.BridgeImpl could not be instantiated
	at java.util.ServiceLoader.fail(ServiceLoader.java:232)
	at java.util.ServiceLoader.access$100(ServiceLoader.java:185)
	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:384)
	at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:404)
	at java.util.ServiceLoader$1.next(ServiceLoader.java:480)
	at javax.portlet.faces.GenericFacesPortlet.getBridgeService(GenericFacesPortlet.java:709)
	at javax.portlet.faces.GenericFacesPortlet.getBridge(GenericFacesPortlet.java:680)
	at javax.portlet.faces.GenericFacesPortlet.init(GenericFacesPortlet.java:388)
	at com.liferay.portlet.InvokerPortletImpl.init(InvokerPortletImpl.java:296)
	at com.liferay.portlet.PortletInstanceFactoryImpl.init(PortletInstanceFactoryImpl.java:288)
	at com.liferay.portlet.PortletInstanceFactoryImpl.create(PortletInstanceFactoryImpl.java:193)
	at com.liferay.portal.kernel.portlet.PortletInstanceFactoryUtil.create(PortletInstanceFactoryUtil.java:49)
	at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:217)
	at com.liferay.portal.service.impl.PortletLocalServiceImpl.initWAR(PortletLocalServiceImpl.java:858)
	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 com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
	at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
	at com.sun.proxy.$Proxy124.initWAR(Unknown Source)
	at com.liferay.portal.kernel.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:327)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:210)
	at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:95)
	... 62 more
Caused by: java.lang.NoClassDefFoundError: javax/faces/FacesException
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:330)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:407)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:272)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:588)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:540)
	at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:527)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:324)
	at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:330)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:407)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
	at java.lang.Class.getConstructor0(Class.java:3075)
	at java.lang.Class.newInstance(Class.java:412)
	at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:380)
	... 83 more
Caused by: java.lang.ClassNotFoundException: javax.faces.FacesException cannot be found by com.liferay.faces.demo.jsf.applicant.portlet-4.0.1-SNAPSHOT_4.0.0
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:444)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:357)
	at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:349)
	at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 116 more

If I download jsf applicant portlet and deploy it, it works fine.
This is because necessary dependencies are bundled within a war file. But I want to use that dependencies provided by application server. How can I achieve it?

Thank you in advance!
thumbnail
Neil Griffin, modificado 7 Anos atrás.

RE: JSF Portlet on Liferay 7 Wildfly bundle

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
Hi Oleksandr,

Try this:
mvn -P liferay,mojarra clean install


The jboss profile is meant for use with the liferay62 profile with JBoss AS 7, so it's not applicable for Liferay 7 and WildFly.

Kind Regards,

Neil
Oleksandr Druzhynin, modificado 7 Anos atrás.

RE: JSF Portlet on Liferay 7 Wildfly bundle

New Member Postagens: 6 Data de Entrada: 15/11/13 Postagens Recentes
Thank you very much Neil, this works. I'm only starting to develop on Liferay and have yet no much experience with it.
The resulting war-file contains now jsf-api and jsf-impl in the javax.faces-2.2.13.jar dependency.
Similar, I had to add Weld CDI dependency to the pom.xml:

<dependency>
	<groupid>org.jboss.weld.servlet</groupid>
	<artifactid>weld-servlet</artifactid>
	<scope>runtime</scope>
</dependency>

in order to get jsf-cdi-applicant Portlet working on wildfly.

But I still wondering, why is it necessary these dependencies to have compile or runtime scope?
I choose wildfly bundle for Liferay because it already have the full EE stack on board. Is it possible somehow to leverage such APIs and their implementations that are native on application server?
Wildfly have JSF and CDI modules in modules/system/layers/base:
JSF API: javax/faces/api
Mojarra: com/sun/jsf-impl
CDI API: javax/enterprise/api
Weld: org/jboss/weld/core

It would be nice to force Liferay to load these modules from application server instead of providing them every time within an own portlet.
The only question is - how?

Thank you and best Regards,
Oleksandr
thumbnail
Neil Griffin, modificado 7 Anos atrás.

RE: JSF Portlet on Liferay 7 Wildfly bundle (Resposta)

Liferay Legend Postagens: 2655 Data de Entrada: 27/07/05 Postagens Recentes
Hi Oleksandr,

Versions of Liferay prior to version 7 relied on the out-of-the-box provision of Java EE technologies (JSF, CDI, etc.) by app servers like WildFly, GlassFish, etc..

Although Liferay 7 can be used in WildFly, it is based on OSGi which does not rely on those types of out-of-the-box features. Instead, the classpath is determined by OSGi bundle requirements.

We are currently working on ways of deploying Mojarra (JSF), Weld (CDI), and Liferay Faces Bridge as OSGi bundles, but we aren't there yet. As a transitional phase, you will need to include those jars in the WEB-INF/lib folder of your portlet applications.

Kind Regards,

Neil