So I have an improvement. The bundling plugin is now adding in the jars and 
giving me a size close to what I'm expecting when the dependencies are imported 
(~36mb).

My plugin definition now looks like follows:

 <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>2.2.0</version>
                <extensions>true</extensions>

                <configuration>
                    <instructions>
                        
<!--<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>-->
                        <Import-Package>org.isatools.tablib.utils, 
org.isatools.isatab.gui_invokers,
                            org.isatools.tablib.utils.logging, *
                        </Import-Package>
                        
<Export-Package>org.isatools.plugins.validatorconverter, *
                        </Export-Package>
                        
<Bundle-Activator>org.isatools.plugins.validatorconverter.Activator</Bundle-Activator>
                        <Bundle-Vendor>ISAteam</Bundle-Vendor>
                        
<Bundle-ClassPath>isavalidatorconvert,import_layer</Bundle-ClassPath>
                    </instructions>
                </configuration>
</plugin>

The only problem I have now is sorting out the imports/exports I guess. I'm 
currently getting this message when starting of the plugin is attempted:

ERROR: Error starting 
file:/Users/eamonnmaguire/git/isarepo/ISAcreator/Plugins/isavalidatorconvert-1.0.jar
 (org.osgi.framework.BundleException: Activator start error in bundle 
org.isatools.plugins.isavalidatorconvert [1].)

Before that, I was getting classnotfoundexceptions all over the place.

Also, I feel that just using the wildcard * in imports and exports is wrong, 
but I am still unsure of how to satisfy all the requirements and ensure that my 
package will be seen in ISAcreator. If I leave the * out of the export-package 
value, the jar is very small and doesn't contain the required dependencies. So, 
I am sure that the bundle classpath values are incorrect. I thought just 
specifying the artifactIds was enough, but obviously not from this message 
found when building the plugin code.

[WARNING] Warning building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : No sub JAR or directory 
isavalidatorconvert
[WARNING] Warning building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : No sub JAR or directory 
import_layer
[WARNING] Warning building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : Superfluous 
export-package instructions: [*, org.isatools.plugins.validatorconverter]
[WARNING] Warning building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : The Bundle-Classpath does 
not contain the actual bundle JAR (as specified with '.' in the 
Bundle-Classpath) but the JAR does contain classes. Is this intentional?

BTW, the oode for the plugin in it's entirety can be seen here: 
https://github.com/ISA-tools/ISAcreatorPlugins/tree/master/ValidatorConverter

Thanks again for all the help, I really appreciate it!

Eamonn



On 20 Sep 2011, at 08:27, Eamonn Maguire wrote:

[ERROR] Error building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : Invalid class file: 
*.class

^ It's actually due to the fact that an actual file called *.class is being 
embedded into the final bundle. I had this problem before with another project, 
and it wasn't anything to do with OSGi. It was actually down to a maven plugin 
not working properly. I think it was maven-assembly but I can't rightly 
remember at present. I will try and find the trace I made about the problem and 
get back to you on this.

I'll remove the osgi framework from the bundle. now and see what happens with 
that.

Thanks,

Eamonn

On 20 Sep 2011, at 00:31, 
<[email protected]<mailto:[email protected]>> 
<[email protected]<mailto:[email protected]>> wrote:



This is a tough one, and my answer may be wrong, so I hope that other smart 
developers on this list will read this and correct it if possible. A "CAFEBABE" 
header is a hexadecimal string Ja va uses to identify ava bytecode.  So, what 
this is tellling me is that Java is unable to recognize the .class file 
referred to hear as Java Bytecode.  Where are you pulling this file from?  
Also, what version of Java are you using?  What version of Java is required by 
the isatools plugins?



v/r,



Mike Van



----- Original Message -----


From: "Eamonn Maguire" 
<[email protected]<mailto:[email protected]>>
To: [email protected]<mailto:[email protected]>
Sent: Monday, September 19, 2011 5:36:45 PM
Subject: Re: Dependencies, Exports and Imports Query

The full error there was:

[ERROR] Error building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : Exception: Not a valid 
class file (no CAFEBABE header)
[ERROR] Error building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : Invalid class file: 
*.class

For some reason, not everything copied. This is what you get when working late 
:)

Eamonn

On 19 Sep 2011, at 22:35, Eamonn Maguire wrote:

Hi,

Thank you for your prompt response. So, I tried that and the following problems 
have come up.

[ERROR] Error building bundle 
org.isatools.plugins:isavalidatorconvert:bundle:1.0 : Exception: Not a valid 
class file (no CAFEBABE header)

The edited pom.xml file I'm using is here: https://gist.github.com/1227576

Eamonn


On 19 Sep 2011, at 22:22, 
<[email protected]<mailto:[email protected]>> wrote:



Eamonn,



The dependencies section is only really used to build your .jar file when you 
have pakcages external to your bundle included in the Export-Package section of 
your maven-bundle plugin.  I believe the reason that you're experiencing the 
bundling of your .jar file with your bundle is because of your 
maven-assembly-plugin implementation.


What I would suggest you do is change your packaging type to "bundle", comment 
out your maven-assembly-plugin section and attempt to compile again. The 
maven-bundle-plugin will take care of most of the stuff you're trying to do in 
your maven-assembly-plugin and is a cleaner approach. This will also ensure 
that you don't get erroneous dependant .jar files compiled in with your 
application.



The dependancy is still needed if you have references to that external library 
in your Import-Package section of your maven-bundle-plugin implementation.



So, in short, keep the dependancy, and comment out your maven-assembly-plugin 
code.



Please let me know if that helps!






----- Original Message -----


From: "Eamonn Maguire" 
<[email protected]<mailto:[email protected]>>
To: [email protected]<mailto:[email protected]>
Sent: Monday, September 19, 2011 5:06:24 PM
Subject: Re: Dependencies, Exports and Imports Query

Ah, I should have mentioned that BIIObjectStore is in the 
org.isatools.tablib.utils package.

Thanks again,

Eamonn

On 19 Sep 2011, at 21:58, Eamonn Maguire wrote:

Hi all,

I'm new to OSGi, I just started implementing before the weekend and although 
the process was relatively pain free, I'm having some problems with getting 
plugins to work without having all my dependencies in the host project.

For the plugin I'm using, the pom.xml file can be seen here: 
https://gist.github.com/1227576

For the dependencies:

1) The ISAcreator dependency is the actual host program, where the plugins are 
to be deployed.
2) The import_layer artifact is used for validation and conversion, which the 
plugin does and contains a class called BIIObjectStore (this becomes relevant 
below). It is NOT an OSGi module.


The problem
Everything is working as long as the import_layer dependency is in the host 
pom.xml dependencies, but this defeats the purpose of the plugin. But when it's 
not included, I get a classnotfoundexception when I attempt to execute the code 
in the plugin (there are no complaints when felix starts and the plugin is 
loaded). I'm not totally sure why it's not working since the resulting jar 
produced when I run mvn clean install contains the class. It's just not being 
'seen' when it is executed.

The plugin configuration as seen in the file is probably not doing something 
right, and as you can see, the current version of that file is doing everything.

Any help would be greatly appreciated. I feel like I'm banging my head against 
a brick wall on this one.

Many thanks,

Eamonn Maguire





---------------------------------------------------------------------
To unsubscribe, e-mail: 
[email protected]<mailto:[email protected]>
For additional commands, e-mail: 
[email protected]<mailto:[email protected]>



---------------------------------------------------------------------
To unsubscribe, e-mail: 
[email protected]<mailto:[email protected]>
For additional commands, e-mail: 
[email protected]<mailto:[email protected]>


Reply via email to