You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by rsteppac2 <ra...@steppacher.name> on 2014/10/12 12:40:57 UTC

Import missing

Hello,

I have three bundles that I build as part of a multi-module project with the
maven-bundle-plugin: A, X, and Y. A depends on X and Y. However, when
building the bundle A the import package statement for the package in Y is
missing, while the import for X is present. And unsurprisingly, deployment
of A (in Karaf) fails. I am a bit at a loss as to why the import might be
dropped.

The configuration looks as follows:

    <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
            <instructions>
               
<Embed-Dependency>*;scope=compile|runtime;inline=false;artifactId=!X|Y</Embed-Dependency>
                <Embed-Transitive>true</Embed-Transitive>
                <Import-Package>
                    com.sun.jdi.*;
                    com.sun.msv.*;
                    com.sun.tools.*;
                    
                    resolution:=optional,
                    *
                </Import-Package>
            </instructions>
        </configuration>
    </plugin>

    <dependency>
        <groupId>my.group</groupId>
        <artifactId>X</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>my.group</groupId>
        <artifactId>Y</artifactId>
        <version>${project.version}</version>
    </dependency>

    

The order of the artifacts in the exclusion list for embedding does not
matter. Both "!X|Y" and "!Y|X" yield the same result.

If anyone could point me to a possible mistake on my side, I'd be glad.

Thanks!
Ralf



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by Jan Willem Janssen <ja...@luminis.eu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/10/14 12:20, rsteppac2 wrote:
> Both by static import:
> 
> import static 
> ch.vivates.ams.camel.compoment.uldap.Constants.LDAP_ENTRY_UUID; 
> import static 
> ch.vivates.ams.camel.compoment.uldap.Constants.LDAP_OBJECT_CLASS; 
> ... builder.entryUUID =
> UUID.fromString((String)headers.get(*LDAP_ENTRY_UUID*));
> 
> and "regular" import:
> 
> import ch.vivates.ams.camel.compoment.uldap.Constants; ... public
> void touchVertex(@Header(*Constants.LDAP_ENTRY_UUID*) String
> strUUID) { ... }
> 

You are aware that string constants are inlined by the Java compiler?
That might explain why no import is present...

- -- 
Met vriendelijke groeten | Kind regards

Jan Willem Janssen | Software Architect
+31 631 765 814

/My world is revolving around INAETICS and Amdatu/

Luminis Technologies B.V.
Churchillplein 1
7314 BZ   Apeldoorn
+31 88 586 46 00

http://www.luminis-technologies.com
http://www.luminis.eu

KvK (CoC) 09 16 28 93
BTW (VAT) NL8169.78.566.B.01
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.22 (Darwin)
Comment: GPGTools - http://gpgtools.org

iQIcBAEBAgAGBQJUPPmXAAoJEKF/mP2eHDc4zMoP/iopuynqEzI4dUraTCrTuuPj
EfLkvLj7rK3GHkafG+1W7qAxGzfMe3RwNfuLE1J4cz4K8qaHks+o//6pTan4wPdS
gn5HLFeBWfoxvhJETppl0NMZZs97cU0KLHzvEdwVJv+n4RxxYJVJtoS3IqrGnnIl
+uyBSquLBrmCznqN8sown7YHn2YV3qwtw/YAeaaLoi8QGL56CIUUAOAzHI5OL/jJ
vM6cJ3nDfsP+68qxDivFtrc9FJXw/3IQkck/KJjbork8noi2rl487JAX+qX6Udag
2YAHqkvlF/OP+UDxNsBhra8dgdJzui3Z6a7IKwKGLyA/q84NnQyEo50pJoIVk41k
hPtzvkea0p6B+7uCdQau0jtma+KXU//2QicuoSS43+HWHeBQDCmPmtOY6ZspeQjo
l+PYAOTkRl/1qTP2bUmW7O1qb0XiT4GDliuLgugi5EKalBZBm09tIw/Oi9QTt3+v
0kgWZE6jIpA/oxzLPHNxKjrhPZe7Av2af3DjX0tkivz0UC1REZAsZMytNB9GpHaB
vWG6y2vOi2/NhbOZeoaomfoJcnLqoRluwJTkAJyhRwRcNVC7TW98YtBd8pTpTTqm
4kIwIFoUDNK0T6iah2y4R38PbUaXoxu7bN6gFKUzsNUiMmSI7moe/gBshUUr9Wpj
ftsrIHTlZ7qR+prC4qMw
=7p9a
-----END PGP SIGNATURE-----

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


Re: Import missing

Posted by rsteppac2 <ra...@steppacher.name>.
Both by static import:

import static
ch.vivates.ams.camel.compoment.uldap.Constants.LDAP_ENTRY_UUID;
import static
ch.vivates.ams.camel.compoment.uldap.Constants.LDAP_OBJECT_CLASS;
...
builder.entryUUID = UUID.fromString((String)headers.get(*LDAP_ENTRY_UUID*));

and "regular" import:

import ch.vivates.ams.camel.compoment.uldap.Constants;
...
public void touchVertex(@Header(*Constants.LDAP_ENTRY_UUID*) String strUUID)
{
...
}



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010154.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by Achim Nierbeck <bc...@googlemail.com>.
The question is,
how do you reference these constants?
Where an how do you use them?

regards, Achim

2014-10-14 9:14 GMT+02:00 rsteppac2 <ra...@steppacher.name>:

> Hi Achim,
>
> the class in question is an interface containing only string constants.
>
> Thanks!
> Ralf
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010150.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Import missing

Posted by rsteppac2 <ra...@steppacher.name>.
Hi Achim,

the class in question is an interface containing only string constants.

Thanks!
Ralf



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010150.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by Achim Nierbeck <bc...@googlemail.com>.
How do you access this class?
By some kind of reflection?
If you don't instantiate the class bnd is not able to find it as it does
analyze the bytecode.

regards, Achim

2014-10-14 9:05 GMT+02:00 rsteppac2 <ra...@steppacher.name>:

> Maybe I should add that the bundle containing the class
> ch.vivates.ams.camel.compoment.uldap.Constants has been deployed as well.
> And as soon as I explicitly add the import like so everything works.
>
> ch.vivates.ams.camel.compoment.uldap;
> version=${project.version},
>
> The question is why the import is not being generated by the plugin?
> BTW, the problem is not the version. The import as a whole is missing from
> the manifest of the bundle.
>
>
> Ralf
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010148.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 

Apache Member
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/> Committer &
Project Lead
blog <http://notizblog.nierbeck.de/>
Co-Author of Apache Karaf Cookbook <http://bit.ly/1ps9rkS>

Software Architect / Project Manager / Scrum Master

Re: Import missing

Posted by rsteppac2 <ra...@steppacher.name>.
Maybe I should add that the bundle containing the class
ch.vivates.ams.camel.compoment.uldap.Constants has been deployed as well.
And as soon as I explicitly add the import like so everything works. 

ch.vivates.ams.camel.compoment.uldap;
version=${project.version},

The question is why the import is not being generated by the plugin?
BTW, the problem is not the version. The import as a whole is missing from
the manifest of the bundle.


Ralf



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010148.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by rsteppac2 <ra...@steppacher.name>.
Yep, I have Karaf 3.0.1 at the ready. I can deploy the bundle no problem
without manually adding the import as discussed. But I then get
ClassNotFoundExceptions as soon as the Camel route gets triggered by an LDAP
update:

	at
