Foren

LR7CEGA2 Module Authentication including jars

thumbnail
darren rose, geändert vor 7 Jahren.

LR7CEGA2 Module Authentication including jars

Regular Member Beiträge: 215 Beitrittsdatum: 04.04.15 Neueste Beiträge
Hi,

I am creating a module to override authentication.

The issue I have when deploying is:

Failed to update bundle: /opt/liferay/liferay-ce-portal-7.0-ga2/osgi/modules/module-authentication-v7-1.0.0.jar with ID 498. The bundle has been uninstalled
13:40:27,781 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:252] Processing module-authentication-v7-1.0.1.jar
13:40:54,740 ERROR [http-nio-8080-exec-1][PortletServlet:109] javax.portlet.PortletException: org.osgi.framework.BundleException: Could not resolve module: module-authentication-v7 [499]_ Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation_ [Sanitized]
javax.portlet.PortletException: org.osgi.framework.BundleException: Could not resolve module: module-authentication-v7 [499]_ Unresolved requirement: Import-Package: com.fasterxml.jackson.annotation_ [Sanitized]
at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:202)


build.gradle dependencies

dependencies {
compile 'org.codehaus.groovy:groovy-all:' + groovyVersion
compile 'org.springframework:spring-context:' + springVersion
compile 'org.springframework:spring-web:' + springVersion
compile 'com.fasterxml.jackson.core:jackson-core:' + jacksonVersion
compile 'com.fasterxml.jackson.core:jackson-databind:' + jacksonVersion
compile 'com.liferay.portal:com.liferay.portal.kernel:2.3.0'
compile 'org.osgi:org.osgi.service.component.annotations:1.3.0'
testCompile 'junit:junit:' + junitVersion
}

bnd.bnd

Bundle-Version: 1.0.1
-includeresource: @spring-context-4.2.5.RELEASE.jar
-includeresource: @spring-web-4.2.5.RELEASE.jar
-includeresource: @jackson-core-2.5.1.jar
-includeresource: @jackson-databind-2.5.1.jar
-sources: true
thumbnail
darren rose, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Regular Member Beiträge: 215 Beitrittsdatum: 04.04.15 Neueste Beiträge
I updated my bnd.bnd as follows, so that all the libs are included

Bundle-Version: 1.0.2
-includeresource: @spring-context-4.2.5.RELEASE.jar, @spring-web-4.2.5.RELEASE.jar, @jackson-core-2.5.1.jar, @jackson-databind-2.5.1.jar
-sources: true

now I see

14:09:00,881 INFO [com.liferay.portal.kernel.deploy.auto.AutoDeployScanner][AutoDeployDir:252] Processing module-auth
entication-v7-1.0.2.jar
14:09:21,881 ERROR [http-nio-8080-exec-2][PortletServlet:109] javax.portlet.PortletException: org.osgi.framework.Bundl
eException: Could not resolve module: module-authentication-v7 [500]_ Unresolved requirement: Import-Package: bsh_
javax.portlet.PortletException: org.osgi.framework.BundleException: Could not resolve module: module-authentication-v7 [500]_ Unresolved requirement: Import-Package: bsh_ [Sanitized]
at com.liferay.portal.kernel.portlet.LiferayPortlet.callActionMethod(LiferayPortlet.java:202)
at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.callActionMethod(MVCPortlet.java:392)
at com.liferay.portal.kernel.portlet.LiferayPortlet.processAction(LiferayPortlet.java:93)
at com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet.processAction(MVCPortlet.java:249)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:71)
at com.liferay.portlet.CheckboxParametersPortletFilter.doFilter(CheckboxParametersPortletFilter.java:57)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:68)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:48)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:105)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at com.liferay.portal.osgi.web.servlet.context.helper.internal.ServletContextHelperRegistrationImpl$PortletServletWrapper.service(ServletContextHelperRegistrationImpl.java:427)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:50
thumbnail
Gregory Amerson, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Liferay Legend Beiträge: 1123 Beitrittsdatum: 16.02.10 Neueste Beiträge
Hey Darren,

Can you share this failing bundle as a single project in github? That way we can import it in Liferay IDE and try it out and see what it takes to get the bundle running. It is likely a properly configured bnd.bnd file to block some imports

Import-Package: \
   !bsh_.*,\
   *


Or something similar.

Another alternative is to get a OSGi compatible jackson jar if one is available. See here:
http://download.eclipse.org/tools/orbit/downloads/drops/R20160520211859/
thumbnail
darren rose, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Regular Member Beiträge: 215 Beitrittsdatum: 04.04.15 Neueste Beiträge
Hi Greg,
Will do that.
regards
thumbnail
David H Nebinger, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
darren rose:
Unresolved requirement: Import-Package: bsh_


So I kind of hinted about this in my recent blog post... For options 3 and 4, you need to include your dependency jars as well as those that are dependencies of the dependencies.

In your case you're missing beanshell.

runtime group: 'bsh', name: 'bsh', version: '2.0b4'
thumbnail
darren rose, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Regular Member Beiträge: 215 Beitrittsdatum: 04.04.15 Neueste Beiträge
why do I need that dependency?
an example with multiple external dependencies, spring and jackson, would help greatly.
thumbnail
David H Nebinger, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
darren rose:
why do I need that dependency?


Because you also need to satisfy dependencies of dependencies. I'm guessing that either spring or jackson leverages beanshell to do some of it's magic and therefore needs bsh, but it's only a guess.

The point is, if you are using a jar that has a dependency on something else, it's going to be your responsibility to provide the dependency or find a way to block the dependency (such as Greg's example).

Ah, just found it. If you check out the compile dependencies for spring context, you'll find the dependency on bsh: https://mvnrepository.com/artifact/org.springframework/spring-context/4.2.5.RELEASE
thumbnail
darren rose, geändert vor 7 Jahren.

RE: LR7CEGA2 Module Authentication including jars

Regular Member Beiträge: 215 Beitrittsdatum: 04.04.15 Neueste Beiträge
when I build the hook as a war, I don't have these issues. building as an osgi module so far is a complete pain.