You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Ivo K. Koga" <iv...@gmail.com> on 2006/12/17 06:03:59 UTC

Importing packages and using classes from the bundle that exported it

Hi All,

I'm trying to use some classes that I provide in my bundle. So I want to use
the classes inside my bundle from this same bundle. I don't know if I am
doing something wrong, but my manifest file is sth like this:

Bundle-Activator:
br.unifacs.nuperc.ice.osgi.perfsonar.clmp.ping.CLMPPingPlugin
Export-Package: br.unifacs.nuperc.ice.osgi.perfsonar.clmp.ping
Bundle-Classpath: .
Import-Package: org.osgi.framework, javax.swing, org.w3c.dom,
br.unifacs.nuperc.ice.osgi.perfsonar.clmp.ping
Bundle-Name: CL-MP Ping Data Plugin
Bundle-Description: A bundle that registers a CLMP Ping service access
Bundle-Vendor: Ivo K. Koga
Bundle-Version: 1.0.0

All the classes are in the same package at
br.unifacs.nuperc.ice.osgi.perfsonar.clmp.ping.

The CLMPPingPlugin.java is trying to use a class from the same package of
it, but when I execute it, I receive the following error message:

Exception in thread "Thread-3" java.lang.NoClassDefFoundError:
br/unifacs/nuperc/ice/mpcl/ping/MPCLPingResultVO

Hope you can Help me.

Regards,

Ivo K. Koga




-- 
Msc. Candidate in Computer Networks at Universidade Salvador/BA/Brazil
Measurement WG - RNP/Brazil

RE: Importing packages and using classes from the bundle that exported it

Posted by "Jan S. Rellermeyer" <re...@inf.ethz.ch>.
Hi Ivo, 

Sorry for mixing the reply to your problem with other, more general
comments. 

> Sorry abt my ignorance abt many aspects of your e-mail, but 
> you said that maven could help not getting this kind of 
> errors, or am I wrong?

No, it does not help you. In my oppinion, it makes the problem even worse
because it introduces a new level where you have to take care of
dependencies, their freshness, consistency...
 
> I don't know anything abt maven unless the mvn clean install 
> to build felix
> :-)
> 
> But how I can use it to help me?

So the reason why I use it is that otherwise, I would end up with one
project per bundle and this would be too much. Maven can handle
multiprojects, that means, you have one project containing subprojects. So
one project is the set of all bundles (= subprojects) that are directly
involved in the application. The dependencies to other bundles or general
artefacts are handled by maven. (= this is the additional layer to take care
of).

> I saw that a maven eclipse plugin already exist. Do I have 
> just to use it and learn how to use maven?

I use it because otherwise, Eclipse does not understand multiprojects and I
need them. If you write just a small number of bundles, you can easily live
without it. 

> Another question:
> You mentioned: " the transition from the PDE to a BDE is the 
> thing that would make my life a lot easier".
> 
> Is PDE = Plugin development environment and BDE = Bundle 
> development environment?

Exactly. Since Eclipse is so close to OSGi, the step appears not too big.
However, as I mentioned, I consider the one plugin/bundle = one project
strategy as unreasonable. And no Eclipse 3.3 Extension Point that allows me
to plug in the OSGi framework of my choice for development purposes changes
anything on *this* issue. 


Regards, 

Jan. 

-----------------------------------------------------------
ETH Zurich, MSc Jan S. Rellermeyer,
Information and Communication Systems Research Group (IKS),
Department of Computer Science, IFW B 47.1, 
Haldeneggsteig 4, CH–8092 Zürich 
Tel +41 44 632 30 38, http://www.iks.inf.ethz.ch
----------------------------------------------------------- 


Re: Importing packages and using classes from the bundle that exported it

Posted by "Ivo K. Koga" <iv...@gmail.com>.
Hi Jan,

Sorry abt my ignorance abt many aspects of your e-mail, but you said that
maven could help not getting this kind of errors, or am I wrong?

I don't know anything abt maven unless the mvn clean install to build felix
:-)

But how I can use it to help me?

I saw that a maven eclipse plugin already exist. Do I have just to use it
and learn how to use maven?

Another question:
You mentioned: " the transition from the PDE to a BDE is the thing
that would make my life a lot easier".

Is PDE = Plugin development environment and BDE = Bundle development
environment?


