XStream Json / OSGi application with jdk 1.4

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

XStream Json / OSGi application with jdk 1.4

Brice Vandeputte
Hi all,

 I'm trying to use XStream (JSON mode) with the following constraints:

  - jdk 1.4,
  - Prosyst OSGi container.


In the official "news.html" page, I read (nov 2011):
>  Anyone who needs a version for Java 1.4.2 can build it easily from source, this build is still supported and part of CI.

So I get the xstream source and I compile it using JDK 1.4.2_19 and maven 2.0.11 (with success).
In my target bundle application I just inline the following ressources from the distribution :
 - xstream-1.4.7.jar
 - jettison-1.0.1.jar
 - stax-1.2.0.jar
 - stax-api-1.0.1.jar

When I start my application, I Got the following result :
 > org.osgi.framework.BundleException: Can't Resolve poc-bundle : com.ibm.xml.xlxp.api.stax

So my questions are:
- is xstream always compliant with jdk 1.4 ?
- do you know how to solve this dependency error ?
- what's wrong in the way I use xstream ?

Thanks
Regards
Brice
Reply | Threaded
Open this post in threaded view
|

Re: XStream Json / OSGi application with jdk 1.4

Jörg Schaible-4
Hello Brice,

Brice Vandeputte wrote:

> Hi all,
>
>  I'm trying to use XStream (JSON mode) with the following constraints:
>
>   - jdk 1.4,
>   - Prosyst OSGi container.
>
>
> In the official "news.html" page, I read (nov 2011):
>>  Anyone who needs a version for Java 1.4.2 can build it easily from
> source, this build is still supported and part of CI.
>
> So I get the xstream source and I compile it using JDK 1.4.2_19 and maven
> 2.0.11 (with success).
> In my target bundle application I just inline the following ressources
> from the distribution :
>  - xstream-1.4.7.jar
>  - jettison-1.0.1.jar
>  - stax-1.2.0.jar
>  - stax-api-1.0.1.jar
>
> When I start my application, I Got the following result :
>  > org.osgi.framework.BundleException: Can't Resolve poc-bundle :
> com.ibm.xml.xlxp.api.stax
>
> So my questions are:
> - is xstream always compliant with jdk 1.4 ?

Yes, otherwise you would not have been able to build it. The unit tests are
quite extensive. OSGi support is a different story though.

> - do you know how to solve this dependency error ?
> - what's wrong in the way I use xstream ?

The reported error message indicates that this is an error reported by OSGi.
My OSGi knowledge is very limited, therefore I'd check the manifests of the
jars from above for this bundle requirement. Note, that no OSGi entries are
added to XStream's manifest if you build with Java 1.4 (mainly because the
Felix bundle-plugin requires a Java 5 runtime), you will have to handcraft a
manifest on your own.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: XStream Json / OSGi application with jdk 1.4

Brice Vandeputte
Thanks Jörg for your answer.

 I'm currently trying to do that: a custom bundle by hand.

I get the following resource content:
>  - xstream-1.4.7.jar
>  - jettison-1.0.1.jar

to make my own bundle.
I share the bundle.jar::/META-INF/MANIFEST.MF on gist

     be warn that I didn't report all xtream package here (bundle export package )..


At runtime I got the following exception:

   Exception in thread "Thread-697" java.lang.NoClassDefFoundError: java.util.regex.Pattern
        at com.thoughtworks.xstream.XStream.<clinit>(Unknown Source)
        at java.lang.J9VMInternals.initializeImpl(Native Method)
        at java.lang.J9VMInternals.initialize(Unknown Source)
        (...)


I check "java.util.regex.Pattern" which is available since 1.4... 
but this class seems not available on J9 JVM.

I will maybe try to test an older version of xstream.

Regards

Brice

2014-12-09 13:59 GMT+01:00 Jörg Schaible
Hello Brice,

Brice Vandeputte wrote:

> Hi all,
>
>  I'm trying to use XStream (JSON mode) with the following constraints:
>
>   - jdk 1.4,
>   - Prosyst OSGi container.
>
>
> In the official "news.html" page, I read (nov 2011):
>>  Anyone who needs a version for Java 1.4.2 can build it easily from
> source, this build is still supported and part of CI.
>
> So I get the xstream source and I compile it using JDK 1.4.2_19 and maven
> 2.0.11 (with success).
> In my target bundle application I just inline the following ressources
> from the distribution :
>  - xstream-1.4.7.jar
>  - jettison-1.0.1.jar
>  - stax-1.2.0.jar
>  - stax-api-1.0.1.jar
>
> When I start my application, I Got the following result :
>  > org.osgi.framework.BundleException: Can't Resolve poc-bundle :
> com.ibm.xml.xlxp.api.stax
>
> So my questions are:
> - is xstream always compliant with jdk 1.4 ?

Yes, otherwise you would not have been able to build it. The unit tests are
quite extensive. OSGi support is a different story though.

> - do you know how to solve this dependency error ?
> - what's wrong in the way I use xstream ?

The reported error message indicates that this is an error reported by OSGi.
My OSGi knowledge is very limited, therefore I'd check the manifests of the
jars from above for this bundle requirement. Note, that no OSGi entries are
added to XStream's manifest if you build with Java 1.4 (mainly because the
Felix bundle-plugin requires a Java 5 runtime), you will have to handcraft a
manifest on your own.

Cheers,
Jörg


Reply | Threaded
Open this post in threaded view
|

Re: XStream Json / OSGi application with jdk 1.4

