使用 Maven 将 OSB 项目部署到服务器

OSB project deployment to server with Maven

这是我第一次使用 Maven。我正在尝试使用 Maven 将 OSB 项目打包并部署到 weblogic 服务器。但我面临着问题。 以下是完成的步骤:

  1. 已更新 settings.xml 代理设置和服务器设置。

  2. 我已经使用以下命令设置了 OSB (12.2.1.3) maven 插件:

mvn install:install-file -DpomFile=oracle-maven-sync-12.2.1.pom -Dfile=oracle-maven-sync-12.2.1.jar

mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=ORACLE_HOME

  1. 我在 jdeveloper 中使用 OSB 项目(要打印的项目 "Hello World")创建了一个简单的 OSB 应用程序。

  2. 我用属性标记修改了项目 pom.xml 以便部署到服务器。请在下面找到项目 pom.xml:

    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    http://maven.apache.org/maven-v4_0_0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <modelVersion>4.0.0</modelVersion>
        <parent>
            <groupId>com.oracle.servicebus</groupId>
            <artifactId>sbar-project-common</artifactId>
            <version>12.2.1-3-0</version>
        </parent>
        <groupId>MavenTest</groupId>
        <artifactId>MavenTest1</artifactId>
        <version>1.0-SNAPSHOT</version>
        <packaging>sbar</packaging>
        <build>
            <plugins>
                <plugin>
                    <groupId>com.oracle.adf.plugin</groupId>
                    <artifactId>ojdeploy</artifactId>
                    <version>12.2.1-3-0</version>
                    <configuration>
                        <ojdeploy>${oracleHome}/jdeveloper/jdev/bin/ojdeploy.exe</ojdeploy>
                        <workspace>${basedir}/../MavenTest.jws</workspace>
                        <project>MavenTest1</project>
                        <profile>MavenTest1</profile>
                        <outputfile>${project.build.directory}/${project.build.finalName}.${project.packaging}</outputfile>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <properties>
            <oracleUsername>weblogicUN</oracleUsername>
            <oraclePassword>weblogicPW</oraclePassword>
            <oracleHome>Oracle_HomePath</oracleHome>
            <oracleServerUrl>http://localhost:7001</oracleServerUrl>
        </properties>
    </project>
    
  3. 然后我 运行 在项目 pom 文件所在的项目目录中从命令行执行以下命令:

mvn -e -X package

但我收到以下错误:

MAIN ERROR: [ERROR] Failed to execute goal com.oracle.servicebus.plugin:oracle-servicebus-plugin:12.2.1-3-0:package (default-package) on project MavenTest1: Creation of the Service Bus Configuration Archive failed. See the log in the build directory for more information. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.oracle.servicebus.plugin:oracle-servicebus-plugin:12.2.1-3-0:package (default-package) on project MavenTest1: Creation of the Service Bus Configuration Archive failed. See the log in the build directory for more information.

全栈:

