Trouble Building rest-app-jpa in Postges Example

218 views
Skip to first unread message

robert.p...@leidos.com

unread,
Feb 14, 2018, 9:38:35 AM2/14/18
to bndtools-users
Hi,

I have imported projects indexes, dao-api, dao-impl-jpa, rest-service, and rest-app-jpa from the R7 Postgres example from here:  https://github.com/timothyjward/osgi.enroute/tree/postgres

I have created our own packages, added our Java code, removed the example Java code (after mimicking it), and changed the pom.xml files to make it all build with our groupId.

I've got all of the projects buildig, except for rest-app-jpa.  I'm getting this exception when I try to build rest-app-jpa:

[ERROR] Error   : Cannot find /error/my.project.dao-impl;version=7.0.0 Not found in [rest-app-jpa [org.apache.felix.http.jetty,org.apache.aries.javax.annotation-api,net.bytebuddy.byte-buddy,org.apache.felix.configurator,org.eclipse.equinox.event,org.osgi.service.event,org.apache.felix.log,org.apache.johnzon.mapper,org.apache.aries.javax.jax.rs-api,org.hibernate.common.hibernate-commons-annotations,org.apache.felix.http.servlet-api,tx-control-provider-jdbc-xa,org.apache.servicemix.bundles.dom4j,javassist,osgi.core,org.apache.felix.framework,org.jboss.spec.javax.transaction.jboss-transaction-api_1.2_spec,org.apache.servicemix.specs.json-api-1.1,org.apache.aries.jax.rs.whiteboard,ch.qos.logback.classic,org.apache.felix.scr,org.osgi.util.promise,my.project.dao-impl-jpa,org.apache.johnzon.core,org.jboss.jandex,org.hibernate.osgi,my.project.rest-service,org.osgi.service.http.whiteboard,org.osgi.service.jaxrs,org.apache.commons.fileupload,ch.qos.logback.core,osgi.cmpn,org.apache.commons.io,org.osgi.util.converter,org.hibernate.javax.persistence.hibernate-jpa-2.1-api,tx-control-provider-jpa-xa,org.osgi.util.function,org.apache.servicemix.bundles.antlr,org.apache.felix.configadmin,org.osgi.service.log,org.eclipse.equinox.metatype,org.hibernate.core,my.project.rest-app-jpa,com.fasterxml.classmate,org.apache.aries.jpa.container,tx-control-service-xa,slf4j.api,org.apache.aries.jpa.javax.persistence_2.0,javax.interceptor-api,my.project.dao-api,org.jboss.logging.jboss-logging,org.apache.aries.jpa.javax.persistence_2.1,javax.json-api,org.osgi.util.pushstream,org.postgresql.jdbc42 r/w=false], bnd-cache [/home/afatdsprod/pepersacr/osgiSpikeMaven/microservice/rest-app-jpa/target/tmp/export/rest-app-jpa/cnf/cache/4.0.0/bnd-cache r/w=false], repo01 [/home/afatdsprod/pepersacr/osgiSpikeMaven/microservice/rest-app-jpa/target/tmp/export/rest-app-jpa/cnf/cache/4.0.0/repo01 r/w=false]]
[ERROR] Error   : my.project.dao-impl;version=7.0.0 Not found in [rest-app-jpa [org.apache.felix.http.jetty,org.apache.aries.javax.annotation-api,net.bytebuddy.byte-buddy,org.apache.felix.configurator,org.eclipse.equinox.event,org.osgi.service.event,org.apache.felix.log,org.apache.johnzon.mapper,org.apache.aries.javax.jax.rs-api,org.hibernate.common.hibernate-commons-annotations,org.apache.felix.http.servlet-api,tx-control-provider-jdbc-xa,org.apache.servicemix.bundles.dom4j,javassist,osgi.core,org.apache.felix.framework,org.jboss.spec.javax.transaction.jboss-transaction-api_1.2_spec,org.apache.servicemix.specs.json-api-1.1,org.apache.aries.jax.rs.whiteboard,ch.qos.logback.classic,org.apache.felix.scr,org.osgi.util.promise,my.project.dao-impl-jpa,org.apache.johnzon.core,org.jboss.jandex,org.hibernate.osgi,my.project.rest-service,org.osgi.service.http.whiteboard,org.osgi.service.jaxrs,org.apache.commons.fileupload,ch.qos.logback.core,osgi.cmpn,org.apache.commons.io,org.osgi.util.converter,org.hibernate.javax.persistence.hibernate-jpa-2.1-api,tx-control-provider-jpa-xa,org.osgi.util.function,org.apache.servicemix.bundles.antlr,org.apache.felix.configadmin,org.osgi.service.log,org.eclipse.equinox.metatype,org.hibernate.core,my.project.rest-app-jpa,com.fasterxml.classmate,org.apache.aries.jpa.container,tx-control-service-xa,slf4j.api,org.apache.aries.jpa.javax.persistence_2.0,javax.interceptor-api,my.project.dao-api,org.jboss.logging.jboss-logging,org.apache.aries.jpa.javax.persistence_2.1,javax.json-api,org.osgi.util.pushstream,org.postgresql.jdbc42 r/w=false], bnd-cache [/home/afatdsprod/pepersacr/osgiSpikeMaven/microservice/rest-app-jpa/target/tmp/export/rest-app-jpa/cnf/cache/4.0.0/bnd-cache r/w=false], repo01 [/home/afatdsprod/pepersacr/osgiSpikeMaven/microservice/rest-app-jpa/target/tmp/export/rest-app-jpa/cnf/cache/4.0.0/repo01 r/w=false]]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] microservice ....................................... SUCCESS [  0.620 s]
[INFO] dao-api ............................................ SUCCESS [  3.808 s]
[INFO] rest-service ....................................... SUCCESS [  1.166 s]
[INFO] dao-impl-jpa ....................................... SUCCESS [  0.525 s]
[INFO] rest-app-jpa ....................................... FAILURE [  6.372 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.658 s
[INFO] Finished at: 2018-02-14T09:29:16-05:00
[INFO] Final Memory: 29M/307M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal biz.aQute.bnd:bnd-export-maven-plugin:4.0.0-SNAPSHOT:export (default) on project rest-app-jpa: 2 errors found -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal biz.aQute.bnd:bnd-export-maven-plugin:4.0.0-SNAPSHOT:export (default) on project rest-app-jpa: 2 errors found
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
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 org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: 2 errors found
at aQute.bnd.maven.export.plugin.ExportMojo.execute(ExportMojo.java:103)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more

Also, I get this error when I click the "Resolve" button on rest-app-jpa.bndrun:

Unable to resolve <<INITIAL>> version=null:
   missing requirement my.project.rest-service 

->  Unable to resolve my.project.rest-service version=7.0.0.201802141429:
   missing requirement org.osgi.framework; version=[1.9.0,2.0.0)]

