【问题标题】:JWSC for weblogic 12c with Maven带有 Maven 的用于 weblogic 12c 的 JWSC
【发布时间】:2013-05-01 17:41:54
【问题描述】:

我们正在从 Weblogic 10g 升级到 12c。我们的代码库的一部分是网络服务,所以我们使用weblogic-maven-plugin

<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.6weblogic: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 插件运行代码?

【问题讨论】:

  • 如果排除 webservices jar 会发生什么?
  • 我不知道排除它的方法。您可以排除依赖项的依赖项(传递依赖项),但不能排除插件的依赖项。
  • 您是否尝试过这里提到的 wls-maven-plugin docs.oracle.com/cd/E24329_01/web.1211/e24368/maven.htm
  • 我看到了wls-maven-plugin,但我在文档中没有看到任何关于 JWSC 的内容。它似乎更适合部署和服务器维护。也许,我只是错过了,我会再检查一次。

标签: web-services maven weblogic weblogic12c


【解决方案1】:

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

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>

build.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作为工件

注意事项:

【讨论】:

    猜你喜欢
    • 2012-04-18
    • 2020-05-11
    • 2012-11-18
    • 2016-11-15
    • 2014-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多