You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by André Lage <An...@irisa.fr> on 2009/11/24 20:09:52 UTC

Passing information (java parameters) to Felix

Hello!

I've tried to run a bundle on Felix with no success. This bundle needs 
to tell Java some details about it. For instance, as a simple Java 
class, I run it like this:

java \
     -cp "$SAGA_CLASSPATH:$CLASSPATH" \
 
-Djava.endorsed.dirs=$JAVA_SAGA_LOCATION/lib/adaptors/GridsamAdaptor/endorsed:$JAVA_SAGA_LOCATION/lib/endorsed 
\
     -Dlog4j.configuration="file:$JAVA_SAGA_LOCATION/log4j.properties" \
     -Dsaga.factory="eu.xtreemos.xosaga.bootstrap.MetaFactory" \
     -Dsaga.location="$JAVA_SAGA_LOCATION" \
     MyClassIWannaRun

In Felix, I don't know how to "put" this information. I've tried to add 
it in the config.properties file further packages but it didn't solve 
the issue. I've also done a bunch of bundles from all jars that my 
app/bundle needs by using the bnd tool (http://www.aqute.biz/Code/Bnd).

So that's what *I think* it is happening. I have no classpath problems 
since the libs are now bundles that export their packages. However, I 
don't tell Felix about the configuration I need (java.endorsed.dirs, 
log4j.configuration, saga.factory and saga.location).

Finally, I had the "great" idea of running Felix as follows:

  java \
     -cp "$SAGA_CLASSPATH:$CLASSPATH" \
 
-Djava.endorsed.dirs=$JAVA_SAGA_LOCATION/lib/adaptors/GridsamAdaptor/endorsed:$JAVA_SAGA_LOCATION/lib/endorsed 
\
     -Dlog4j.configuration="file:$JAVA_SAGA_LOCATION/log4j.properties" \
     -Dsaga.factory="eu.xtreemos.xosaga.bootstrap.MetaFactory" \
     -Dsaga.location="$JAVA_SAGA_LOCATION" \
     -jar bin/felix.jar

Even though Felix runs, I think it ignores those parameters -- actually 
Felix behaves the same with or without those parameters.

Does anybody have any idea of how to tell Felix about those parameters?


Thanks in advance,


André Lage.

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


Re: Passing information (java parameters) to Felix

Posted by André Lage <An...@irisa.fr>.

Richard S. Hall wrote:
> On 11/24/09 14:09, André Lage wrote:
>> Hello!
>>
>> I've tried to run a bundle on Felix with no success. This bundle needs 
>> to tell Java some details about it. For instance, as a simple Java 
>> class, I run it like this:
>>
>> java \
>>     -cp "$SAGA_CLASSPATH:$CLASSPATH" \
>>
>> -Djava.endorsed.dirs=$JAVA_SAGA_LOCATION/lib/adaptors/GridsamAdaptor/endorsed:$JAVA_SAGA_LOCATION/lib/endorsed 
>> \
>>     -Dlog4j.configuration="file:$JAVA_SAGA_LOCATION/log4j.properties" \
>>     -Dsaga.factory="eu.xtreemos.xosaga.bootstrap.MetaFactory" \
>>     -Dsaga.location="$JAVA_SAGA_LOCATION" \
>>     MyClassIWannaRun
>>
>> In Felix, I don't know how to "put" this information. I've tried to 
>> add it in the config.properties file further packages but it didn't 
>> solve the issue. I've also done a bunch of bundles from all jars that 
>> my app/bundle needs by using the bnd tool 
>> (http://www.aqute.biz/Code/Bnd).
>>
>> So that's what *I think* it is happening. I have no classpath problems 
>> since the libs are now bundles that export their packages. However, I 
>> don't tell Felix about the configuration I need (java.endorsed.dirs, 
>> log4j.configuration, saga.factory and saga.location).
>>
>> Finally, I had the "great" idea of running Felix as follows:
>>
>>  java \
>>     -cp "$SAGA_CLASSPATH:$CLASSPATH" \
>>
>> -Djava.endorsed.dirs=$JAVA_SAGA_LOCATION/lib/adaptors/GridsamAdaptor/endorsed:$JAVA_SAGA_LOCATION/lib/endorsed 
>> \
>>     -Dlog4j.configuration="file:$JAVA_SAGA_LOCATION/log4j.properties" \
>>     -Dsaga.factory="eu.xtreemos.xosaga.bootstrap.MetaFactory" \
>>     -Dsaga.location="$JAVA_SAGA_LOCATION" \
>>     -jar bin/felix.jar
>>
>> Even though Felix runs, I think it ignores those parameters -- 
>> actually Felix behaves the same with or without those parameters.
> 
> If you use "-jar" then "-cp" is ignored. If you want to set the class 
> path, then you will need to do something like:
> 
>     java -cp felix.jar;stuff.jar org.apache.felix.main.Main
> 
> This should start the framework with the specified class path.
> 
>> Does anybody have any idea of how to tell Felix about those parameters?
> 
> Felix would never do anything with the "-D" arguments, since they are 
> used by the JVM to set system properties. The above command should set 
> them correctly, though, so your bundles should be able to see them using 
> System.getProperty().
> 
> You can also set system properties in conf/system.properties as a 
> convenience.


