0

我编写了以下代码来读取 arxml 文件的内容。

@Test
    public void second() throws IOException {

        private XMLResource resource;

        String file = "E:\\Input\\ArText_0001.arxml";

        AutosarResourceSetImpl resourceSet = new AutosarResourceSetImpl();

        Autosar40ResourceFactoryImpl resourceFactory = new Autosar40ResourceFactoryImpl();

        URI uri = URI.createFileURI(file );

        Map<?, ?> options = null;

        resource = (XMLResource) resourceFactory.createResource(uri);

        resource.load(options); 

        resourceSet.getResources().add(resource);

    }

我使用 clean verify goal 运行项目,在 eclipse 中它工作正常,但从命令行使用 maven 我得到以下异常。

java.lang.StackOverflowError: null
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)

最后我知道我在resource.load(option)中遇到了问题。我也尝试了以下方法而不是option = null

option.put(Resource.Factory.Registry.DEFAULT_EXTENSION,new Autosar40ResourceFactoryImpl())

但现在我也遇到了同样的异常。请帮我解决这个问题?

例外:

    Time elapsed: 12.846 sec  <<< ERROR!
java.lang.StackOverflowError: null
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:273)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:586)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:538)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:525)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:325)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:345)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.defineClass(ModuleClassLoader.java:273)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.defineClass(ClasspathManager.java:632)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findClassImpl(ClasspathManager.java:586)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClassImpl(ClasspathManager.java:538)
    at org.eclipse.osgi.internal.loader.classpath.ClasspathManager.findLocalClass(ClasspathManager.java:525)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.findLocalClass(ModuleClassLoader.java:325)
    at org.eclipse.osgi.internal.loader.BundleLoader.findLocalClass(BundleLoader.java:345)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:423)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
    at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at autosar40.diagnosticextract.dcm.diagnosticservice.environmentalcondition.EnvironmentalconditionFactory.<clinit>(EnvironmentalconditionFactory.java:41)
    at autosar40.diagnosticextract.dcm.diagnosticservice.environmentalcondition.impl.EnvironmentalconditionPackageImpl.<init>(EnvironmentalconditionPackageImpl.java:1152)
    at autosar40.diagnosticextract.dcm.diagnosticservice.environmentalcondition.impl.EnvironmentalconditionPackageImpl.init(EnvironmentalconditionPackageImpl.java:1206)
    at autosar40.diagnosticextract.dcm.diagnosticservice.environmentalcondition.EnvironmentalconditionPackage.<clinit>(EnvironmentalconditionPackage.java:84)
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
    at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
    at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
    at java.lang.reflect.Field.get(Field.java:393)
    at org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor.getEPackage(RegistryReader.java:275)
    at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:127)
    at autosar40.diagnosticextract.dcm.obdservice.mode_0x0a_requestemissionrelateddtcpermanentstatus.impl.Mode_0x0a_requestemissionrelateddtcpermanentstatusPackageImpl.init(Mode_0x0a_requestemissionrelateddtcpermanentstatusPackageImpl.java:1400)
    at autosar40.diagnosticextract.dcm.obdservice.mode_0x0a_requestemissionrelateddtcpermanentstatus.Mode_0x0a_requestemissionrelateddtcpermanentstatusPackage.<clinit>(Mode_0x0a_requestemissionrelateddtcpermanentstatusPackage.java:78)
    at sun.misc.Unsafe.ensureClassInitialized(Native Method)
    at sun.reflect.UnsafeFieldAccessorFactory.newFieldAccessor(UnsafeFieldAccessorFactory.java:43)
    at sun.reflect.ReflectionFactory.newFieldAccessor(ReflectionFactory.java:142)
    at java.lang.reflect.Field.acquireFieldAccessor(Field.java:1088)
    at java.lang.reflect.Field.getFieldAccessor(Field.java:1069)
    at java.lang.reflect.Field.get(Field.java:393)
    at org.eclipse.emf.ecore.plugin.RegistryReader$EPackageDescriptor.getEPackage(RegistryReader.java:275)
    at org.eclipse.emf.ecore.impl.EPackageRegistryImpl.getEPackage(EPackageRegistryImpl.java:127)
    at autosar40.diagnosticextract.dcm.obdservice.mode_0x09_requestvehicleinformation.impl.Mode_0x09_requestvehicleinformationPackageImpl.init(Mode_0x09_requestvehicleinformationPackageImpl.java:1399)
4

0 回答 0