Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use JiBX with Java 8 #3

Closed
manish-in-java opened this issue May 3, 2014 · 18 comments
Closed

Unable to use JiBX with Java 8 #3

manish-in-java opened this issue May 3, 2014 · 18 comments

Comments

@manish-in-java
Copy link

Java: Oracle JDK 1.8.0.0, Oracle JDK 1.8.0.05, OpenJDK 1.8.0
OS: 64-bit CentOS, 64-bit RedHat, 64-bit Amazon Linux, 64-bit Fedora, 64-bit Windows 7 Professional, 64-bit Windows 8 Pro
JiBX: 1.2.5

We are trying to upgrade our applications (around 60 in number) to Java 8. All of them use JiBX and JiBX Maven plugin version 1.2.5. The following error is received during the Maven builds and the builds fail:

Failed to execute goal org.jibx:jibx-maven-plugin:1.2.5:bind (bind-compile) on project common: Error loading class java.lang.CharSequence: Error reading path java/lang/CharSequence.class for class java.lang.CharSequence
  ...
  at org.jibx.binding.classes.ClassCache$ClassCacheLocator.getClassInfo(ClassCache.java:291)
  at org.jibx.binding.model.ClassHierarchyContext.accumulateInterfaces(ClassHierarchyContext.java:95)
  at org.jibx.binding.model.ClassHierarchyContext.addTypedComponent(ClassHierarchyContext.java:121)
  ...

This problem has existed since the first OpenJDK developer preview came out and has been reported in several forums. What are the plans to fix this?

@markathomas
Copy link

Yes please, when will this be fixed?

@Vad1mo
Copy link

Vad1mo commented Jul 31, 2014

I debugged the code and the Problem is related to BCEL.
https://issues.apache.org/jira/browse/BCEL-173
It is marked fixed for 6.0 but not released yet. I couldn't find a release date.
As a workaround I switch to BECEL 6.0 snapshot and the binding worked.

<build>
      <plugins>
         <plugin>
            <groupId>org.jibx</groupId>
            <artifactId>jibx-maven-plugin</artifactId>
            <version>1.2.5</version>
            <configuration>
               <verbose>true</verbose>
               <options>
                  <import-docs>false</import-docs>
                  <show-schema>false</show-schema>
               </options>
               <customizations>
                  <customization>src/main/config/config.xml</customization>
               </customizations>
               <!-- <schemaLocation>src/main/xsd</schemaLocation> -->
               <includeSchemas>
                  <includeSchema>SCHEMA.xsd</includeSchema>
               </includeSchemas>
               <!-- <schemaBindingDirectory>src/main/java</schemaBindingDirectory> -->

            </configuration>
            <executions>
               <execution>
                  <id>generate-java-code-from-schema</id>
                  <!-- <phase>generate-sources</phase> -->
                  <goals>
                     <!-- <goal>schema-codegen</goal> -->
                     <!-- <goal>test-schema-codegen</goal> -->
                  </goals>
               </execution>
               <execution>
                  <id>bind-xml</id>
                  <goals>
                     <goal>bind</goal>
                  </goals>
               </execution>
            </executions>
            <dependencies>
               <dependency>
                  <groupId>org.jibx</groupId>
                  <artifactId>jibx-bind</artifactId>
                  <version>1.2.5</version>
                  <exclusions>
                     <exclusion>
                        <artifactId>bcel</artifactId>
                        <groupId>bcel</groupId>
                     </exclusion>
                  </exclusions>
               </dependency>
               <dependency>
                  <groupId>org.apache.bcel</groupId>
                  <artifactId>bcel</artifactId>
                  <version>6.0-SNAPSHOT</version>
               </dependency>
            </dependencies>
         </plugin>
   <repositories>
      <repository>
         <id>apache.snapshots</id>
         <url>https://repository.apache.org/content/repositories/snapshots</url>
         <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
         </snapshots>
         <releases>
            <enabled>false</enabled>
         </releases>
      </repository>
   </repositories>

@ianbrandt
Copy link

Per JIBX-514 I believe JIRA is the canonical tracker for JiBX issues. I've migrated the content from this issue to JIBX-515.

@analytically
Copy link

+1

1 similar comment
@zhupan
Copy link

zhupan commented Jun 16, 2015

+1

@markathomas
Copy link

Perhaps JiBX should move to a different bytecode library such as ASM, Byteman, or Byte Buddy. It appears BCEL hasn't seen any activity in quite a while.

@Vad1mo
Copy link

Vad1mo commented Jun 16, 2015

I am not so sure this could be done that easy. do you have knowledge in one of these tools you are refering? You could give it a try.

@manish-in-java
Copy link
Author

I made an attempt to port over to ASM, spent 2 days, could not port all the code and therefore gave up. I estimated that it would take about 6 weeks to complete the port. I contacted Dennis Sosnosky, the original developer of JiBX and he confirmed that he has no plans of upgrading to Java 8 because his estimate was 8-12 weeks and he could not afford to invest that much effort outside of his regular work hours. Dennis also mentioned that he had made a proposal on the JiBX users list to sponsor a project for him to port over to ASM but no one showed interest.

My team got convinced last year that there was no surety around JiBX getting ported to Java 8. So, we branched off our production application, got rid of JiBX and plugged in JAXB in its place. Then we ran some performance tests against our master branch using JiBX and JDK 7 and the new branch using JAXB and JDK 8. We did not find any conclusive evidence of a performance difference between the two. Our most complicated use case involves importing a file containing 36,000+ products with each product having over 200 attributes in the XML file. We did not find much practical difference between JiBX and JAXB with this file. Also, all our XML serialization-deserialization use cases are infrequent so there was no real reason to worry too much about performance. We therefore migrated to JAXB immediately and have not seen any apparent problems so far.

