You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Bruce Jackson <br...@inqmobile.com> on 2013/06/02 18:18:04 UTC

Felix and scala

Hi All

Have an annoying problem at the moment, and I'm struggling to find a solution so thought I'd ask:

I'm using Felix and have packaged up the scala runtime library and also Goose (https://github.com/jiminoc/goose) into bundles (along with the other various things they require). The goose bundle is basically just a lib folder containing the goose jar and then the various import/exports it needs.

I have then written a simple bundle that creates a TestGoose instance from the activator that simply does:

Configuration config = new Configuration();
config.setEnableImageFetching(false);
Goose goose = new Goose(config);
Article article = goose.extractContent("http://www.bbc.co.uk/news/uk-wales-22723221");

When I run this, I see the following error:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.gravity.goose.extractors.StandardContentExtractor$
	at com.gravity.goose.Configuration.<init>(Configuration.scala:77)

This same code (and library jar) works perfectly when I just create a 'regular' Java app with the libraries on the classpath, and looking at the Goose source, I'm pretty happy that I have correctly satisfied all of the import requirements that Goose needs. The one thing I've not seen before is this kind of class: com.gravity.goose.extractors.StandardContentExtractor$ which I guess must be a Scala thing. Would there be anything in the Felix bundle classloader that would prevent this being loaded correctly?

Thanks

Bruce





This e-mail is only intended for the person(s) to whom it is addressed and may contain CONFIDENTIAL information. Any opinions or views are personal to the writer and do not represent those of INQ Mobile Limited, Hutchison Whampoa Limited or its group companies.  If you  are not the intended recipient, you are hereby notified that any use, retention, disclosure, copying, printing, forwarding or dissemination of this communication is strictly prohibited. If you have received this  communication in error, please erase all copies of the message and its  attachments and notify the sender immediately. INQ Mobile Limited is  a company registered in the British Virgin Islands. www.inqmobile.com.



Re: Felix and scala

Posted by Neil Bartlett <nj...@gmail.com>.
Bruce,

Felix, and other OSGi frameworks, can handle Scala classes just fine --
including the ones with multiple $ suffixes. I know several people using
Scala with OSGi in production.

Most likely the cause of the problem is that your bundle does not import
the package "com.gravity.goose.extractors". How have you built this bundle,
did you write the manifest by hand? Wherever possible it's best to use a
tool like bnd, which will automatically discover dependencies such as this
in compiled code and generate the manifest for you. Since bnd works with
.class files rather than source, it does not care whether the source
language is Scala, Java or anything else.

Regards,
Neil

On Sun, Jun 2, 2013 at 5:18 PM, Bruce Jackson <br...@inqmobile.com> wrote:

> Hi All
>
> Have an annoying problem at the moment, and I'm struggling to find a
> solution so thought I'd ask:
>
> I'm using Felix and have packaged up the scala runtime library and also
> Goose (https://github.com/jiminoc/goose) into bundles (along with the
> other various things they require). The goose bundle is basically just a
> lib folder containing the goose jar and then the various import/exports it
> needs.
>
> I have then written a simple bundle that creates a TestGoose instance from
> the activator that simply does:
>
> Configuration config = new Configuration();
> config.setEnableImageFetching(false);
> Goose goose = new Goose(config);
> Article article = goose.extractContent("
> http://www.bbc.co.uk/news/uk-wales-22723221");
>
> When I run this, I see the following error:
>
> Caused by: java.lang.NoClassDefFoundError: Could not initialize class
> com.gravity.goose.extractors.StandardContentExtractor$
>         at com.gravity.goose.Configuration.<init>(Configuration.scala:77)
>
> This same code (and library jar) works perfectly when I just create a
> 'regular' Java app with the libraries on the classpath, and looking at the
> Goose source, I'm pretty happy that I have correctly satisfied all of the
> import requirements that Goose needs. The one thing I've not seen before is
> this kind of class: com.gravity.goose.extractors.StandardContentExtractor$
> which I guess must be a Scala thing. Would there be anything in the Felix
> bundle classloader that would prevent this being loaded correctly?
>
> Thanks
>
> Bruce
>
>
>
>
>
> This e-mail is only intended for the person(s) to whom it is addressed and
> may contain CONFIDENTIAL information. Any opinions or views are personal to
> the writer and do not represent those of INQ Mobile Limited, Hutchison
> Whampoa Limited or its group companies.  If you  are not the intended
> recipient, you are hereby notified that any use, retention, disclosure,
> copying, printing, forwarding or dissemination of this communication is
> strictly prohibited. If you have received this  communication in error,
> please erase all copies of the message and its  attachments and notify the
> sender immediately. INQ Mobile Limited is  a company registered in the
> British Virgin Islands. www.inqmobile.com.
>
>
>