Here is the configuration in the "Source" tab:

index: target/index.xml

-standalone: ${index}

-resolve.effective: active

# Needed because the JRE has a split package for javax.transaction and a uses
# constraint between javax.sql and javax.transaction. This breaks JPA unless
# the JTA API is always provided from outside the OSGi framework
-runpath: org.jboss.spec.javax.transaction.jboss-transaction-api_1.2_spec;version=1.0.1.Final

# Hibernate has versioned imports for JTA, and its dependency dom4j has versioned
# imports for the STAX API. Both of these should come from the JRE
-runsystempackages: \
  javax.transaction;version=1.2.0,\
  javax.transaction.xa;version=1.2.0,\
  javax.xml.stream;version=1.0.0,\
  javax.xml.stream.events;version=1.0.0,\
  javax.xml.stream.util;version=1.0.0

-runrequires: \
osgi.identity;filter:='(osgi.identity=org.apache.johnzon.core)',\
bnd.identity;id='org.postgresql.jdbc42',\
osgi.identity;filter:='(osgi.identity=my.project.rest-service)'
-runfw: org.apache.felix.framework
-runee: JavaSE-1.8
-runbundles: \
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
org.apache.aries.javax.annotation-api;version='[0.0.1,0.0.2)',\
org.apache.aries.javax.jax.rs-api;version='[0.0.1,0.0.2)',\
org.apache.aries.jax.rs.whiteboard;version='[0.0.1,0.0.2)',\
org.apache.felix.configadmin;version='[1.9.0,1.9.1)',\
org.apache.felix.http.jetty;version='[3.4.7,3.4.8)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.0,2.1.1)',\
org.osgi.service.jaxrs;version='[1.0.0,1.0.1)',\
org.osgi.util.converter;version='[1.0.0,1.0.1)',\
org.osgi.util.function;version='[1.1.0,1.1.1)',\
org.osgi.util.promise;version='[1.1.0,1.1.1)',\
slf4j.api;version='[1.7.25,1.7.26)',\
tx-control-service-xa;version='[1.0.0,1.0.1)',\
org.apache.felix.configurator;version='[0.0.1,0.0.2)',\
org.apache.servicemix.specs.json-api-1.1;version='[2.9.0,2.9.1)',\
org.apache.johnzon.core;version='[1.1.0,1.1.1)',\
com.fasterxml.classmate;version='[1.3.0,1.3.1)',\
javassist;version='[3.20.0,3.20.1)',\
org.apache.aries.jpa.container;version='[2.7.0,2.7.1)',\
org.apache.aries.jpa.javax.persistence_2.1;version='[2.7.0,2.7.1)',\
org.apache.servicemix.bundles.antlr;version='[2.7.7,2.7.8)',\
org.apache.servicemix.bundles.dom4j;version='[1.6.1,1.6.2)',\
org.hibernate.common.hibernate-commons-annotations;version='[5.0.1,5.0.2)',\
org.hibernate.core;version='[5.2.12,5.2.13)',\
org.hibernate.javax.persistence.hibernate-jpa-2.1-api;version='[1.0.0,1.0.1)',\
org.hibernate.osgi;version='[5.2.12,5.2.13)',\
org.jboss.jandex;version='[2.0.3,2.0.4)',\
org.jboss.logging.jboss-logging;version='[3.3.0,3.3.1)',\
tx-control-provider-jpa-xa;version='[1.0.0,1.0.1)',\
org.postgresql.jdbc42;version='[9.4.1212,9.4.1213)',\
osgi.cmpn;version='[4.3.1,4.3.2)',\
my.project.rest-service;version='7.0.0',\
my.project.rest-app-jpa;version='7.0.0',\
my.project.dao-api;version='7.0.0',\
my.project.dao-impl;version='7.0.0'


