Warm tip: This article is reproduced from stackoverflow.com, please click
java osgi portlet liferay-7 bnd

My portlet don't start after the adding of postgres jdbc in my portlet

发布于 2020-03-27 10:23:21

I have a problem with my OSGI portlet. I added jdbc.jar in my portlet via bnd.bnd.

This is how I did it:

Bundle-Name: bd-portlet
Bundle-SymbolicName: com.test
Bundle-Version: 1.0.0
Export-Package: com.test.constants
Bundle-ClassPath:\
  .,\
  lib/postgresql.jar
-includeresource:\
  lib/postgresql.jar=postgresql-42.2.5.jar

I see the jar of my portlet and jdbc is present in lib folder. But now my portlet doesn't start. Here is the screen output:

org.osgi.framework.BundleException: Could not resolve module: com.test 2019-07-03 14:13:51.054 ERROR [Framework Event Dispatcher: Equinox Container: e04d1c6e-9a3c-4356-88d0-325b8207118b][com_test:97] FrameworkEvent ERROR 
org.osgi.framework.BundleException: Could not resolve module: com.test [1012]_  Unresolved requirement: Import-Package: com.sun.jna_ [Sanitized]
    at org.eclipse.osgi.container.Module.start(Module.java:444)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1682)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.incStartLevel(ModuleContainer.java:1662)
    at org.eclipse.osgi.container.ModuleContainer$ContainerStartLevel.doContainerStartLevel(ModuleContainer.java:1624)
    at org.eclipse.osgi.container.SystemModule.startWorker(SystemModule.java:264)
    at org.eclipse.osgi.container.Module.doStart(Module.java:581)
    at org.eclipse.osgi.container.Module.start(Module.java:449)
    at org.eclipse.osgi.container.SystemModule.start(SystemModule.java:188)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
    at org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:447)
    at org.eclipse.osgi.launch.Equinox.start(Equinox.java:115)
    at com.liferay.portal.bootstrap.ModuleFrameworkImpl.startFramework(ModuleFrameworkImpl.java:403)
    at com.liferay.portal.module.framework.ModuleFrameworkUtilAdapter.startFramework(ModuleFrameworkUtilAdapter.java:100)
    at com.liferay.portal.spring.context.PortalContextLoaderListener.contextInitialized(PortalContextLoaderListener.java:309)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4682)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5150)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:631)
    at org.apache.catalina.startup.HostConfig$DeployDescriptor.run(HostConfig.java:1832)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:526)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:425)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1577)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:424)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:367)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:929)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:831)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1377)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1367)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:902)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:423)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:928)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:634)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:350)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:492)

I added com.sun.jna into my build.gradle and into my bnd.bnd file :

Bundle-Name: bd-portlet
Bundle-SymbolicName: com.test
Bundle-Version: 1.0.0
Export-Package: com.test.constants
Bundle-ClassPath:\
  .,\
  lib/postgresql.jar,\lib/jna.jar
-includeresource:\
  lib/postgresql.jar=postgresql-42.2.5.jar,\
  lib/jna.jar=jna-3.0.9.jar

, but nothing changed. My portlet doesn't start. Does anybody have an idea, please?

Questioner
Franck Might
Viewed
27
Franck Might 2019-07-04 06:17

I solved the problem. When we have :

org.osgi.framework.BundleException: Could not resolve module: com.test [1012]_  Unresolved requirement: Import-Package: xxxxxx [Sanitized]

Just add :

Import-Package: \
!xxxxxx,\
*

In your bnd.bnd file. In my case i will add :

Import-Package: \
  !com.sun.*,\
  *

In my bnd.bnd file.