Fórum

Liferay 7. Use Wildfly modules on portlet deployment

Costin Pirosca, modificado 7 Anos atrás.

Liferay 7. Use Wildfly modules on portlet deployment

New Member Postagens: 8 Data de Entrada: 26/06/15 Postagens Recentes
Hello,
Migrating the java portlets from 6.1 to 7.

I am trying to use the Wildfly 10 default modules in MANIFEST instead of adding the specific jar in the lib folder. My problem is that the portlets are not recognizing the module dependencies from pom.xml. I have tried with import-packages, dinamicimport-packages and so on. Nothing seems to work. Is this caused by the OSGI architecture and if so how can i fix this? The portlets are compiled into .war files, deploied in /opt/deploy and finally they appear under /opt/osgi/war.

This is my stacktrace:

Caused by: java.lang.NoClassDefFoundError: org/codehaus/jackson/type/TypeReference
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 com.liferay.portlet.PortletBagFactory.getPortletInstance(PortletBagFactory.java:303)
at com.liferay.portlet.PortletBagFactory.create(PortletBagFactory.java:106)
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:497)
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.$Proxy177.initWAR(Unknown Source)
at com.liferay.portal.kernel.service.PortletLocalServiceUtil.initWAR(PortletLocalServiceUtil.java:326)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:210)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:95)
... 65 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.jackson.type.TypeReference cannot be found by utl_duetoday-portlet_1.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)
... 82 more

This implementation worked in liferay 6.1 with Jboss 7, but there all my portlets were under standalone/deployments. If this change is the cause is there anyway that the deployed portlets will end up in the deployments folder?

I don't really know if this topic should be here or under Development. I hope i have posted it right.

Thank you!
Costin
Nicolas Ballinas, modificado 7 Anos atrás.

RE: Liferay 7. Use Wildfly modules on portlet deployment

New Member Postagens: 7 Data de Entrada: 28/03/12 Postagens Recentes
Hello Costin,

Did you solve this issue? We are facing the same problems with our own dependencies defined as global-modules in standalone.xml, but no luck so far. We tried adding them to both to module.framework.system.packages.extra and DynamicImport-Package in portal-ext.properties, and nothing seems to work. To be honest I am still confused over how these properties are meant to be used, and I am not really sure I am on the right track to solve this, so if you have made any progress it could be of much help.

Cheers
Nicolas
thumbnail
Juan Gonzalez, modificado 7 Anos atrás.

RE: Liferay 7. Use Wildfly modules on portlet deployment

Liferay Legend Postagens: 3089 Data de Entrada: 28/10/08 Postagens Recentes
Apart from adding those packages in properties as you said, did you test adding those imports in jboss-deployment-structure.xml in Liferay's WAR?
Nicolas Ballinas, modificado 7 Anos atrás.

RE: Liferay 7. Use Wildfly modules on portlet deployment

New Member Postagens: 7 Data de Entrada: 28/03/12 Postagens Recentes
Juan Gonzalez:
Apart from adding those packages in properties as you said, did you test adding those imports in jboss-deployment-structure.xml in Liferay's WAR?


Thank you Juan, but adding our modules under dependencies in jboss-deployment-structure.xml didn't help.

Maybe I'm way off, but it feels like I am missing something in the manifest. Does my deployed jar (the one I am including as a global module in wildfly's standalone.xml) need something specific in the manifest to be accessible from the OSGi context? In Liferay 6.2 we could just deploy global modules in JBoss and we could access them from the portlets without adding anything at all in the manifest.

Thanks for any help
Nicolas Ballinas, modificado 7 Anos atrás.

RE: Liferay 7. Use Wildfly modules on portlet deployment

New Member Postagens: 7 Data de Entrada: 28/03/12 Postagens Recentes
After a lot of trial and error I managed to solve it! For others having similar issues, the solution actually lies in adding the Java packages you want exported to the module framework in module.framework.system.packages.extra, nothing else. So no extra meta data in manifest files, or adding module dependencies in jboss-deployment-structure.xml was needed.

Thank you again Juan for trying to help, and also to the original poster for giving me some hints by having a similar problem emoticon

For some interesting reading check out this blog post about OSGi Module Dependencies.
It helped me to understand the problem I was facing, especially Miguel Angel Olivar's comment about Option 1 further down:
"Option 1 is not completely accurate. Not everything you put into the global class loader of the App Server will be accessible from the OSGi container. We have a fine grained control on what we export; you will need to play with the module.framework.system.packages.extra property in your portal-ext.properties file."

Edit: fixed links