Thanks!

robert.p...@leidos.com

unread,
Feb 14, 2018, 2:10:04 PM2/14/18
to bndtools-users
I have one of these issues resolved.  It was a problem with how I declared the versions of my SNAPSHOT bundles.

I'm still getting this exception when I try to resolve rest-app-jpa:

! Failed to start bundle my.project.rest-service-7.0.0.201802141848, exception Unable to resolve my.project.rest-service [36](R 36.0): missing requirement [my.project.rest-service [36](R 36.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.9.0)(!(version>=2.0.0))) Unresolved requirements: [[my.project.rest-service [36](R 36.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.9.0)(!(version>=2.0.0)))]
org.osgi.framework.BundleException: Unable to resolve my.project.rest-service [36](R 36.0): missing requirement [my.project.rest-service [36](R 36.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.9.0)(!(version>=2.0.0))) Unresolved requirements: [[my.project.rest-service [36](R 36.0)] osgi.wiring.package; (&(osgi.wiring.package=org.osgi.framework)(version>=1.9.0)(!(version>=2.0.0)))]
at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:4149)
at org.apache.felix.framework.Felix.startBundle(Felix.java:2119)
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:998)
at aQute.launcher.Launcher.startBundles(Launcher.java:502)
at aQute.launcher.Launcher.activate(Launcher.java:409)
at aQute.launcher.Launcher.run(Launcher.java:289)
at aQute.launcher.Launcher.main(Launcher.java:142)

This seems strange to me because org.osgi.framework was not required in the example project's rest-server.

Raymond Auge

unread,
Feb 14, 2018, 3:04:23 PM2/14/18
to bndtool...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

Raymond Auge

unread,
Feb 14, 2018, 3:11:04 PM2/14/18
to bndtool...@googlegroups.com
I think the problem however is not with resolve, but with startup... which seems weird considering this issue should have been caught during resolve.

It looks like your runtime framework doesn't provide the package at the correct version!

- Ray

robert.p...@leidos.com

unread,
Feb 15, 2018, 8:14:05 AM2/15/18
to bndtools-users
You are correct.  I do need an implementation of org.osgi.framework, and I do.  My run-app-jpa.bndrun is below, with my -runfw:  org.apache.felix.framework.

Also, I get the same error from both clicking the "Resolve" button and in the console when I click "Run OSGi".  Since my last post, I have tried this with Bndtools 3.5 and 4.0.

index: target/index.xml

-standalone: ${index}

-resolve.effective: active

# Needed because the JRE has a split package for javax.transaction and a uses
# constraint between javax.sql and javax.transaction. This breaks JPA unless
# the JTA API is always provided from outside the OSGi framework
-runpath: org.jboss.spec.javax.transaction.jboss-transaction-api_1.2_spec;version=1.0.1.Final