Regards,

Ivo





On 12/17/06, Jan S. Rellermeyer <re...@inf.ethz.ch> wrote:
>
> > Verifying again the classes I was using I realized that Eclipse pointed
> to
> import the class I was using (called MPCLPingResultVO) from other project
> that I was using as a dependency. That was the problem.
>
> Yes, that's a sometimes annoying side-effect copy/paste in Eclipse. I ran
> so
> often into it ...
>
>
> So taking on the previous discussions on Eclipse, Maven and OSGi, I can
> state from my experience that the different handling of dependencies is
> the
> cumbersome part, much more than the quality of the individual strategies.
>
> In Eclipse, everything resides in a magic "bin" folder and over the time,
> a
> lot of old (and dead) code is accumulating which sometimes lead to strange
> side-effects. (Not to speak from those effects that you have just
> encountered: An innocent paste sometimes introduce dependencies that were
> never intended and as long as you stay in Eclipse, they can easily been
> overseen unless you try to run it on "real OSGi".) So a regular cleaning
> of
> the project is necessary.
>
> Since Eclipse is not able to manage multiprojects, I need maven to do this
> task. Maven has it's own repository where the dependencies bundles are
> stored and every subproject has its own target folder. Once again, regular
> cleanups or strange behaviors. What comes out in the end of this process
> is
> still often not what I have intended to do, no matter which plugin I use.
>
> When I start my Eclipse in the morning, I can go for breakfast, read and
> reply to all my mails that have arrived over night (even read all the new
> posts on the felix mailing list :-)) and still have to wait since it takes
> minutes until the workspace has finished building all the open projects.
> The
> reason for this? It's the Maven-Eclipse integration that makes things so
> slow. But if I don't have it, I have yet another layer where I have to
> maintain the dependencies between the bundles. A layer additional to the
> poms that I need for building and to my different OSGi deployments with
> all
> their startup scripts that I need for running and testing. (To make
> matters
> even worse, I am a pervasive computing person, so I have a number of
> different deployments for each project). Everytime I move to a new version
> of a bundle, I have to manually adjust all the dependencies anyway.
>
> So from my point of view, the transition from the PDE to a BDE is the
> thing
> that would make my life a lot easier. But most important, the one bundle =
> one project strategy is far away from reality when it comes to the
> development of real-life OSGi applications (and this is from my point of
> view the main difference between plugins and bundles: The complexity of
> the
> modularization and the resulting dependency structure).
>
>
> Regards,
>
> Jan.
>
>
> -----------------------------------------------------------
> ETH Zurich, MSc Jan S. Rellermeyer,
> Information and Communication Systems Research Group (IKS),
> Department of Computer Science, IFW B 47.1,
> Haldeneggsteig 4, CH–8092 Zürich
> Tel +41 44 632 30 38, http://www.iks.inf.ethz.ch
> -----------------------------------------------------------
>
>


-- 
Msc. Candidate in Computer Networks at Universidade Salvador/BA/Brazil
Measurement WG - RNP/Brazil

RE: Importing packages and using classes from the bundle that exported it

Posted by "Jan S. Rellermeyer" <re...@inf.ethz.ch>.
> Verifying again the classes I was using I realized that Eclipse pointed to
import the class I was using (called MPCLPingResultVO) from other project
that I was using as a dependency. That was the problem.

Yes, that's a sometimes annoying side-effect copy/paste in Eclipse. I ran so
often into it ...


So taking on the previous discussions on Eclipse, Maven and OSGi, I can
state from my experience that the different handling of dependencies is the
cumbersome part, much more than the quality of the individual strategies. 

In Eclipse, everything resides in a magic "bin" folder and over the time, a
lot of old (and dead) code is accumulating which sometimes lead to strange
side-effects. (Not to speak from those effects that you have just
encountered: An innocent paste sometimes introduce dependencies that were
never intended and as long as you stay in Eclipse, they can easily been
overseen unless you try to run it on "real OSGi".) So a regular cleaning of
the project is necessary. 

Since Eclipse is not able to manage multiprojects, I need maven to do this
task. Maven has it's own repository where the dependencies bundles are
stored and every subproject has its own target folder. Once again, regular
cleanups or strange behaviors. What comes out in the end of this process is
still often not what I have intended to do, no matter which plugin I use. 