org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1379)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.builder.ExpressionBuilder$30.evaluate(ExpressionBuilder.java:755)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.builder.ExpressionBuilder$31.evaluate(ExpressionBuilder.java:779)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.language.simple.ast.SimpleFunctionStart$1.evaluate(SimpleFunctionStart.java:80)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.builder.BinaryPredicateSupport.matchesReturningFailureMessage(BinaryPredicateSupport.java:60)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.builder.BinaryPredicateSupport.matches(BinaryPredicateSupport.java:50)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.builder.PredicateBuilder$4.matches(PredicateBuilder.java:116)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.language.simple.ast.BinaryExpression$3.evaluate(BinaryExpression.java:178)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.util.ExpressionToPredicateAdapter.matches(ExpressionToPredicateAdapter.java:34)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:76)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.processor.ChoiceProcessor.process(ChoiceProcessor.java:90)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[84:org.apache.camel.camel-core:2.13.2]
	at
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[84:org.apache.camel.camel-core:2.13.2]
	at
ch.vivates.ams.camel.compoment.uldap.UnboundIDLDAPConsumer.messageReceived(UnboundIDLDAPConsumer.java:61)[103:ch.vivates.ams.camel-uldap:3.0.0.SNAPSHOT]
	at
ch.vivates.ams.camel.compoment.uldap.unboundid.CallbackAsyncSearchResultListener.searchEntryReturned(CallbackAsyncSearchResultListener.java:67)[103:ch.vivates.ams.camel-uldap:3.0.0.SNAPSHOT]
	at
com.unboundid.ldap.sdk.AsyncSearchHelper.responseReceived(AsyncSearchHelper.java:206)[104:com.unboundid.ldap.sdk.se:2.3.6]
	at
com.unboundid.ldap.sdk.LDAPConnectionReader.run(LDAPConnectionReader.java:564)[104:com.unboundid.ldap.sdk.se:2.3.6]
Caused by: java.lang.ClassNotFoundException: Cannot find type
ch.vivates.ams.camel.compoment.uldap.Constants.LDAP_ACTION
	... 22 more

The package "ch.vivates.ams.camel.compoment.uldap" is the one that is not
included automatically.


Thanks again!
Ralf



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010138.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by Raymond Auge <ra...@liferay.com>.
Ok so are you setup so you can do some runtime diagnostics?

Do you have a runtime into which is deployed, or can be deployed gogo shell?

Before continuing to pull your hair out, it would be a good idea to set
that up because it can provide invaluable details about what's going on
with just a few simple commands.

Let us know.

- Ray

On Sun, Oct 12, 2014 at 11:18 AM, rsteppac2 <ra...@steppacher.name> wrote:

> Raymond,
>
> Thanks for detailing the package rule.
> I have changed the config accordingly, but that has not solved the original
> problem of the missing import.
>
> The config looks like this now:
>
> org.junit.*;
> resolution:=optional,
> org.relaxng.datatype;
> resolution:=optional,
> ...,
> ch.vivates.ams.base.domain;
> version=${project.version},
> ch.vivates.ams.camel.compoment.uldap;
> version=${project.version},
> *
>
> Ralf
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010135.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect
*Liferay, Inc.* <http://www.liferay.com> (@Liferay)

Re: Import missing

Posted by rsteppac2 <ra...@steppacher.name>.
Raymond,

Thanks for detailing the package rule. 
I have changed the config accordingly, but that has not solved the original
problem of the missing import.

The config looks like this now:

org.junit.*;
resolution:=optional,
org.relaxng.datatype;
resolution:=optional,
...,
ch.vivates.ams.base.domain;
version=${project.version},
ch.vivates.ams.camel.compoment.uldap;
version=${project.version},
*

Ralf



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010135.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by Raymond Auge <ra...@liferay.com>.
On Sun, Oct 12, 2014 at 9:38 AM, rsteppac2 <ra...@steppacher.name> wrote:

> Neil,
>
> Hm... it appears to work though. I can list packages with ";" and then add
> a
> qualifier like "resolution" or "version" at the end and start a new list
> with a ",".
>
> <Import-Package>
>




>         org.junit.*;
>         org.relaxng.datatype;
>         resolution:=optional,
>

All of this will be interpreted as one single package "rule" and
org.relaxng.datatype will end up somewhere in the aether as semicolon is
used to separate "parameters" of the rule, such as "version".