# Hibernate has versioned imports for JTA, and its dependency dom4j has versioned
# imports for the STAX API. Both of these should come from the JRE
-runsystempackages: \
  javax.transaction;version=1.2.0,\
  javax.transaction.xa;version=1.2.0,\
  javax.xml.stream;version=1.0.0,\
  javax.xml.stream.events;version=1.0.0,\
  javax.xml.stream.util;version=1.0.0

-runrequires: \
osgi.identity;filter:='(osgi.identity=my.project.rest-service)',\
osgi.identity;filter:='(osgi.identity=org.apache.johnzon.core)',\
bnd.identity;id='org.postgresql.jdbc42'
-runfw: org.apache.felix.framework
-runee: JavaSE-1.8
-runbundles: \
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
ch.qos.logback.core;version='[1.2.3,1.2.4)',\
org.apache.aries.javax.annotation-api;version='[0.0.1,0.0.2)',\
org.apache.aries.javax.jax.rs-api;version='[0.0.1,0.0.2)',\
org.apache.aries.jax.rs.whiteboard;version='[0.0.1,0.0.2)',\
org.apache.felix.configadmin;version='[1.9.0,1.9.1)',\
org.apache.felix.http.jetty;version='[3.4.7,3.4.8)',\
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
org.apache.felix.scr;version='[2.1.0,2.1.1)',\
org.osgi.service.jaxrs;version='[1.0.0,1.0.1)',\
org.osgi.util.converter;version='[1.0.0,1.0.1)',\
org.osgi.util.function;version='[1.1.0,1.1.1)',\
org.osgi.util.promise;version='[1.1.0,1.1.1)',\
slf4j.api;version='[1.7.25,1.7.26)',\
tx-control-service-xa;version='[1.0.0,1.0.1)',\
org.apache.felix.configurator;version='[0.0.1,0.0.2)',\
org.apache.servicemix.specs.json-api-1.1;version='[2.9.0,2.9.1)',\
org.apache.johnzon.core;version='[1.1.0,1.1.1)',\
org.apache.johnzon.mapper;version='[1.1.0,1.1.1)',\
com.fasterxml.classmate;version='[1.3.0,1.3.1)',\
javassist;version='[3.20.0,3.20.1)',\
org.apache.aries.jpa.container;version='[2.7.0,2.7.1)',\
org.apache.aries.jpa.javax.persistence_2.1;version='[2.7.0,2.7.1)',\
org.apache.servicemix.bundles.antlr;version='[2.7.7,2.7.8)',\
org.apache.servicemix.bundles.dom4j;version='[1.6.1,1.6.2)',\
org.hibernate.common.hibernate-commons-annotations;version='[5.0.1,5.0.2)',\
org.hibernate.core;version='[5.2.12,5.2.13)',\
org.hibernate.javax.persistence.hibernate-jpa-2.1-api;version='[1.0.0,1.0.1)',\
org.hibernate.osgi;version='[5.2.12,5.2.13)',\
org.jboss.jandex;version='[2.0.3,2.0.4)',\
org.jboss.logging.jboss-logging;version='[3.3.0,3.3.1)',\
tx-control-provider-jpa-xa;version='[1.0.0,1.0.1)',\
org.postgresql.jdbc42;version='[9.4.1212,9.4.1213)',\
osgi.cmpn;version='[4.3.1,4.3.2)',\
my.project.dao-api;version='[7.0.0,7.0.1)',\
my.project.rest-service;version='[7.0.0,7.0.1)',\
my.project.dao-impl-jpa;version='[7.0.0,7.0.1)',\
my.project.rest-app-jpa;version='[7.0.0,7.0.1)'

Thanks,
Bob
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

BJ Hargrave

unread,
Feb 15, 2018, 9:45:02 AM2/15/18
to bndtool...@googlegroups.com
Your bundle `my.project.rest-service` seems to have an Import-Package for org.osgi.framework;version=1.9. And the -runfw you are using does not offer that version. What version of osgi.core are you compiling your bundle against?
BJ

robert.p...@leidos.com

unread,
Feb 15, 2018, 10:50:05 AM2/15/18
to bndtools-users
It's the same version that the example uses.  The impl-index pom.xml file uses org.apache.felix.framework version 5.7.0-SNAPSHOT (see below).  I don't know what version of org.osgi.framework it implements.  I've been trying to figure that out.  org.osgi.framework is not in any of the example's pom.xmls' dependencies.  The rest-service project doesn't have a bnd file or a bndrun file, so I don't know where the 1.9 is coming from.  The POMs for osgi-api and rest-service do not have org.osgi.framework either.

