You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by "aldana@gmx.de" <al...@gmx.de> on 2007/09/12 12:54:34 UTC

maven-bundle-plugin: built bundle shows "bundle could not be resolved"

hi,

am using maven-bundle-plugin 1.1.0-SNAPSHOT. building bundle works fine, 
but when installing and trying to start i get a BundleException:
"The bundle could not be resolved. Reason Missing Constraint. 
Import-Package: antlr;

so it seems that lib containing antlr-stuff did not get included inside 
the bundle. this is a bit weird because i "nearly" used an include all 
configuration, and set transitive embedding to true:

<configuration>
  <instructions>
  <Private-Package>ownModulePackage.*</Private-Package>
  <Embed-Transitive>true</Embed-Transitive>
  <Embed-Dependency>
        
*;groupId=!org.eclipse.equinox;artifactId=!referencedBundle;inline=false
   </Embed-Dependency>
   <Bundle-Activator>Activator</Bundle-Activator>
   </instructions>
</configuration>

when putting antlr directly as dependency inside pom.xml, OSGi can find 
antlr (but still has problems with other dependencies). so to me it 
seems that transitive dependencies do not get included by bundle-plugin 
correctly.

many thanks.

-- 
 manuel aldana
 aldana@gmx.de
 homepage: www.aldana-online.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: maven-bundle-plugin: built bundle shows "bundle could not be resolved"

Posted by Stuart McCulloch <st...@jayway.net>.
just to follow up on this question...

On 12/09/2007, aldana@gmx.de <al...@gmx.de> wrote:
>
> how does bnd analyze package dependencies? does it look at bytecode
> (from classes/jars) and its import statements? what about unused
> imports, are they included too? what is bnd analyzing (i guess compiled
> classes, and all project's dependent jars)?


BND is not involved in analyzing maven dependencies - the bundle plugin uses
the
maven project API to query the current project's dependencies (direct or
transitive
depending on Embed-Transitive) and uses Embed-Dependency to decide whether
to
add Include-Resource and Bundle-ClassPath clauses to embed the dependency.

however, orthogonal to the embed dependency feature BND does see the
complete
compilation classpath (minus provided dependencies) and "pulls" classes into
the
bundle using the Export-Package, Private-Package and Include-Resource
settings.

once it has the bundle contents it then looks at the contained bytecode to
find what
packages it needs to import (and calculates uses constraints, etc.)  BND
usually does
a good job at finding dependencies, but may miss them if, say, you use
reflection to
access packages at runtime

i am asking because i find it very weird that many packages
> (antlr,com.sun.msv.grammar,com.sun.msv.grammar.trex) show up, though my
> code does not use it. so the only point could be with external libraries
>

some tips that might help:

   mvn clean install -X

      this will tell you how maven is resolving dependencies and will
contain the
      compilation classpath (in the compiler plugin phase) - remember to
redirect
      output to a file, as it's very verbose

   mvn dependency:analyze

        analyzes your project to find undeclared / unused dependencies (very
useful)

HTH

-- 
Cheers, Stuart

Re: maven-bundle-plugin: built bundle shows "bundle could not be resolved"

Posted by "aldana@gmx.de" <al...@gmx.de>.
> it is certainly possible, depending what part of the maven build phase the
> manifest goal executes (as it needs either classes or a jarfile to analyze).
>
> the manifest goal also doesn't do any embedding, etc. as it's meant to be
> used to generate OSGi metadata for existing (non-OSGi) maven artifacts,
> so you'll also see a difference there...
>   
i see,

finding the evil dependency which is causing my problem is very 
difficult because when trying to remove one of them at a time my build 
breaks (maven compile error). well, it's a kind of hen/egg problem 
(cannot diagnose without removing <->  removing makes diagnosis not 
possible for cannot build).

that's why i try to find out the reason with getting to know the 
approach from bnd better:
how does bnd analyze package dependencies? does it look at bytecode 
(from classes/jars) and its import statements? what about unused 
imports, are they included too? what is bnd analyzing (i guess compiled 
classes, and all project's dependent jars)?

i am asking because i find it very weird that many packages 
(antlr,com.sun.msv.grammar,com.sun.msv.grammar.trex) show up, though my 
code does not use it. so the only point could be with external libraries 
but following lets me doubt this to:
1) having had a look at external poms dependencies with never seen 
before packages do not show up
2) in production currently i use maven assembly plugin, and these 
package-matching libraries (like antlr -> antlr.jar) did not get 
included and system works fine on runtime.

on the other hand following assumptions could be right (for i really 
doubt that packages are made up by bnd tool out from nothing):
1) some pom.xml from external libraries are incorrect (they forgot some 
dependencies)
2) external libraries are using unused imports and thus are included by bnd
3) my runtime system did not execute lines of code yet, which are using 
ominous imported packages