I started Felix as you said and my bundle can see the properties and the 
classpath. Moreover, I put the properties in the system.properties file 
as you suggested.

But it was not the only problem. I'm running a non trivial application 
that requires some adjustments, your tips helped me to solve part of 
them. The main issue I had came from bundles automatically generated by 
bnd. In that case, bnd is not enough because they need to be later 
configured anyway (manifest file). So, I decided to wrap the jars I need 
as Bundle-Classpath in a single bundle for a while.

Thanks,


André.

> 
> -> richard
>>
>>
>> Thanks in advance,
>>
>>
>> André Lage.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
> 


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


Re: Passing information (java parameters) to Felix

Posted by "Richard S. Hall" <he...@ungoverned.org>.
On 11/24/09 14:09, André Lage wrote:
> Hello!
>
> I've tried to run a bundle on Felix with no success. This bundle needs 
> to tell Java some details about it. For instance, as a simple Java 
> class, I run it like this:
>
> java \
>     -cp "$SAGA_CLASSPATH:$CLASSPATH" \
>
> -Djava.endorsed.dirs=$JAVA_SAGA_LOCATION/lib/adaptors/GridsamAdaptor/endorsed:$JAVA_SAGA_LOCATION/lib/endorsed 
> \
>     -Dlog4j.configuration="file:$JAVA_SAGA_LOCATION/log4j.properties" \
>     -Dsaga.factory="eu.xtreemos.xosaga.bootstrap.MetaFactory" \
>     -Dsaga.location="$JAVA_SAGA_LOCATION" \
>     MyClassIWannaRun
>
> In Felix, I don't know how to "put" this information. I've tried to 
> add it in the config.properties file further packages but it didn't 
> solve the issue. I've also done a bunch of bundles from all jars that 
> my app/bundle needs by using the bnd tool 
> (http://www.aqute.biz/Code/Bnd).
>
> So that's what *I think* it is happening. I have no classpath problems 
> since the libs are now bundles that export their packages. However, I 
> don't tell Felix about the configuration I need (java.endorsed.dirs, 
> log4j.configuration, saga.factory and saga.location).
>
> Finally, I had the "great" idea of running Felix as follows:
>
>  java \
>     -cp "$SAGA_CLASSPATH:$CLASSPATH" \
>
> -Djava.endorsed.dirs=$JAVA_SAGA_LOCATION/lib/adaptors/GridsamAdaptor/endorsed:$JAVA_SAGA_LOCATION/lib/endorsed 
> \
>     -Dlog4j.configuration="file:$JAVA_SAGA_LOCATION/log4j.properties" \
>     -Dsaga.factory="eu.xtreemos.xosaga.bootstrap.MetaFactory" \
>     -Dsaga.location="$JAVA_SAGA_LOCATION" \
>     -jar bin/felix.jar
>
> Even though Felix runs, I think it ignores those parameters -- 
> actually Felix behaves the same with or without those parameters.

If you use "-jar" then "-cp" is ignored. If you want to set the class 
path, then you will need to do something like:

     java -cp felix.jar;stuff.jar org.apache.felix.main.Main

This should start the framework with the specified class path.

> Does anybody have any idea of how to tell Felix about those parameters?

Felix would never do anything with the "-D" arguments, since they are 
used by the JVM to set system properties. The above command should set 
them correctly, though, so your bundles should be able to see them using 
System.getProperty().

You can also set system properties in conf/system.properties as a 
convenience.

-> richard
>
>
> Thanks in advance,
>
>
> André Lage.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

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