<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>5.7.0-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>

Raymond Auge

unread,
Feb 15, 2018, 11:05:31 AM2/15/18
to bndtool...@googlegroups.com
Do you have a dependency on osgi.core 7.0.0-SNAPSHOT ? That's where the package org.osgi.framework became version 1.9 but you're not using a framework that implements this package version.

Maybe you're compiling against this SNAPSHOT?

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

BJ Hargrave

unread,
Feb 15, 2018, 11:06:39 AM2/15/18
to bndtool...@googlegroups.com
org.osgi.framework;version=1.9 is the Core R7 framework. Core R7 spec is only Proposed Final Draft.

I am asking about your bundle since it has the import for 1.9. What are the compile dependencies of your bundle?

Since you are based upon Tim's enRoute R7 work, you will likely be compiling against the OSGi R7 API [1] and I don't think Felix supports that yet. For now, you may need to use the latest Equinox build since Equinox is the framework RI.

Tim, who would know more, is on holiday for a couple of weeks.

Raymond Auge

unread,
Feb 15, 2018, 11:23:01 AM2/15/18
to bndtool...@googlegroups.com
I think Tim's enroute examples work ONLY because they do not seem to import the org.osgi.framework package anywhere.

However, if your code DID happen to touch the org.osgi.framework package then it would certainly blow up because it would compile against the R7 proposed final draft as mentioned by BJ and the runtime is NOT an R7 compatible framework. In fact there's not an R7 compatible framework indexed in any of the enroute indexes so I expect Tim was careful not to touch the updated packages from core R7.

If you DID need to use the core APIs, I would change the indexed dependency [1] to 6.0.0 to at least compile against a package that there's a released framework for (the configured one should work then).


To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
BJ

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

robert.p...@leidos.com

unread,
Feb 15, 2018, 12:11:36 PM2/15/18
to bndtools-users
Hi Ray and BJ,

I will answer all three of your posts here.

Yes, I am using osgi.core 7.0.0-SNAPSHOT.  Here are my dependencies in my osgi-api project, which I didn't change.

<dependencies>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.core</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.annotation</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
</dependencies>

I think that I'm compiling against this snapshot.  If Felix doesn't support OSGi R7 API, then how does Tim's example work?

Tim sent us an email to try to explain how these puzzle pieces fit together.  If you read it, then this may make sense to you.  Here his email:

I’ve pushed an example to https://github.com/timothyjward/osgi.enroute/tree/postgres. To keep things as simple as possible I’ve just branched OSGi enRoute R7 into a branch named ‘postgres’ and made the minimum necessary set of changes. This gives you a Maven build that produces an OSGi application using the following at runtime:

 

Apache Felix 5.7.0-SNAPSHOT (an R6 framework)

 Hibernate 5.2.12

Postgres JDBC 9.4.1212

Managed JPA using the Apache Aries JPA Container 2.7.0-SNAPSHOT and Apache Aries Transaction Control 1.0.0-SNAPSHOT

 

The changes I needed to make are visible in this commit https://github.com/timothyjward/osgi.enroute/commit/30f861ff6ba37dcbdc4a814f5c3c24e7d682ae17

 

I changed the H2 dependency in the rest-app-jpa pom to a dependency on the Postgres JDBC driver

I changed the H2 requirement in the rest-app-jpa.bndrun to require the Postgres JDBC driver

 I updated the rest-app-jpa configuration to connect to a Postgres server

I tweaked the table creation scripts in the dao-impl-jpa project to make them work on Postgres 9.4 (it doesn’t support the SQL “generated” keyword)

 

If you want to run this example against your own PostgreSQL database then you will need to change this line of configuration to point at your own server. You may also need to add configuration entries for “user” and “password” into that JSON object if your database requires authentication.

 

You should be able to build this example from the command line using “mvn verify” which will output a runnable jar file in examples/microservice/rest-app-jpa/target/rest-app-jpa.jar - this can simply be launched by running “java -jar rest-app-jpa.jar” and halted by hitting Ctrl+C. When the app is running there will be a REST API returning JSON at http://localhost:8080/person and a simple Polymer based UI at http://localhost:8080/microservice/index.html (note that this can take a few seconds to load the polymer javascript from the web). The UI will let you add people (and multiple addresses if you click ‘+’) to the database, and remove existing entries.

 