Brice Vandeputte
Hey,
  using xstream 1.4.2 I've no "regex.Pattern" usage in the main XStream classes 
  (only on some extended converters..)
  So this works now ! 
  (My need was only to be able to searialize in JSON a basic PoJo tree).

  A little question: 
      for "embedded users" like me (using J9 JVM); how could we make possible to continue to use the latest xstream version ?
           maybe add an xstream improvment to migrate native "regex Pattern" usage to a dedicated dependency like "jakarta-regexp"(available in osgi 1.4) ?  I don't know..

anyway thanks again.

Regards
  

2014-12-10 11:27 GMT+01:00 Brice 

I check "java.util.regex.Pattern" which is available since 1.4... 
but this class seems not available on J9 JVM.

I will maybe try to test an older version of xstream.

Reply | Threaded
Open this post in threaded view
|

Re: Re: XStream Json / OSGi application with jdk 1.4

Jörg Schaible-2
Hello Brice,

Brice Vandeputte wrote:
> 2014-12-10 11:27 GMT+01:00 Brice
>>
>>
>> I check "java.util.regex.Pattern" which is available since 1.4...
>> but this class seems not available on J9 JVM.

My J9 has no problems with it:

------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 16 seconds
[INFO] Finished at: Wed Dec 10 23:26:37 CET 2014
[INFO] Final Memory: 38M/100M
[INFO]
------------------------------------------------------------------------
: ~/src/Codehaus/xstream-1.4.x/xstream $ java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 2.3)
IBM J9 VM (build 2.3, J2RE 1.4.2 IBM J9 2.3 Linux amd64-64
j9vmxa64142ifx-20110312 (JIT enabled)
J9VM - 20110202_74499_LHdSMr
JIT  - 20090210_1447ifx2_r8
GC   - 200902_24)


What kind of edition are you using?


>> I will maybe try to test an older version of xstream.
>
> Hey,
>   using xstream 1.4.2 I've no "regex.Pattern" usage in the main XStream
> classes
>   (only on some extended converters..)
>   So this works now !
>   (My need was only to be able to searialize in JSON a basic PoJo tree).
>
>   A little question:
>       for "embedded users" like me (using J9 JVM); how could we make
> possible to continue to use the latest xstream version ?
>            maybe add an xstream improvment to migrate native "regex
> Pattern" usage to a dedicated dependency like "jakarta-regexp"(available
> in
> osgi 1.4) ?  I don't know..

We can load the class dynamically. This happens already e.g. for the types
in the java.sql.* package that are also not available in some embedded envs.

Just open a JIRA issue (you have to create a full user account at
xircles.codehaus.org first).

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Re: XStream Json / OSGi application with jdk 1.4

Brice Vandeputte
Jörg

Oh, you're right, my current J9 JVM version seems older (2008) than yours (2011) :


j9_2.4_jclFoundation11_ARM_Linux/bin/j9 -version

java version "WECE J2ME Foundation Specification v1.1"
IBM J9 2.4 Linux arm-32  (JIT enabled)
J9VM - 20080409_018613_lEdFGQ
JIT  - r9.weme62_20071207_2130ifx2
GC   - 20080229_AA
MD  - 20110302_release_1.00_23801
JCL  - 20080409_1632,foun11

Licensed Materials - Property of IBM

J9 - VM for the Java(TM) platform, Version 2.4
(c) Copyright IBM Corp. 1991, 2008  All Rights Reserved
Target: 20080409_018613_lEdFGQ (Linux 2.6.27.62 arm)
IBM is a registered trademark of IBM Corp.
Java and all Java-based marks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc.


thanks
regards
Brice


2014-12-10 23:32 GMT+01:00 Jörg Schaible <[hidden email]>:
Hello Brice,

Brice Vandeputte wrote:
> 2014-12-10 11:27 GMT+01:00 Brice
>>
>>
>> I check "java.util.regex.Pattern" which is available since 1.4...
>> but this class seems not available on J9 JVM.

My J9 has no problems with it:

------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
------------------------------------------------------------------------
[INFO] Total time: 16 seconds
[INFO] Finished at: Wed Dec 10 23:26:37 CET 2014
[INFO] Final Memory: 38M/100M
[INFO]
------------------------------------------------------------------------
: ~/src/Codehaus/xstream-1.4.x/xstream $ java -version
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 2.3)
IBM J9 VM (build 2.3, J2RE 1.4.2 IBM J9 2.3 Linux amd64-64
j9vmxa64142ifx-20110312 (JIT enabled)
J9VM - 20110202_74499_LHdSMr
JIT  - 20090210_1447ifx2_r8
GC   - 200902_24)


What kind of edition are you using?


>> I will maybe try to test an older version of xstream.
>
> Hey,
>   using xstream 1.4.2 I've no "regex.Pattern" usage in the main XStream
> classes
>   (only on some extended converters..)
>   So this works now !
>   (My need was only to be able to searialize in JSON a basic PoJo tree).
>
>   A little question:
>       for "embedded users" like me (using J9 JVM); how could we make
> possible to continue to use the latest xstream version ?
>            maybe add an xstream improvment to migrate native "regex
> Pattern" usage to a dedicated dependency like "jakarta-regexp"(available
> in
> osgi 1.4) ?  I don't know..

We can load the class dynamically. This happens already e.g. for the types
in the java.sql.* package that are also not available in some embedded envs.

Just open a JIRA issue (you have to create a full user account at
xircles.codehaus.org first).

Cheers,
Jörg