When I start my Eclipse in the morning, I can go for breakfast, read and
reply to all my mails that have arrived over night (even read all the new
posts on the felix mailing list :-)) and still have to wait since it takes
minutes until the workspace has finished building all the open projects. The
reason for this? It's the Maven-Eclipse integration that makes things so
slow. But if I don't have it, I have yet another layer where I have to
maintain the dependencies between the bundles. A layer additional to the
poms that I need for building and to my different OSGi deployments with all
their startup scripts that I need for running and testing. (To make matters
even worse, I am a pervasive computing person, so I have a number of
different deployments for each project). Everytime I move to a new version
of a bundle, I have to manually adjust all the dependencies anyway.  

So from my point of view, the transition from the PDE to a BDE is the thing
that would make my life a lot easier. But most important, the one bundle =
one project strategy is far away from reality when it comes to the
development of real-life OSGi applications (and this is from my point of
view the main difference between plugins and bundles: The complexity of the
modularization and the resulting dependency structure). 


Regards, 

Jan. 


-----------------------------------------------------------
ETH Zurich, MSc Jan S. Rellermeyer,
Information and Communication Systems Research Group (IKS),
Department of Computer Science, IFW B 47.1, 
Haldeneggsteig 4, CH–8092 Zürich 
Tel +41 44 632 30 38, http://www.iks.inf.ethz.ch
----------------------------------------------------------- 


Re: Importing packages and using classes from the bundle that exported it

Posted by "Ivo K. Koga" <iv...@gmail.com>.
Hi Jan,

Verifying again the classes I was using I realized that Eclipse pointed to
import the class I was using (called MPCLPingResultVO) from other project
that I was using as a dependency. That was the problem.

Thanks,

Ivo


On 12/17/06, Jan S. Rellermeyer <re...@inf.ethz.ch> wrote:
>
> Hi Ivo,
>
> > All the classes are in the same package at
> > br.unifacs.nuperc.ice.osgi.perfsonar.clmp.ping.
>
> > Exception in thread "Thread-3" java.lang.NoClassDefFoundError:
> > br/unifacs/nuperc/ice/mpcl/ping/MPCLPingResultVO
>
> Well, it looks like not *all* classes are in this package. The exception
> complains about a class from the package br.unifacs.nuperc.ice.mpcl.ping.
> Since this package is not imported and (assuming from your first
> statement)
> not contained in the bundle, the class cannot be found. Check, if some
> refactoring went wrong. If you use Eclipse, this is not unlikely to be the
> case :-)
>
> Greets,
>
> Jan.
>
> -----------------------------------------------------------
> ETH Zurich, MSc Jan S. Rellermeyer,
> Information and Communication Systems Research Group (IKS),
> Department of Computer Science, IFW B 47.1,
> Haldeneggsteig 4, CH–8092 Zürich
> Tel +41 44 632 30 38, http://www.iks.inf.ethz.ch
> -----------------------------------------------------------
>
>


-- 
Msc. Candidate in Computer Networks at Universidade Salvador/BA/Brazil
Measurement WG - RNP/Brazil

RE: Importing packages and using classes from the bundle that exported it

Posted by "Jan S. Rellermeyer" <re...@inf.ethz.ch>.
Hi Ivo,  

> All the classes are in the same package at 
> br.unifacs.nuperc.ice.osgi.perfsonar.clmp.ping.

> Exception in thread "Thread-3" java.lang.NoClassDefFoundError:
> br/unifacs/nuperc/ice/mpcl/ping/MPCLPingResultVO

Well, it looks like not *all* classes are in this package. The exception
complains about a class from the package br.unifacs.nuperc.ice.mpcl.ping.
Since this package is not imported and (assuming from your first statement)
not contained in the bundle, the class cannot be found. Check, if some
refactoring went wrong. If you use Eclipse, this is not unlikely to be the
case :-) 

Greets, 

Jan. 

-----------------------------------------------------------
ETH Zurich, MSc Jan S. Rellermeyer,
Information and Communication Systems Research Group (IKS),
Department of Computer Science, IFW B 47.1, 
Haldeneggsteig 4, CH–8092 Zürich 
Tel +41 44 632 30 38, http://www.iks.inf.ethz.ch
-----------------------------------------------------------