All our XML manipulation code is in a single class that is invoked from multiple places. Therefore, we had to change only one file and we were done. For teams using a similar approach, migration to JAXB may be a viable option, given that JAXB is now part of the standard JDK and therefore guaranteed to get upgraded with Java versions.

For those looking for an example, here is our code (comments and some sensitive parts ommitted):

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.Serializable;

public class XMLHandler
{
  public static <T extends Serializable> T read(final InputStream stream, final Class<T> type)
  {
    try
    {
      return (T) JAXBContext.newInstance(type).createUnmarshaller().unmarshal(stream);
    }
    catch(final JAXBException e)
    {
      throw new RuntimeException("Unable to read from XML input stream for class " + type.getName() + ".", e);
    }

    return null;
  }

  public static <T extends Serializable> void write(final OutputStream stream, final T object)
  {
    try
    {
      JAXBContext.newInstance(object.getClass()).createMarshaller().marshal(object, stream);
    }
    catch (final JAXBException e)
    {
      throw new RuntimeException("Unable to write to XML output stream for class " + object.getClass().getName() + ".", e);
    }
  }
}

@passyt
Copy link

passyt commented Sep 22, 2015

I have re-code the binding part of Jibx with Javassist, and it support JDK1.8. See my project: https://github.com/passyt/jibx-bind

@archiecobbs
Copy link

FYI,

JiBX 1.2.6 binding now works on Java 1.8. You have to use the latest 6.0-SNAPSHOT of the BCEL library, which is available here.

However and weirdly, it works for me on Linux, but not on Mac OS X. I'm using OpenJDK 1.8.0_60-b27 on Linux and Oracle Java 1.8.0_60-b27 on Mac OS X. On Mac OS X I'm still getting the java.lang.CharSequence error.

@markathomas
Copy link

check your environment. if using Ant, please remove any references to
bcel, ant-bcel, and apache-bcel from any files in /etc/ant.d/ (or wherever
those files may be in an OSX environment) as those jars will be added to
ant's bootclasspath and override your classpath

Regards,

Mark Thomas
spatialguru.net@gmail.com
205.529.9013

"Commit to the Lord whatever you do,
and your plans will succeed." - Proverbs 16:3

On Fri, Oct 2, 2015 at 12:56 PM, Archie L. Cobbs notifications@github.com
wrote:

FYI,

JiBX 1.2.6 binding now works on Java 1.8. You have to use the latest
6.0-SNAPSHOT of the BCEL library, which is available here
https://repository.apache.org/content/groups/snapshots/org/apache/bcel/bcel/6.0-SNAPSHOT/
.

However and weirdly, it works for me on Linux, but not on Mac OS X. I'm
using OpenJDK 1.8.0_60-b27 on Linux and Oracle Java 1.8.0_60-b27 on Mac OS
X. On Mac OS X I'm still getting the java.lang.CharSequence error.


Reply to this email directly or view it on GitHub
#3 (comment).

@archiecobbs
Copy link

Thanks! That was indeed the problem. This fixed it:

$ find /usr/local/Cellar/ant -type f -iname '*bcel*' | xargs rm

FYI I'm using brew for installing 3rd party software on Mac OS X.

@markathomas
Copy link

you're welcome

Regards,

Mark Thomas
spatialguru.net@gmail.com
205.529.9013

"Commit to the Lord whatever you do,
and your plans will succeed." - Proverbs 16:3

On Fri, Oct 2, 2015 at 1:20 PM, Archie L. Cobbs notifications@github.com
wrote:

Thanks! That was indeed the problem. This fixed it:

$ find /usr/local/Cellar/ant -type f -iname 'bcel' | xargs rm

FYI I'm using brew for installing 3rd party software on Mac OS X.


Reply to this email directly or view it on GitHub
#3 (comment).

@alberto-hernandez
Copy link

Hi All,

Since past July, BCEL 6.0 is available so I suppose new version could be realease with this dependency.
Thanks for your effort.

@zhupan
Copy link

zhupan commented Sep 20, 2016

It‘s a good news.

@doncorley
Copy link
Contributor

doncorley commented Nov 9, 2016

JiBX 1.3.0-SNAPSHOT has been released.

Thanks to the new BCEL release, JiBX is now compatible with JDK 1.6, 1.7, and 1.8.

You can find the jar file here:
https://sourceforge.net/projects/jibx/files/jibx/jibx-1.3.0-SNAPSHOT/jibx_1_3_0_SNAPSHOT.zip

The snapshot is in the maven central snapshot repo.

You can browse maven snapshots here:
https://oss.sonatype.org/content/repositories/snapshots/org/jibx/

To use a snapshot in your pom file, add a repository section:

<repositories>
    <repository>
      <id>central</id>
      <name>Maven Repository Switchboard</name>
      <layout>default</layout>
      <url>http://repo1.maven.org/maven2</url>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>

    <repository>
      <id>central-snapshot</id>
      <name>Central Repository</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Maven Plugin Repository</name>
      <url>http://repo1.maven.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>

    <pluginRepository>
      <id>central-snapshot</id>
      <name>Central Repository</name>
      <url>https://oss.sonatype.org/content/repositories/snapshots</url>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
        <enabled>false</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>

Test it. Log your issues here:
https://github.com/jibx -> Issues

It looks pretty solid. I should be able to put out a release in a few weeks. @dcorleyusc

@doncorley
Copy link
Contributor

Fixed!

@scofier
Copy link

scofier commented Jan 6, 2017

on maven , we should update maven-jibx-plugin to 1.3.1

org.jibx
maven-jibx-plugin
1.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests