ejb客户端的POM配置引发异常

时间:2016-10-23 10:32:59

标签: java maven ejb wildfly pom.xml

我有一个Wildfly服务器正在运行,我有一个ejb项目和java中的客户端。当我尝试运行客户端时,我得到以下异常:

    [ERROR] Failed to execute goal on project online-shop-ejb-client: Could not resolve dependencies for project com.wildfly.proj:online-shop-ejb-client:jar:0.0.1-SNAPSHOT: Could not find artifact com.wildfly.proj:online-shop-ejb:jar:client:0.0.1-SNAPSHOT -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project online-shop-ejb-client: Could not resolve dependencies for project com.wildfly.proj:online-shop-ejb-client:jar:0.0.1-SNAPSHOT: Could not find artifact com.wildfly.proj:online-shop-ejb:jar:client:0.0.1-SNAPSHOT
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:221)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.resolveProjectDependencies(LifecycleDependencyResolver.java:127)
    at org.apache.maven.lifecycle.internal.MojoExecutor.ensureDependenciesAreResolved(MojoExecutor.java:257)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:200)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    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.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project com.wildfly.proj:online-shop-ejb-client:jar:0.0.1-SNAPSHOT: Could not find artifact com.wildfly.proj:online-shop-ejb:jar:client:0.0.1-SNAPSHOT
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:211)
    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies(LifecycleDependencyResolver.java:195)
    ... 23 more
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact com.wildfly.proj:online-shop-ejb:jar:client:0.0.1-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
    at org.apache.maven.project.DefaultProjectDependenciesResolver.resolve(DefaultProjectDependenciesResolver.java:205)
    ... 24 more
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not find artifact com.wildfly.proj:online-shop-ejb:jar:client:0.0.1-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:444)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:246)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:367)
    ... 25 more
Caused by: org.eclipse.aether.transfer.ArtifactNotFoundException: Could not find artifact com.wildfly.proj:online-shop-ejb:jar:client:0.0.1-SNAPSHOT
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve(DefaultArtifactResolver.java:434)
    ... 27 more

这是我的ejb项目的主题:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.wildfly.proj</groupId>
        <artifactId>online-shop</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>online-shop-ejb</artifactId>
    <packaging>ejb</packaging>
    <name>online-shop-ejb</name>

    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>7.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
            <version>3.1.4.GA</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <!-- WildFly plugin to deploy the application -->
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>1.0.2.Final</version>
                <configuration>
                    <filename>${project.build.finalName}.jar</filename>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <!-- enforce Java 8 -->
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.2</ejbVersion>
                    <!-- Generate ejb-client for client project -->
                    <generateClient>true</generateClient>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

这是客户项目的主题:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.wildfly.proj</groupId>
        <artifactId>online-shop</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>online-shop-ejb-client</artifactId>
    <name>online-shop-ejb-client</name>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.wildfly</groupId>
                <artifactId>wildfly-ejb-client-bom</artifactId>
                <version>10.1.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>com.wildfly.proj</groupId>
            <artifactId>online-shop-ejb</artifactId>
            <type>ejb-client</type>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.transaction</groupId>
            <artifactId>jboss-transaction-api_1.2_spec</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.spec.javax.ejb</groupId>
            <artifactId>jboss-ejb-api_3.2_spec</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss</groupId>
            <artifactId>jboss-ejb-client</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-api</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.xnio</groupId>
            <artifactId>xnio-nio</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.remoting3</groupId>
            <artifactId>jboss-remoting</artifactId>
            <version>3.3.3.Final</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.sasl</groupId>
            <artifactId>jboss-sasl</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.marshalling</groupId>
            <artifactId>jboss-marshalling-river</artifactId>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <!-- maven-compiler-plugin here -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>java</executable>
                    <workingDirectory>${project.build.directory}/exec-working-directory</workingDirectory>
                    <arguments>
                        <argument>-classpath</argument>
                        <classpath />
                        <argument>com.wildfly.proj.client.TicketAgencyClient</argument>
                    </arguments>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

1 个答案:

答案 0 :(得分:1)

您可以在此处从ejb模块生成ejb-client:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-ejb-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <ejbVersion>3.2</ejbVersion>
                    <!-- Generate ejb-client for client project -->
                    <generateClient>true</generateClient>
                </configuration>
            </plugin>

因此,通过演绎,我认为您尚未在Maven本地存储库中安装包含ejb和ejb-client的工件com.wildfly.proj:online-shop-ejb:0.0.1-SNAPSHOT

为此,您必须从mvn clean intall模块运行com.wildfly.proj:online-shop-ejb:0.0.1-SNAPSHOT