OpenJPA
  1. OpenJPA
  2. OPENJPA-1038

Enhancer java.lang.StackOverflowError exception when circular dependencies are encountered within embeddables

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0-M2
    • Fix Version/s: 2.0.0-M2
    • Component/s: None
    • Labels:
      None

      Description

      Circular dependencies among embeddable are not allowed. When they are encountered by the Enhancer it gets in an infinite loop causing a stack overflow exception as shown below. It seems there should be a more graceful detection of this scenario and a more useful explanation and/or description of the error. The failure is the same for both annotated and XML versions of the entities/embeddables.

      [jpa.fvt/jpafvt.setup/echo] [exec] 1016 EmbeddableNested_JSE TRACE [main] openjpa.MetaData - Resolving field "suite.r80.base.embeddable.nested.entities.XMLEmbeddable03b@969030082.xmlEmbeddable03a".
      [jpa.fvt/jpafvt.setup/echo] [exec] 1016 EmbeddableNested_JSE TRACE [main] openjpa.MetaData - Generating default metadata for type "suite.r80.base.embeddable.nested.entities.XMLEmbeddable03a".
      [jpa.fvt/jpafvt.setup/echo] [exec] 1016 EmbeddableNested_JSE TRACE [main] openjpa.MetaData - Using reflection for metadata generation.
      [jpa.fvt/jpafvt.setup/echo] [exec] 1016 EmbeddableNested_JSE TRACE [main] openjpa.MetaData - Resolving embedded metadata for "suite.r80.base.embeddable.nested.entities.XMLEmbeddable03a@961886549".
      [jpa.fvt/jpafvt.setup/echo] [exec] Exception in thread "main" java.lang.StackOverflowError
      [jpa.fvt/jpafvt.setup/echo] [exec] at sun.nio.cs.SingleByteEncoder.encodeArrayLoop(SingleByteEncoder.java:76)
      [jpa.fvt/jpafvt.setup/echo] [exec] at sun.nio.cs.SingleByteEncoder.encodeLoop(SingleByteEncoder.java:152)
      [jpa.fvt/jpafvt.setup/echo] [exec] at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:556)
      [jpa.fvt/jpafvt.setup/echo] [exec] at sun.nio.cs.StreamEncoder$CharsetSE.implWrite(StreamEncoder.java:405)
      [jpa.fvt/jpafvt.setup/echo] [exec] at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:159)
      [jpa.fvt/jpafvt.setup/echo] [exec] at java.io.OutputStreamWriter.write(OutputStreamWriter.java:229)
      [jpa.fvt/jpafvt.setup/echo] [exec] at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:122)
      [jpa.fvt/jpafvt.setup/echo] [exec] at java.io.PrintStream.write(PrintStream.java:489)
      [jpa.fvt/jpafvt.setup/echo] [exec] at java.io.PrintStream.print(PrintStream.java:632)
      [jpa.fvt/jpafvt.setup/echo] [exec] at com.ibm.jvm.io.ConsolePrintStream.print(ConsolePrintStream.java:259)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.log.LogFactoryImpl$LogImpl.log(LogFactoryImpl.java:306)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.log.AbstractLog.trace(AbstractLog.java:72)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.log.AbstractLog.trace(AbstractLog.java:67)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1649)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1628)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:417)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.FieldMetaData.resolve(FieldMetaData.java:1702)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.ClassMetaData.resolveMeta(ClassMetaData.java:1693)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.ClassMetaData.resolve(ClassMetaData.java:1628)
      [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.ValueMetaDataImpl.resolve(ValueMetaDataImpl.java:417)

        Activity

        Hide
        Tim McConnell added a comment -

        Issue is now resolved as the Enhancer (as of r765846) is able to detect indirect circular dependencies without getting stack overflow exceptions and it also outputs a more useful Exception message as below:

        [jpa.fvt/jpafvt.setup/echo] do.nothing:
        [jpa.fvt/jpafvt.setup/echo] [echo] Calling wsenhancer script.
        [jpa.fvt/jpafvt.setup/echo] [exec] 93 EmbeddableNested_JSE INFO [main] openjpa.Tool - No targets were given. Running on all classes in your persistent classes list, or all metadata files in classpath directories if you have not listed your persistent classes. Use -help to display tool usage information.
        [jpa.fvt/jpafvt.setup/echo] [exec] 359 EmbeddableNested_JSE INFO [main] openjpa.Enhance - Enhancing type "class suite.r80.base.embeddable.nested.entities.XMLEmbeddable02b".
        [jpa.fvt/jpafvt.setup/echo] [exec] 437 EmbeddableNested_JSE INFO [main] openjpa.Enhance - Enhancing type "class suite.r80.base.embeddable.nested.entities.XMLEntity02".
        [jpa.fvt/jpafvt.setup/echo] [exec] Exception in thread "main" <openjpa-2.0.0-SNAPSHOT-r422266:737816 fatal user error> org.apache.openjpa.util.MetaDataException: Errors encountered while resolving metadata. See nested exceptions for details.
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:563)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:251)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4573)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4520)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4490)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:726)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:716)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4485)
        [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.main(PCEnhancer.java:4476)
        [jpa.fvt/jpafvt.setup/echo] [exec] Caused by: <openjpa-2.0.0-SNAPSHOT-r422266:737816 fatal user error> org.apache.openjpa.util.MetaDataException: Field "suite.r80.base.embeddable.nested.entities.Embeddable05e.embeddable05f.suite.r80.base.embeddable.nested.entities.Embeddable05f.embeddable05a.suite.r80.base.embeddable.nested.entities.Embeddable05a.embeddable05b.suite.r80.base.embeddable.nested.entities.Embeddable05b.embeddable05c.suite.r80.base.embeddable.nested.entities.Embeddable05c.embeddable05d.suite.r80.base.embeddable.nested.entities.Embeddable05d.embeddable05e<class suite.r80.base.embeddable.nested.entities.Embeddable05e>" attempts to recursively embed its declaring type.

        Show
        Tim McConnell added a comment - Issue is now resolved as the Enhancer (as of r765846) is able to detect indirect circular dependencies without getting stack overflow exceptions and it also outputs a more useful Exception message as below: [jpa.fvt/jpafvt.setup/echo] do.nothing: [jpa.fvt/jpafvt.setup/echo] [echo] Calling wsenhancer script. [jpa.fvt/jpafvt.setup/echo] [exec] 93 EmbeddableNested_JSE INFO [main] openjpa.Tool - No targets were given. Running on all classes in your persistent classes list, or all metadata files in classpath directories if you have not listed your persistent classes. Use -help to display tool usage information. [jpa.fvt/jpafvt.setup/echo] [exec] 359 EmbeddableNested_JSE INFO [main] openjpa.Enhance - Enhancing type "class suite.r80.base.embeddable.nested.entities.XMLEmbeddable02b". [jpa.fvt/jpafvt.setup/echo] [exec] 437 EmbeddableNested_JSE INFO [main] openjpa.Enhance - Enhancing type "class suite.r80.base.embeddable.nested.entities.XMLEntity02". [jpa.fvt/jpafvt.setup/echo] [exec] Exception in thread "main" <openjpa-2.0.0-SNAPSHOT-r422266:737816 fatal user error> org.apache.openjpa.util.MetaDataException: Errors encountered while resolving metadata. See nested exceptions for details. [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:563) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.<init>(PCEnhancer.java:251) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4573) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4520) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer$1.run(PCEnhancer.java:4490) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.conf.Configurations.launchRunnable(Configurations.java:726) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.lib.conf.Configurations.runAgainstAllAnchors(Configurations.java:716) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.run(PCEnhancer.java:4485) [jpa.fvt/jpafvt.setup/echo] [exec] at org.apache.openjpa.enhance.PCEnhancer.main(PCEnhancer.java:4476) [jpa.fvt/jpafvt.setup/echo] [exec] Caused by: <openjpa-2.0.0-SNAPSHOT-r422266:737816 fatal user error> org.apache.openjpa.util.MetaDataException: Field "suite.r80.base.embeddable.nested.entities.Embeddable05e.embeddable05f.suite.r80.base.embeddable.nested.entities.Embeddable05f.embeddable05a.suite.r80.base.embeddable.nested.entities.Embeddable05a.embeddable05b.suite.r80.base.embeddable.nested.entities.Embeddable05b.embeddable05c.suite.r80.base.embeddable.nested.entities.Embeddable05c.embeddable05d.suite.r80.base.embeddable.nested.entities.Embeddable05d.embeddable05e<class suite.r80.base.embeddable.nested.entities.Embeddable05e>" attempts to recursively embed its declaring type.

          People

          • Assignee:
            Fay Wang
            Reporter:
            Tim McConnell
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development