1

当我尝试运行我的 wildfly-swarm 实例时,抛出了一个奇怪的异常。以下是我得到的错误;

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.wildfly.swarm.bootstrap.Main.invoke(Main.java:78)
    at org.wildfly.swarm.bootstrap.Main.run(Main.java:53)
    at org.wildfly.swarm.bootstrap.Main.main(Main.java:44)
Caused by: java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.hasApplicationPathAnnotation(JAXRSArchiveImpl.java:80)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.hasApplicationPathAnnotation(JAXRSArchiveImpl.java:95)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.hasApplicationPathAnnotation(JAXRSArchiveImpl.java:72)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.access$000(JAXRSArchiveImpl.java:41)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl$ApplicationHandler.handle(JAXRSArchiveImpl.java:249)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.invokeHandlers(MemoryMapArchiveBase.java:238)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.addAsset(MemoryMapArchiveBase.java:185)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.add(MemoryMapArchiveBase.java:126)
    at org.jboss.shrinkwrap.impl.base.ArchiveBase.add(ArchiveBase.java:376)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.add(MemoryMapArchiveBase.java:151)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.add(ContainerBase.java:141)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsLibrary(ContainerBase.java:1729)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsLibraries(ContainerBase.java:1928)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsLibraries(ContainerBase.java:1941)
    at org.wildfly.swarm.spi.api.DependenciesContainer.addAllDependencies(DependenciesContainer.java:34)
    at com.research.fsindexer.bootstrap.FSIndexerBootStrap.addPackageResources(FSIndexerBootStrap.java:78)
    at com.research.fsindexer.bootstrap.FSIndexerBootStrap.bootUpApplication(FSIndexerBootStrap.java:94)
    at com.research.fsindexer.bootstrap.FSIndexerBootStrap.main(FSIndexerBootStrap.java:109)
    ... 7 more
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.wildfly.swarm.bootstrap.Main.invoke(Main.java:78)
    at org.wildfly.swarm.bootstrap.Main.run(Main.java:53)
    at org.wildfly.swarm.bootstrap.Main.main(Main.java:44)
Caused by: java.lang.IllegalArgumentException
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.objectweb.asm.ClassReader.<init>(Unknown Source)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.hasApplicationPathAnnotation(JAXRSArchiveImpl.java:80)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.hasApplicationPathAnnotation(JAXRSArchiveImpl.java:95)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.hasApplicationPathAnnotation(JAXRSArchiveImpl.java:72)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl.access$000(JAXRSArchiveImpl.java:41)
    at org.wildfly.swarm.jaxrs.internal.JAXRSArchiveImpl$ApplicationHandler.handle(JAXRSArchiveImpl.java:249)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.invokeHandlers(MemoryMapArchiveBase.java:238)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.addAsset(MemoryMapArchiveBase.java:185)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.add(MemoryMapArchiveBase.java:126)
    at org.jboss.shrinkwrap.impl.base.ArchiveBase.add(ArchiveBase.java:376)
    at org.jboss.shrinkwrap.impl.base.MemoryMapArchiveBase.add(MemoryMapArchiveBase.java:151)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.add(ContainerBase.java:141)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsLibrary(ContainerBase.java:1729)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsLibraries(ContainerBase.java:1928)
    at org.jboss.shrinkwrap.impl.base.container.ContainerBase.addAsLibraries(ContainerBase.java:1941)
    at org.wildfly.swarm.spi.api.DependenciesContainer.addAllDependencies(DependenciesContainer.java:34)
    at com.research.fsindexer.bootstrap.FSIndexerBootStrap.addPackageResources(FSIndexerBootStrap.java:78)
    at com.research.fsindexer.bootstrap.FSIndexerBootStrap.bootUpApplication(FSIndexerBootStrap.java:94)
    at com.research.fsindexer.bootstrap.FSIndexerBootStrap.main(FSIndexerBootStrap.java:109)
    ... 7 more

我使用了自定义 Main 方法。以下是我的 Main 方法的代码;

public final class FSIndexerBootStrap {

    private void addDependencies ( JAXRSArchive archive ) {

    /*
     * Collection< String > suppliedDependencies =
     * ResearchSuppliedDependenciesConfigurationReader
     * .getSuppliedDependencies();
     * 
     * if ( CollectionUtils.isNotEmpty( suppliedDependencies ) ) {
     * 
     * suppliedDependencies.stream().forEach( suppliedDependency -> { try {
     * archive.addDependency( ( String ) suppliedDependency ); } catch (
     * Exception e ) { // TODO Auto-generated catch block
     * e.printStackTrace(); } } ); }
     */
    }

    private void addSystemProperties () {

    String logFileAbsoluteName = ResearchLoggingConfigurationReader.getLogFileAbsoluteName();

    if ( StringUtils.isNotBlank( logFileAbsoluteName ) ) {
        System.setProperty( "research.log", logFileAbsoluteName );
    }
    }

    private void addPackageResources ( JAXRSArchive archive ) throws IllegalArgumentException, Exception {

    if ( !Objects.equals( null, archive ) ) {
        // archive.addPackages( true, "com/research/fsindexer" );

        archive.addResource( FSIndexerRestApplication.class ).addResource( RESTTest.class )
            .addResource( FileIndexerService.class )
            .addAsWebInfResource(
                new ClassLoaderAsset( "META-INF/beans.xml", FSIndexerBootStrap.class.getClassLoader() ),
                "classes/META-INF/beans.xml" )
            .addAllDependencies();
    }
    }

    @ExceptionHandled
    @Logged
    public void bootUpApplication () throws Exception {

    addSystemProperties();

    final Swarm SWARM = new Swarm( true );

    final JAXRSArchive DEPLOYMENT = ShrinkWrap.create( JAXRSArchive.class );

    DEPLOYMENT.as( TopologyArchive.class );

    addPackageResources( DEPLOYMENT );
    addDependencies( DEPLOYMENT );

    SWARM.start();

    SWARM.deploy( DEPLOYMENT );
    }

    /**
     * @param args
     * @throws Exception
     */
    public static void main ( String... args ) throws Exception {

    FSIndexerBootStrap fsBootStrap = new FSIndexerBootStrap();
    fsBootStrap.bootUpApplication();

    }

}

异常是从 JAXRSArchive 的 addAllDependencies() 方法调用引发的。我尝试过调试,但无法找出真正的问题。

4

0 回答 0