>         ch.vivates.ams.base.domain;
>         ch.vivates.ams.camel.compoment.uldap;
>         version=${project.version},
>

All of this will be the next rule and ch.vivates.ams.camel.compoment.uldap
will also end up who knows where as bnd thinks it's some parameter with no
value.



>         *
>

This will let bnd calculate everything else which may accidentally solve
the problems you caused yourself with org.relaxng.datatype and
ch.vivates.ams.camel.compoment.uldap if it happens to see this in some uses
somewhere in your code.

This is all to say that simply because something appears to work, if you
break the rules you are shooting yourself in the foot.

So, as Neil said, and he really is not fooling you.. use a comma for the
package rule delimiter.

- Ray



> </Import-Package>
>
> The above results in a manifest that imports all junit packages and the
> relaxng package with resolution:=optional and my own two packages with the
> enforced version, plus everything else as it would be generated by default.
>
> Ralf
>
>
>
> --
> View this message in context:
> http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010131.html
> Sent from the Apache Felix - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
*Raymond Augé* <http://www.liferay.com/web/raymond.auge/profile>
 (@rotty3000)
Senior Software Architect
*Liferay, Inc.* <http://www.liferay.com> (@Liferay)

Re: Import missing

Posted by rsteppac2 <ra...@steppacher.name>.
Neil,

Hm... it appears to work though. I can list packages with ";" and then add a
qualifier like "resolution" or "version" at the end and start a new list
with a ",".

<Import-Package>
	org.junit.*;
	org.relaxng.datatype;
	resolution:=optional,
	ch.vivates.ams.base.domain;
	ch.vivates.ams.camel.compoment.uldap;
	version=${project.version},
	*
</Import-Package>

The above results in a manifest that imports all junit packages and the
relaxng package with resolution:=optional and my own two packages with the
enforced version, plus everything else as it would be generated by default.

Ralf



--
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122p5010131.html
Sent from the Apache Felix - Users mailing list archive at Nabble.com.

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


Re: Import missing

Posted by Neil Bartlett <nj...@gmail.com>.
It looks like you’re trying to use a semicolon to separate your package list. The separator character should be a comma.

Regards,
Neil


On 12 October 2014 at 11:41:25, rsteppac2 (ralf@steppacher.name) wrote:

Hello,  

I have three bundles that I build as part of a multi-module project with the  
maven-bundle-plugin: A, X, and Y. A depends on X and Y. However, when  
building the bundle A the import package statement for the package in Y is  
missing, while the import for X is present. And unsurprisingly, deployment  
of A (in Karaf) fails. I am a bit at a loss as to why the import might be  
dropped.  

The configuration looks as follows:  

<plugin>  
<groupId>org.apache.felix</groupId>  
<artifactId>maven-bundle-plugin</artifactId>  
<extensions>true</extensions>  
<configuration>  
<instructions>  

<Embed-Dependency>*;scope=compile|runtime;inline=false;artifactId=!X|Y</Embed-Dependency>  
<Embed-Transitive>true</Embed-Transitive>  
<Import-Package>  
com.sun.jdi.*;  
com.sun.msv.*;  
com.sun.tools.*;  

resolution:=optional,  
*  
</Import-Package>  
</instructions>  
</configuration>  
</plugin>  

<dependency>  
<groupId>my.group</groupId>  
<artifactId>X</artifactId>  
<version>${project.version}</version>  
</dependency>  
<dependency>  
<groupId>my.group</groupId>  
<artifactId>Y</artifactId>  
<version>${project.version}</version>  
</dependency>  



The order of the artifacts in the exclusion list for embedding does not  
matter. Both "!X|Y" and "!Y|X" yield the same result.  

If anyone could point me to a possible mistake on my side, I'd be glad.  

Thanks!  
Ralf  



--  
View this message in context: http://apache-felix.18485.x6.nabble.com/Import-missing-tp5010122.html  
Sent from the Apache Felix - Users mailing list archive at Nabble.com.  

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