If you import the example into Eclipse (as an existing Maven project), and you have the latest Bndtools 4.0.0 snapshot (installation instructions here) then you will also be able to run the bndrun files directly from in the IDE. The debug.bndrun extends the rest-app-jpa.bndrun and adds Felix Gogo and Felix File install. If you make changes and want to re-resolve the application then this can be done from the IDE, or from the command line using “mvn bnd-resolver:resolve” on the rest-app-jpa project.

 

The official website documenting the R7 enRoute examples is still being written, however a rough cut of the base materials is visible at https://github.com/timothyjward/osgi.enroute.site/tree/R7 - the raw instructions for putting together the jdbc version of the microservice are visible at https://github.com/timothyjward/osgi.enroute.site/blob/R7/_tutorial/030-tutorial_microservice.md

 

 

Now - you’ve stated a desire to use R6 (which the application actually is) but I’m sure that you’ll notice that there are still snapshots being used (including of the bnd tooling). This is because the overall setup is a lot simpler if we’re able to use some of the build-time OSGi R7 annotations - this in turn is supported by bnd/bndtools 4.0.0-SNAPSHOT. The resulting code has no dependency on the OSGi framework API and can therefore be run on existing R5 and R6 implementations.

 

The sorts of things that the R7 binaries let us do are:

 

Require the JPA service and set up the bundle’s Meta-Persistence header without needing a bnd file

Serve a JAX-RS resource and static content in a type-safe way

Declare our need for a configuration provider

 

It is absolutely possible to remove these annotations and to declare the metadata manually (which would also remove the need for bnd 4.0.0-SNAPSHOT), but it adds quite a bit of noise to the bnd.bnd file for each bundle, and it also makes it much easier to make a typo when declaring things. The only parts of R7 that are actually directly required by this example are the JAX-RS whiteboard and the Transaction Control service.

robert.p...@leidos.com

unread,
Feb 15, 2018, 12:16:42 PM2/15/18
to bndtools-users
So, I think the mixture of R6 and R7 is causing my problem.

Raymond Auge

unread,
Feb 15, 2018, 12:24:55 PM2/15/18
to bndtool...@googlegroups.com
If you re-read my last post I explain precisely why you are having an issue.

Tim's code doesn't directly use the OSGi core framework APIs (i.e. org.osgi.framework) which means the examples never cause the onerous import to come in.

You need to review your code and do one of two things:

a) don't use any org.osgi.framework APIs in your code
b) make sure if you use them that you manually set the version import range to a version range supported by the runtime framework.

Look at your output bundles and check to see which ones have:

Import-Package: ... org.osgi.framework;version=[1.9.0,2.0.0) ...

For those bundles edit your bnd files to include a statement like:

Import-Package: org.osgi.framework;version=[1.8.0,2.0.0), *

and rebuild them.

Then I believe everything should work. Had you been compiling against osgi.core R6 this would have happened naturally.

- Ray

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Raymond Auge

unread,
Feb 15, 2018, 12:26:26 PM2/15/18
to bndtool...@googlegroups.com
On Thu, Feb 15, 2018 at 12:24 PM, Raymond Auge <raymon...@liferay.com> wrote:
If you re-read my last post I explain precisely why you are having an issue.

Tim's code doesn't directly use the OSGi core framework APIs (i.e. org.osgi.framework) which means the examples never cause the onerous import to come in.

You need to review your code and do one of two things:

a) don't use any org.osgi.framework APIs in your code
b) make sure if you use them that you manually set the version import range to a version range supported by the runtime framework.

Look at your output bundles and check to see which ones have:

Import-Package: ... org.osgi.framework;version=[1.9.0,2.0.0) ...

For those bundles edit your bnd files to include a statement like:

Import-Package: org.osgi.framework;version=[1.8.0,2.0.0), *

Import-Package: org.osgi.framework;version='[1.8.0,2.0.0)', *    # added quotes
 

robert.p...@leidos.com

unread,
Feb 15, 2018, 1:36:25 PM2/15/18
to bndtools-users
It resolves now.  We had some Java code in rest-service that imported org.osgi.framework and used BundleContext.  I removed that code.  Now the my bundles resolve and start up.  I see them in the gogo console when I enter lb.

Thank you!
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

Raymond Auge

unread,
Feb 15, 2018, 1:43:28 PM2/15/18
to bndtool...@googlegroups.com
Phew!!! I'm glad it got sorted out! :)

This does speak to a need for improving the user feedback produced from resolution failures. I'm hoping to work on this in bnd over the next few months.

It would have probably been really helpful if the output had given some hint as to possible reasons why various resolution failures arise. I think this is achievable.

Sincerely,
- Ray


To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages