当前位置: 首页 > 知识库问答 >
问题:

带Maven的weblogic 12c JWSC

钱哲茂
2023-03-14

我们正在从Weblogic 10g升级到12c。我们的代码库的一部分是webservices,因此我们使用的是weblogic maven插件:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>weblogic-maven-plugin</artifactId>
    <version>2.9.5</version>
    <configuration>
        <contextPath>ws</contextPath>
        <keepGenerated>true</keepGenerated>
    </configuration>
    <executions>
        <execution>
            <phase>compile</phase>
            <goals>
                <goal>jwsc</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.5</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>weblogic</groupId>
            <artifactId>weblogic</artifactId>
            <version>${weblogic.version}</version>
            <scope>system</scope>
            <systemPath>${bea.lib}/weblogic.jar</systemPath>
        </dependency>
    </dependencies>
</plugin>

我看到的构建错误是

[ERROR] Failed to execute goal org.codehaus.mojo:weblogic-maven-plugin:2.9.5:jwsc (default) on project webService: Execution default of goal org.codehaus.mojo:weblogic-maven-plugin:2.9.5:jwsc failed: Plugin org.codehaus.mojo:weblogic-maven-plugin:2.9.5 or one of its dependencies could not be resolved: Failure to find weblogic:webservices:jar:10.3.6 in http://ccicusbuild1/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]

深入检查表明该插件依赖于weblogic:weblogic:10.3.6和weblogic:webservices:10.3.6。如前一段代码所示,我可以用weblogic:weblogic:12.1.1覆盖weblogic:weblogic:10.3.6。问题是webservices。jar不再是weblogic 12c的一部分,因此我没有任何东西可以覆盖依赖关系,也不能排除它。

