This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 220130 - Public packages from wrapped library not displayed in properties
Summary: Public packages from wrapped library not displayed in properties
Status: RESOLVED WORKSFORME
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Milos Kleint
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-15 18:23 UTC by javydreamercsw
Modified: 2012-10-20 07:01 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description javydreamercsw 2012-10-15 18:23:34 UTC
Although issue 218704 seems to solve the issue it seems some undesirable side effects have been detected. For example, the packages does not shown in Properties>Public Packages, but the project builds fine.

Also I have trouble with other projects re-using those modules as they complain about the wrapped libraries: "Project uses classes from transitive module xxx which will not be accessible at runtime."

When in the original project they seem to work.
Comment 1 Milos Kleint 2012-10-16 14:26:24 UTC

(In reply to comment #0)
> Although issue 218704 seems to solve the issue it seems some undesirable side
> effects have been detected. For example, the packages does not shown in
> Properties>Public Packages, but the project builds fine.

public packages customizer code is unrelated to the change in issue 218704. that issue only affects lock badges on packages nodes.


> 
> Also I have trouble with other projects re-using those modules as they complain
> about the wrapped libraries: "Project uses classes from transitive module xxx
> which will not be accessible at runtime."

That's a correct error message from the nbm-maven plugin. You have some misconfiguration in the way dependencies are defined. see http://mojo.codehaus.org/nbm-maven/nbm-maven-plugin/


> 
> When in the original project they seem to work.

see above
Comment 2 javydreamercsw 2012-10-16 18:46:34 UTC
I'm not sure if I'm following you. Are you referring to the libraries/library* configuration?

For example do something like this for log4j wrapper:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>nbm-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <useOSGiDependencies>false</useOSGiDependencies>
                    <libraries>
                        <library>log4j:log4j</library>
                    </libraries>
                </configuration>
            </plugin>

I already did the try and this got added to the manifest:

Maven-Class-Path: log4j:log4j:1.2.17

Is that what should really happen?
Comment 3 Milos Kleint 2012-10-16 19:02:13 UTC
(In reply to comment #2)
> I'm not sure if I'm following you. Are you referring to the libraries/library*
> configuration?

any classes you are referring to from your module's classes need to be declared as direct dependency. Then if the dependency is a module itself, it has to make the referring classes/packages public. Any non-module dependency becomes wrapped as part of the module itself (known as library wrapper in the ant world)

So in a wordly example of log4j, you should effectively just declare one module as the wrapper module for log4j and directly depend on it and expose the log4j packages as public. Any other module project will only declare a direct dependency on your log4j wrapper module.

> 
> For example do something like this for log4j wrapper:
> 
>             <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>nbm-maven-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <configuration>
>                     <useOSGiDependencies>false</useOSGiDependencies>
>                     <libraries>
>                         <library>log4j:log4j</library>
>                     </libraries>
>                 </configuration>
>             </plugin>
> 
> I already did the try and this got added to the manifest:
> 
> Maven-Class-Path: log4j:log4j:1.2.17
> 
> Is that what should really happen?


more or less. <libraries> is optional explicit declaration, but declaring log4j as direct dependency is equivalent.

A more detailed example project along with the failing output would be helpful for any more specific investigation.
Comment 4 javydreamercsw 2012-10-16 19:51:11 UTC
It sounds like my configuration follows your advice already. I got rid of the libraries part having the same result.

For example, here's how I wrap the log4j library:

             <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>nbm-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <useOSGiDependencies>false</useOSGiDependencies>
                    <moduleType>eager</moduleType>
                    <codeNameBase>org.apache.lib/1</codeNameBase>
                    <licenseName>Apache License, Version 2.0</licenseName>
                    <licenseFile>../../License.txt</licenseFile>
                    <manifest>src/main/nbm/manifest.mf</manifest>
                    <author>Javier A. Ortiz Bultrón</author>
                    <homepageUrl>https://sourceforge.net/projects/simple-marauroa/</homepageUrl>
                    <publicPackages>
                        <publicPackage>org.apache.*</publicPackage>
                    </publicPackages>
                </configuration>
            </plugin>

The weird thing is that all other wrappers seems to be working properly. Just the log4j one seems to have problems, but just outside of the project (i.e. trying to reuse the artifact as dependency in another project). As far as I can tell, that's not illegal. At least was legal in the ant version.

Source can be found here: https://bitbucket.org/javydreamercsw/simple-marauroa-rcp

The Log4j wrapper is defined in the Marauroa-Server-Manager application and I'm having issues when trying to use it from the Simple-Marauroa-Client (notice the dashes as there's one without dashes while I complete the transformation to Maven) application. For example, module Simple-Client-Wrapper from the Simple-Marauroa-Client fails being unable to access log4j classes.
Comment 5 Milos Kleint 2012-10-18 08:37:27 UTC
(In reply to comment #4)
> It sounds like my configuration follows your advice already. I got rid of the
> libraries part having the same result.
> 
> For example, here's how I wrap the log4j library:
> 
>              <plugin>
>                 <groupId>org.codehaus.mojo</groupId>
>                 <artifactId>nbm-maven-plugin</artifactId>
>                 <extensions>true</extensions>
>                 <configuration>
>                     <useOSGiDependencies>false</useOSGiDependencies>
>                     <moduleType>eager</moduleType>

you most likely want "autoload" for libraries.


>                     <codeNameBase>org.apache.lib/1</codeNameBase>
>                     <licenseName>Apache License, Version 2.0</licenseName>
>                     <licenseFile>../../License.txt</licenseFile>
>                     <manifest>src/main/nbm/manifest.mf</manifest>
>                     <author>Javier A. Ortiz Bultrón</author>
>                    
> <homepageUrl>https://sourceforge.net/projects/simple-marauroa/</homepageUrl>
>                     <publicPackages>
>                         <publicPackage>org.apache.*</publicPackage>
>                     </publicPackages>
>                 </configuration>
>             </plugin>
> 
> The weird thing is that all other wrappers seems to be working properly. Just
> the log4j one seems to have problems, but just outside of the project (i.e.
> trying to reuse the artifact as dependency in another project). As far as I can
> tell, that's not illegal. At least was legal in the ant version.


the log4j one depends on an OSGI bundle (log4j has osgi headers). That's most likely the difference here.


> 
> Source can be found here:
> https://bitbucket.org/javydreamercsw/simple-marauroa-rcp
> 
> The Log4j wrapper is defined in the Marauroa-Server-Manager application and I'm
> having issues when trying to use it from the Simple-Marauroa-Client (notice the
> dashes as there's one without dashes while I complete the transformation to
> Maven) application. For example, module Simple-Client-Wrapper from the
> Simple-Marauroa-Client fails being unable to access log4j classes.

unfortunately I could not build the entire thing, some dependencies were missing for me. 

Please try applying the <useOSGiDependencies>false</useOSGiDependencies> parameter consistently. In general many parameters and plugin declaration should be moved to one place (the parent pom).
Comment 6 javydreamercsw 2012-10-18 14:06:04 UTC
(In reply to comment #5)
> (In reply to comment #4)
> > It sounds like my configuration follows your advice already. I got rid of the
> > libraries part having the same result.
> > 
> > For example, here's how I wrap the log4j library:
> > 
> >              <plugin>
> >                 <groupId>org.codehaus.mojo</groupId>
> >                 <artifactId>nbm-maven-plugin</artifactId>
> >                 <extensions>true</extensions>
> >                 <configuration>
> >                     <useOSGiDependencies>false</useOSGiDependencies>
> >                     <moduleType>eager</moduleType>
> 
> you most likely want "autoload" for libraries.
I realized this after posting my comment. Was a copy and paste issue, but thanks for pointing it out.
> 
> 
> >                     <codeNameBase>org.apache.lib/1</codeNameBase>
> >                     <licenseName>Apache License, Version 2.0</licenseName>
> >                     <licenseFile>../../License.txt</licenseFile>
> >                     <manifest>src/main/nbm/manifest.mf</manifest>
> >                     <author>Javier A. Ortiz Bultrón</author>
> >                    
> > <homepageUrl>https://sourceforge.net/projects/simple-marauroa/</homepageUrl>
> >                     <publicPackages>
> >                         <publicPackage>org.apache.*</publicPackage>
> >                     </publicPackages>
> >                 </configuration>
> >             </plugin>
> > 
> > The weird thing is that all other wrappers seems to be working properly. Just
> > the log4j one seems to have problems, but just outside of the project (i.e.
> > trying to reuse the artifact as dependency in another project). As far as I can
> > tell, that's not illegal. At least was legal in the ant version.
> 
> 
> the log4j one depends on an OSGI bundle (log4j has osgi headers). That's most
> likely the difference here.
So that one should have <useOSGiDependencies>true</useOSGiDependencies>?
> 
> 
> > 
> > Source can be found here:
> > https://bitbucket.org/javydreamercsw/simple-marauroa-rcp
> > 
> > The Log4j wrapper is defined in the Marauroa-Server-Manager application and I'm
> > having issues when trying to use it from the Simple-Marauroa-Client (notice the
> > dashes as there's one without dashes while I complete the transformation to
> > Maven) application. For example, module Simple-Client-Wrapper from the
> > Simple-Marauroa-Client fails being unable to access log4j classes.
> 
> unfortunately I could not build the entire thing, some dependencies were
> missing for me.
Hmmm. That's weird. It builds fine on Jenkins. Any specific dependency missing you can point out?
> 
> Please try applying the <useOSGiDependencies>false</useOSGiDependencies>
> parameter consistently. In general many parameters and plugin declaration
> should be moved to one place (the parent pom).

I will.
Comment 7 javydreamercsw 2012-10-18 14:36:48 UTC
I fixed the dependency issue and pushed the changes. Also incorporated your comments into the POM's. Will try with the changes and see how it goes.
Comment 8 javydreamercsw 2012-10-18 14:56:02 UTC
It didn't work. It only works if I add the log4j direct dependency to the Simple-Client-Wrapper project. I also tried enabling OSGI depenedencies in both log4j wrapper and the Simple-Client-Wrapper without changes.
Comment 9 Milos Kleint 2012-10-19 11:10:04 UTC
added more explicit error message that also hints at the direction of a fix.
http://fisheye.codehaus.org/changelog/mojo/?cs=17694

I've made it work (build) by adding <useOSGiDependencies>false</useOSGiDependencies> to every module accessing the log4j wrapper (yes, the setting is not only to be applied  to the wrapper itself, but to every module using classes from log4j (ergo. effectively the whole app). 
(So basically the parameter should be defined in the parent pom and inherited by all the modules. There's more generally used libraries from apache that include osgi headers in their artifacts turning them into bundles from our point of view.

Unless you really need to, I would discourage from using osgi bundles as dependencies. personal opinion only though. Especially for libs like log4j it only adds the overhead of felix/equinox container to the runtime.

from what I can tell it's working as expected.
Comment 10 javydreamercsw 2012-10-19 21:14:45 UTC
Which project you were able to build? Server Manager or the client? The client is the one with the issue.
Comment 11 Milos Kleint 2012-10-20 07:01:04 UTC
(In reply to comment #10)
> Which project you were able to build? Server Manager or the client? The client
> is the one with the issue.

after this change the client wrapper built. I got the same problem down the road with another project.

diff -r e335d59ff8b5 Simple-Marauroa-Client/Simple-Client-Wrapper/pom.xml
--- a/Simple-Marauroa-Client/Simple-Client-Wrapper/pom.xml	Thu Oct 18 15:35:14 2012 -0500
+++ b/Simple-Marauroa-Client/Simple-Client-Wrapper/pom.xml	Sat Oct 20 08:59:57 2012 +0200
@@ -76,6 +76,7 @@
                 <extensions>true</extensions>
                 <configuration>
                     <codeNameBase>simple.marauroa.client.wrapper/1</codeNameBase>
+                    <useOSGiDependencies>false</useOSGiDependencies>
                     <licenseName>Apache License, Version 2.0</licenseName>
                     <licenseFile>../../License.txt</licenseFile>
                     <manifest>src/main/nbm/manifest.mf</manifest>