You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by wjm wjm <zz...@gmail.com> on 2018/07/28 01:33:10 UTC

help: problem with maven-jar-plugin

1.there is no problem run unit test, and start spring applicationContext,
by "mvn install"
2.add maven-jar-plugin in pom, set outputDirectory, and run "mvn install"
again
spring will load duplicated libraries in different directory, that cause
spring start failed.
(target/lib is my " outputDirectory ")

Loading XML bean definitions from URL
[jar:file:/D:/work/git/local-servicecomb/integration-tests/target/lib/java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
Loading XML bean definitions from URL
[jar:file:/C:/Users/Administrator/.m2/repository/org/apache/servicecomb/java-chassis-core/1.1.0-SNAPSHOT/java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]

can anybody help me to avoid this problem?
thanks.

Re: help: problem with maven-jar-plugin

Posted by wjm wjm <zz...@gmail.com>.
sorry, description is not correct
green lines is the key information, that's for run by "java -jar xxx.jar",
but it cause "mvn install" failed.

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>3.1.0</version>
  <executions>
    <execution>
      <id>assembly</id>
      <phase>package</phase>
    </execution>
  </executions>
  <configuration>
    <outputDirectory>${root.dir}/integration-tests/target/${project.artifactId}</outputDirectory>
    <archive>
      <manifest>
        <classpathLayoutType>simple</classpathLayoutType>
        <addClasspath>true</addClasspath>
        <classpathPrefix>../lib/</classpathPrefix>
        <mainClass>${it.main}</mainClass>
      </manifest>
      <manifestEntries>
        <Class-Path>. ..</Class-Path>
      </manifestEntries>
    </archive>
  </configuration>
</plugin>



2018-07-28 9:33 GMT+08:00 wjm wjm <zz...@gmail.com>:

> 1.there is no problem run unit test, and start spring applicationContext,
> by "mvn install"
> 2.add maven-jar-plugin in pom, set outputDirectory, and run "mvn install"
> again
> spring will load duplicated libraries in different directory, that cause
> spring start failed.
> (target/lib is my " outputDirectory ")
>
> Loading XML bean definitions from URL [jar:file:/D:/work/git/local-
> servicecomb/integration-tests/target/lib/java-chassis-core-
> 1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
> Loading XML bean definitions from URL [jar:file:/C:/Users/
> Administrator/.m2/repository/org/apache/servicecomb/java-
> chassis-core/1.1.0-SNAPSHOT/java-chassis-core-1.1.0-
> SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
>
> can anybody help me to avoid this problem?
> thanks.
>

Re: help: problem with maven-jar-plugin

Posted by wjm wjm <zz...@gmail.com>.
not resolved, but avoid the problem:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <version>3.1.0</version>
  <executions>
    <execution>
      <id>default-jar</id>
      <phase>package</phase>
    </execution>
  </executions>
  <configuration>
    <archive>
      <manifest>
        <classpathLayoutType>repository</classpathLayoutType>
        <addClasspath>true</addClasspath>
        <!--must reference local repository jars, otherwise when run
"mvn install", will have classpath problem-->
        <classpathPrefix>/${settings.localRepository}/</classpathPrefix>
        <mainClass>${it.main}</mainClass>
      </manifest>
      <manifestEntries>
        <Class-Path>. ..</Class-Path>
      </manifestEntries>
    </archive>
  </configuration>
</plugin>



2018-07-30 15:58 GMT+08:00 wjm wjm <zz...@gmail.com>:

> must run "mvn install" in parent level, that will cause problem.
>
> eg:
> integration tests
>   springmvc-tests
>     springmvc-tests-general-with-springboot
>
> run in " integration tests" or " springmvc-tests", have problems.
> but run in " springmvc-tests-general-with-springboot", no problem.
>
> 2018-07-29 2:41 GMT+08:00 wjm wjm <zz...@gmail.com>:
>
>> infact classpath data in MANIFEST.MF is no problem, "java -jar xx.jar" is
>> no problem.
>> just only classpath for "mvn install" have problem, exclude is not
>> a solution for this.
>>
>> 2018-07-28 14:40 GMT+08:00 Willem Jiang <wi...@gmail.com>:
>>
>>> It looks like the plugin add  all the m2 depedencies into the classpath.
>>> Can you exclude them[1] in the maven jar plugin ?
>>>
>>> [1]
>>> https://maven.apache.org/plugins/maven-jar-plugin/examples/i
>>> nclude-exclude.html
>>>
>>>
>>> Willem Jiang
>>>
>>> Twitter: willemjiang
>>> Weibo: 姜宁willem
>>>
>>> On Sat, Jul 28, 2018 at 9:33 AM, wjm wjm <zz...@gmail.com> wrote:
>>>
>>> > 1.there is no problem run unit test, and start spring
>>> applicationContext,
>>> > by "mvn install"
>>> > 2.add maven-jar-plugin in pom, set outputDirectory, and run "mvn
>>> install"
>>> > again
>>> > spring will load duplicated libraries in different directory, that
>>> cause
>>> > spring start failed.
>>> > (target/lib is my " outputDirectory ")
>>> >
>>> > Loading XML bean definitions from URL
>>> > [jar:file:/D:/work/git/local-servicecomb/integration-tests/
>>> > target/lib/java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/
>>> > spring/cse.bean.xml]
>>> > Loading XML bean definitions from URL
>>> > [jar:file:/C:/Users/Administrator/.m2/repository/
>>> > org/apache/servicecomb/java-chassis-core/1.1.0-SNAPSHOT/
>>> > java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
>>> >
>>> > can anybody help me to avoid this problem?
>>> > thanks.
>>> >
>>>
>>
>>
>

Re: help: problem with maven-jar-plugin

Posted by wjm wjm <zz...@gmail.com>.
must run "mvn install" in parent level, that will cause problem.

eg:
integration tests
  springmvc-tests
    springmvc-tests-general-with-springboot

run in " integration tests" or " springmvc-tests", have problems.
but run in " springmvc-tests-general-with-springboot", no problem.

2018-07-29 2:41 GMT+08:00 wjm wjm <zz...@gmail.com>:

> infact classpath data in MANIFEST.MF is no problem, "java -jar xx.jar" is
> no problem.
> just only classpath for "mvn install" have problem, exclude is not
> a solution for this.
>
> 2018-07-28 14:40 GMT+08:00 Willem Jiang <wi...@gmail.com>:
>
>> It looks like the plugin add  all the m2 depedencies into the classpath.
>> Can you exclude them[1] in the maven jar plugin ?
>>
>> [1]
>> https://maven.apache.org/plugins/maven-jar-plugin/examples/
>> include-exclude.html
>>
>>
>> Willem Jiang
>>
>> Twitter: willemjiang
>> Weibo: 姜宁willem
>>
>> On Sat, Jul 28, 2018 at 9:33 AM, wjm wjm <zz...@gmail.com> wrote:
>>
>> > 1.there is no problem run unit test, and start spring
>> applicationContext,
>> > by "mvn install"
>> > 2.add maven-jar-plugin in pom, set outputDirectory, and run "mvn
>> install"
>> > again
>> > spring will load duplicated libraries in different directory, that cause
>> > spring start failed.
>> > (target/lib is my " outputDirectory ")
>> >
>> > Loading XML bean definitions from URL
>> > [jar:file:/D:/work/git/local-servicecomb/integration-tests/
>> > target/lib/java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/
>> > spring/cse.bean.xml]
>> > Loading XML bean definitions from URL
>> > [jar:file:/C:/Users/Administrator/.m2/repository/
>> > org/apache/servicecomb/java-chassis-core/1.1.0-SNAPSHOT/
>> > java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
>> >
>> > can anybody help me to avoid this problem?
>> > thanks.
>> >
>>
>
>

Re: help: problem with maven-jar-plugin

Posted by wjm wjm <zz...@gmail.com>.
infact classpath data in MANIFEST.MF is no problem, "java -jar xx.jar" is
no problem.
just only classpath for "mvn install" have problem, exclude is not
a solution for this.

2018-07-28 14:40 GMT+08:00 Willem Jiang <wi...@gmail.com>:

> It looks like the plugin add  all the m2 depedencies into the classpath.
> Can you exclude them[1] in the maven jar plugin ?
>
> [1]
> https://maven.apache.org/plugins/maven-jar-plugin/
> examples/include-exclude.html
>
>
> Willem Jiang
>
> Twitter: willemjiang
> Weibo: 姜宁willem
>
> On Sat, Jul 28, 2018 at 9:33 AM, wjm wjm <zz...@gmail.com> wrote:
>
> > 1.there is no problem run unit test, and start spring applicationContext,
> > by "mvn install"
> > 2.add maven-jar-plugin in pom, set outputDirectory, and run "mvn install"
> > again
> > spring will load duplicated libraries in different directory, that cause
> > spring start failed.
> > (target/lib is my " outputDirectory ")
> >
> > Loading XML bean definitions from URL
> > [jar:file:/D:/work/git/local-servicecomb/integration-tests/
> > target/lib/java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/
> > spring/cse.bean.xml]
> > Loading XML bean definitions from URL
> > [jar:file:/C:/Users/Administrator/.m2/repository/
> > org/apache/servicecomb/java-chassis-core/1.1.0-SNAPSHOT/
> > java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
> >
> > can anybody help me to avoid this problem?
> > thanks.
> >
>

Re: help: problem with maven-jar-plugin

Posted by Willem Jiang <wi...@gmail.com>.
It looks like the plugin add  all the m2 depedencies into the classpath.
Can you exclude them[1] in the maven jar plugin ?

[1]
https://maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html


Willem Jiang

Twitter: willemjiang
Weibo: 姜宁willem

On Sat, Jul 28, 2018 at 9:33 AM, wjm wjm <zz...@gmail.com> wrote:

> 1.there is no problem run unit test, and start spring applicationContext,
> by "mvn install"
> 2.add maven-jar-plugin in pom, set outputDirectory, and run "mvn install"
> again
> spring will load duplicated libraries in different directory, that cause
> spring start failed.
> (target/lib is my " outputDirectory ")
>
> Loading XML bean definitions from URL
> [jar:file:/D:/work/git/local-servicecomb/integration-tests/
> target/lib/java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/
> spring/cse.bean.xml]
> Loading XML bean definitions from URL
> [jar:file:/C:/Users/Administrator/.m2/repository/
> org/apache/servicecomb/java-chassis-core/1.1.0-SNAPSHOT/
> java-chassis-core-1.1.0-SNAPSHOT.jar!/META-INF/spring/cse.bean.xml]
>
> can anybody help me to avoid this problem?
> thanks.
>