weblogic-maven-plugin(http://mojo.codehaus.org/weblogic-maven-plugin/)的页面提到了对12c的支持,但没有给出任何细节。

目标是能够通过maven运行JWSC。我是否可以对插件配置进行调整以使其正常工作,或者是否有其他插件,或者我是否需要咬紧牙关并使用ant插件运行代码?

共有1个答案

虞华翰
2023-03-14

这是我们使用的最终解决方案。如果其他人有更好的东西,请张贴出来。

插件部分的pom.xml

<plugins>
    <!--
        Below contains a work around to build web services for Weblogic 12c.
        weblogic-maven-plugin was how things were done (and was much cleaner)
        but at the time of this work around, it doesn't appear to support Weblogic 12c.

        If in the future, weblogic-maven-plugin or some other plugin become known,
        it should replace both parts of the work around.
     -->
    <!-- START OF WORK AROUND part 1-->
    <plugin>
      <groupId>org.codehaus.gmaven</groupId>
      <artifactId>gmaven-plugin</artifactId>
      <version>1.3</version>
      <executions>
        <execution>
          <id>set-main-artifact</id>
          <phase>package</phase>
          <goals>
            <goal>execute</goal>
          </goals>
          <configuration>
            <source>
              project.artifact.setFile(new File(project.build.directory+'/'+project.artifactId+'-'+project.version+'.war'))
            </source>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>
        <executions>
            <execution>
                <phase>prepare-package</phase>
                <configuration>
                    <target>
                        <property name="maven.compile.classpath" refid="maven.compile.classpath" />
                        <property name="maven.runtime.classpath" refid="maven.runtime.classpath" />
                        <property name="maven.test.classpath" refid="maven.test.classpath" />
                        <property name="maven.plugin.classpath" refid="maven.plugin.classpath" />
                        <ant antfile="src/main/ant/build.xml" target="all" />
                    </target>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>org.apache.ant</groupId>
                <artifactId>ant</artifactId>
                <version>1.7.1</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>ant-contrib</groupId>
                <artifactId>ant-contrib</artifactId>
                <version>1.0b2</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>weblogic</groupId>
                <artifactId>weblogic</artifactId>
                <version>${weblogic.version}</version>
                <scope>system</scope>
                <systemPath>${bea.lib}/weblogic.jar</systemPath>
            </dependency>
            <dependency>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
                <version>1.5.0</version>
                <scope>system</scope>
                <systemPath>${java.home}/../lib/tools.jar</systemPath>
            </dependency>
        </dependencies>
    </plugin>
    <!-- END OF WORK AROUND part 1 -->
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.1.1</version>
            <configuration>
                <encoding>UTF-8</encoding>
            </configuration>
            <!-- START OF WORK AROUND part 2 -->
            <executions>
                  <execution>
                      <id>default-war</id>
                      <phase>none</phase>
                  </execution>
              </executions>
              <!-- END OF WORK AROUND part 2 -->
        </plugin>
</plugins>

建筑xml

<project name="build-webservice" default="all">

    <target name="all" depends="build.webService" />

    <path id="maven_plugin_classpath">
        <pathelement path="${maven.plugin.classpath}" />
    </path>

    <path id="maven_runtime_classpath">
        <pathelement path="${maven.compile.classpath}" />
        <pathelement path="${maven.runtime.classpath}" />
        <pathelement path="${maven.plugin.classpath}" />
        <pathelement path="${weblogic.jar}" />
    </path>

    <taskdef name="jwsc"
             classname="weblogic.wsee.tools.anttasks.JwscTask"
             classpath="${weblogic.jar}"
             classpathref="maven_plugin_classpath"
    />

    <target name="build.webService" description="Compile the web services if not up2date">
        <!--
            Eclipse compiles and places classes into target/classes when the workspace is building.
            If this folder exists when jwsc runs, then any classes that are already compiled will NOT
            be included in the final WAR file.  Thus, this directory is removed prior to created the
            webServices WAR fie.
        -->
        <delete dir="target/classes" />
        <jwsc srcdir="${project.build.sourceDirectory}"
              destDir="target"
              classpathref="maven_runtime_classpath"
              keepGenerated="yes"
              applicationxml="${project.build.directory}/application.xml"
              fork="true"
              memorymaximumsize="256m"
              verbose="true"
              debug="on"
        >
            <module contextPath="ws" name="${project.artifactId}-${project.version}">
                <jwsfileset srcdir=".">
                   <include name="**/*.java" />
                   <exclude name="**/*Test.java" />
                 </jwsfileset>
            </module>
        </jwsc>    
    </target>    
</project>

总体描述:

  1. war插件执行被覆盖,因此它不会运行
  2. 编译和打包由JwscTask在ant中处理
  3. gmaven插件使用通知maven应该使用ant生成的war作为工件

注意事项:

  • gmaven的备选方案是ant任务和构建助手maven插件,如如何将自定义构建的jar文件注册为maven主工件所述?,但两者都不起作用。两者都导致附加的工件必须具有与其对应的主工件不同的ID
 类似资料:
  • 它不工作:(.我有这个错误 [致命]org.springframework:java-backend-bdd:0.1.0:无法将项目org.springframework.boot:spring-boot-starter-parent:POM:2.0.3.从/到central发布(https://repo.maven.apache.org/maven2):sun.security.validato

  • 是否有任何surefire或TeamCity选项来配置运行时JRE? 这是我当前的可靠配置:

  • > DAO层类型:jar Rest服务层类型:war,依赖:DAO{scope:default,type:jar}

  • 用Maven和IntelliJ制作Java EE WebApp的过程是什么? 我就是这么做的: 文件/新建/项目 项目类型:Maven 根据原型创建:maven-archetype-webapp 但是,如果我重新加载Maven(右键单击/Maven/reimport),resources目录会丢失“source root”结构。 我觉得我的程序出了问题。

  • 我想使用Maven、GitLab和Artifactory创建一个CI管道。 我已经设置了所有这些系统,现在Jenkins进行了构建,如果用户推到GitLab并将工件部署到Artifactory。 但我想要的是: 开发人员开发了一个Java的应用程序,并可以将代码推送到GitLab。当他完成时,他使用maven发布插件并执行发布:准备和发布:执行目标。Maven发布插件会自动创建一个新的标签并编辑版

  • 我是个新手..在我看来,它应该能帮助我维持我的依赖关系的秩序。我正在尝试使用m2clipse插件使其工作,并使其与Android一起工作。(我使用了以下站点:http://looksok.wordpress.com/2012/05/12/use-maven-with-android-project/) 我已将现有项目更新为maven项目。并为actionbarsherlock项目添加了依赖项。我的