Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With gcj compiled java & XStream. (Exception: Cannot create XmlPullParser)

I'm enhancing a client, which is part of a bigger project. Because of the lack of speed i was forced to switch to CNI and therefore i had to generate native code with the GNU-gcj compiler (gnu 4.6.3).

The compiling and linking works fine (thanks to the -findirect-dispatch flag) and i don't have any problems executing the output. But when it comes to the communication between the client and the server, the client immediately disconnects. The reason:

[XStreamClient Reader] WARN - Client disconnected (Exception: com.thoughtworks.xstream.io.StreamException: Cannot create XmlPullParser)

(This Exeption only appears in the gcj compiled version of the client. When i run the code with the java interpreter - things work well (but too slow^^)) --> The challenging part is that i can't retrieve the source code of where this exception occurs because it is in a pre-compiled (Java class files) library the client uses. (And I cannot contact the author of that library)

I guess the library invokes the XppReader which then tries to create a XmlPullParser class and fails.

I bind in the XStream (vers. 1.4.3) library (and other required *.jars) by unpacking them and compiling the created *.class files and then linking the object files. This seems to work for all other librarys, too. (My OS=Ubuntu)

What i already did to overcome this problem: I googled intensively for XStream/XmlPullParser and gcj and replaced the "xmlpull"- and "kxml2"-files with different versions. But nothing worked. Does anyone of you have a clue of what might be the solution?

EDIT:

I figured out that the reason why the XmlPullParser creation fails is that the META-INF directory with the /services/org.xmlpull.v1.XmlPullParserFactory file can not be found by the XmlPullParserFactory.newInstance function. This is due to the fact that i only compiled and linked the *.jar's *.class files. So as soon as i found i way to link the META-INF directory into the executable in away that the function can find and access it, the problem should be solved. Does anyone of you already know a way to do so?

like image 392
Chris Avatar asked Oct 23 '22 05:10

Chris


1 Answers

I think xmlpull need an implementation which can use xpp3 as its implementation. Please add following code into your pom.xml and if required, add these jar files to the software which requires them.

<dependency>
    <groupId>xmlpull</groupId>
    <artifactId>xmlpull</artifactId>
    <version>1.1.3.1</version>
</dependency>
<dependency>
    <groupId>xpp3</groupId>
    <artifactId>xpp3</artifactId>
    <version>1.1.3.3</version>
</dependency>
like image 170
sendon1982 Avatar answered Oct 26 '22 21:10

sendon1982