[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 31.835 s [INFO] Finished at: 2019-03-12T10:05:17+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal com.oracle.servicebus.plugin:oracle-servicebus-plugin:12.2.1-3-0:package (default-package) on project MavenTest1: Creation of the Service Bus Configuration Archive failed. See the log in the build directory for more information. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.oracle.servicebus.plugin:oracle-servicebus-plugin:12.2.1-3-0:package (default-package) on project MavenTest1: Creation of the Service Bus Configuration Archive failed. See the log in the build directory for more information. at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:213) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) 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.plugin.MojoFailureException: Creation of the Service Bus Configuration Archive failed. See the log in the build directory for more information. at oracle.sb.maven.plugin.PackageMojo.execute (PackageMojo.java:102) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:208) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:154) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:146) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81) at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305) at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192) at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105) at org.apache.maven.cli.MavenCli.execute (MavenCli.java:954) at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:288) at org.apache.maven.cli.MavenCli.main (MavenCli.java:192) 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) [ERROR] [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

  1. 也在 MavenTest1 中。data\maven\configjar 它记录为 C:\Users\userId\AppData\Local\Microsoft\WindowsApps 此时是意外的。

  2. 我已经在 USER 变量 M2_HOME=C:\Oracle\Middleware\Oracle_Home\oracle_common\modules\org.apache.maven_3.2.5 中设置了, ORACLE_HOME=C:\Oracle\Middleware\Oracle_Home, M2=%M2_HOME%\bin , PATH=%path%;%M2%

系统变量 JAVA_HOME=C:\Program Files\Java\jdk1.8.0_202\ , ORACLE_HOME=C:\Oracle\Middleware\Oracle_Home , Path=%JAVA_HOME%\bin , %ORACLE_HOME%\oracle_common\bin

我哪里错了?

通过对 OSB 提供的带有本地存储库的 Maven 插件执行以下步骤,问题已得到解决: • 在用户变量中:

M2_HOME=C:\Oracle\Middleware\Oracle_Home\oracle_common\modules\org.apache.maven_3.2.5 M2=%M2_HOME%\bin PATH=%path%;%M2%

• 在系统变量中:

JAVA_HOME=C:\PROGRA~1\Java\jdk1.8.0_202\ ORACLE_HOME=C:\Oracle\Middleware\Oracle_Home Path=%JAVA_HOME%\bin

• 在 settings.xml 中 C:\Users\.m2\,

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <localRepository>C:\Users\(USERId)\.m2\repository</localRepository>
  <interactiveMode>true</interactiveMode>
  <usePluginRegistry>false</usePluginRegistry>
  <offline />
  <proxies>
    <proxy>
      <host>HostIP</host>
      <nonProxyHosts></nonProxyHosts>
    </proxy>
  </proxies>
</settings>

• 转到 C:\Oracle\Middleware\Oracle_Home\oracle_common\plugins\maven\com\oracle\maven\oracle-maven-sync.2.1 和 运行 以下命令:

  1. mvn install:install-file -DpomFile=oracle-maven-sync-12.2.1.pom -Dfile=oracle-maven-sync-12.2.1.jar [安装Maven同步插件]
  2. mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=C:\Oracle\Middleware\Oracle_Home [将 Oracle Service Bus 开发 Maven 插件植入 Maven 存储库]
  3. mvn help:describe -DgroupId=com.oracle.servicebus.plugin -DartifactId=oracle-servicebus-plugin -Dversion=12.2.1-3-0 [检查是否安装成功]

通过执行第三条命令。它应该给出以下输出:

Name: Oracle Service Bus - Plugin Description: The Oracle Service Bus development Maven plug-in provides Maven goals specific to the requirements of Service Bus projects and applications. You can use it to perform tasks such as packaging Service Bus projects or resources and deploying the package to a running server. Group Id: com.oracle.servicebus.plugin Artifact Id: oracle-servicebus-plugin Version: 12.2.1-3-0 Goal Prefix: servicebus

This plugin has 2 goals: servicebus:deploy Description: The deploy goal deploys Service Bus projects to a running server. This goal supports the Service Bus deployment format, SBAR. It does not require a local server installation. By default, deploying projects does not apply any updates to environment values. If you want to update the environment values, you can create a configuration file with the new environment values and specify that configuration file when you run deploy.

servicebus:package Description: The package goal creates a configuration JAR file from the resources associated with a POM file, and packages the resources into a Service Bus-specific archive file known as an .sbar file. By default, the Maven plug-in assumes the resources being packaged are project resources, but a Service Bus application can also include system resources, which are shared among projects. System resources are packaged differently than project resources, so when you package system resources, you need to set the system flag to true.

安装成功

要使用 OSB 项目进行测试,请创建一个简单的 OSB 项目,如 hello world。从命令提示符转到应用程序目录和 运行 下面的命令来构建项目并将其部署到 osb 服务器:

mvn install -DoracleServerUrl=http://localhost:7001 -DoracleUsername=用户名 -DoraclePassword=密码 -DoracleHome=C:/Oracle/Middleware/Oracle_Home

项目将以 .sbar 格式构建。 .sbar 可以在 (D:(application)\(project)\.data\maven\ sbconfig.sbar) 中找到。 .sbar 将部署到 OSB 服务器。

在D:(application)\(project)\.data\maven\configjar下会有configjar文本文件,其中包含构建过程中的日志。如果有任何错误,需要检查这个文件。

要清除之前的构建阶段,执行 mvn clean,这将删除作为构建目录的 .data\maven 目录。

快照和.sbar artificats也将存储在本地存储库中(C:\Users\(userId)\.m2\repository)。