-- 
 manuel aldana
 aldana@gmx.de
 homepage: www.aldana-online.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: maven-bundle-plugin: built bundle shows "bundle could not be resolved"

Posted by Stuart McCulloch <st...@jayway.net>.
On 12/09/2007, aldana@gmx.de <al...@gmx.de> wrote:
>
> Stuart McCulloch schrieb:
> > the bundleplugin uses standard maven calls to get transitive
> dependencies
> > so I'll need your complete POM to find out why it's not found (ie. it
> could
> > be
> > a scoping issue)
>
> it is quite a lot of dependencies (some of them internal), so it would
> be difficult for you to reproduce it. so i am trying to find the
> dependency which makes problems. to be quicker i tried to use the goal
> org.apache.felix:maven-bundle-plugin:manifest, so i get directly to the
> MANIFEST.MF.
>
> though, when trying out this goal, i get a different MANIFEST.MF as with
> goal org.apache.felix:maven-bundle-plugin:bundle. is that correct? if
> so, i will need to go the longer way with building the complete bundle
> and have look inside the jar...


it is certainly possible, depending what part of the maven build phase the
manifest goal executes (as it needs either classes or a jarfile to analyze).

the manifest goal also doesn't do any embedding, etc. as it's meant to be
used to generate OSGi metadata for existing (non-OSGi) maven artifacts,
so you'll also see a difference there...

--
> manuel aldana
> aldana@gmx.de
> homepage: www.aldana-online.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart

Re: maven-bundle-plugin: built bundle shows "bundle could not be resolved"

Posted by "aldana@gmx.de" <al...@gmx.de>.
Stuart McCulloch schrieb:
> On 12/09/2007, aldana@gmx.de <al...@gmx.de> wrote:
>   
>> hi,
>>
>> am using maven-bundle-plugin 1.1.0-SNAPSHOT. building bundle works fine,
>> but when installing and trying to start i get a BundleException:
>> "The bundle could not be resolved. Reason Missing Constraint.
>> Import-Package: antlr;
>>
>> so it seems that lib containing antlr-stuff did not get included inside
>> the bundle. this is a bit weird because i "nearly" used an include all
>> configuration, and set transitive embedding to true:
>>     
>
>
> the bundleplugin uses standard maven calls to get transitive dependencies
> so I'll need your complete POM to find out why it's not found (ie. it could
> be
> a scoping issue)

it is quite a lot of dependencies (some of them internal), so it would 
be difficult for you to reproduce it. so i am trying to find the 
dependency which makes problems. to be quicker i tried to use the goal 
org.apache.felix:maven-bundle-plugin:manifest, so i get directly to the 
MANIFEST.MF.

though, when trying out this goal, i get a different MANIFEST.MF as with 
goal org.apache.felix:maven-bundle-plugin:bundle. is that correct? if 
so, i will need to go the longer way with building the complete bundle 
and have look inside the jar...


-- 
 manuel aldana
 aldana@gmx.de
 homepage: www.aldana-online.de


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: maven-bundle-plugin: built bundle shows "bundle could not be resolved"

Posted by Stuart McCulloch <st...@jayway.net>.
On 12/09/2007, aldana@gmx.de <al...@gmx.de> wrote:
>
> hi,
>
> am using maven-bundle-plugin 1.1.0-SNAPSHOT. building bundle works fine,
> but when installing and trying to start i get a BundleException:
> "The bundle could not be resolved. Reason Missing Constraint.
> Import-Package: antlr;
>
> so it seems that lib containing antlr-stuff did not get included inside
> the bundle. this is a bit weird because i "nearly" used an include all
> configuration, and set transitive embedding to true:


the bundleplugin uses standard maven calls to get transitive dependencies
so I'll need your complete POM to find out why it's not found (ie. it could
be
a scoping issue)

<configuration>
>   <instructions>
>   <Private-Package>ownModulePackage.*</Private-Package>
>   <Embed-Transitive>true</Embed-Transitive>
>   <Embed-Dependency>
>
> *;groupId=!org.eclipse.equinox;artifactId=!referencedBundle;inline=false
>    </Embed-Dependency>
>    <Bundle-Activator>Activator</Bundle-Activator>
>    </instructions>
> </configuration>
>
> when putting antlr directly as dependency inside pom.xml, OSGi can find
> antlr (but still has problems with other dependencies). so to me it
> seems that transitive dependencies do not get included by bundle-plugin
> correctly.
>
> many thanks.
>
> --
> manuel aldana
> aldana@gmx.de
> homepage: www.aldana-online.de
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart