tags:

views:

66

answers:

4

I run a simple CXF maven project http://cxf.apache.org/docs/using-cxf-with-maven.html, and get error below

[INFO] [cxf-codegen:wsdl2java {execution: generate-sources}]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR 
[INFO] ------------------------------------------------------------------------
[INFO] org/springframework/core/io/support/ResourcePatternResolver

org.springframework.core.io.support.ResourcePatternResolver
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: org/springframework/core/io/support/ResourcePatternResolver
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)

I don't know how to put the springframework-core dependance ?

I tried below like most of answers

       <dependency>
         <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>2.5.6</version>
   </dependency>
</dependencies>

but it didn't help, I also don't know why it depends on springframework

It works if I put the jar file under $M2_HOME/lib, but is it correct way ? since when I solve this, it requires to add more lib there, can I put it into pom.xml somewhere ?

I tried to put <dependencies/> inside <build> tag, it doesn't work

my maven is 2.2.1 on windows

+1  A: 

You have to define it in the pom.xml

Read the docs at http://maven.apache.org/pom.html#Dependencies

eugener
+1  A: 

You'll need to add this to your Maven pom.xml file in the <dependencies> section:

 <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>???</version>
  </dependency>

The version number will depend on which version of spring you're using. (I'm using 2.0 as the version #, along with spring 2.0.8).

elduff
+2  A: 

It works if I put the jar file under $M2_HOME/lib, but is it correct way ?

No, definitely not. To add a dependency, you need to declare it in your pom.xml, something like this:

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>???</version>
    </dependency>
    ...
  </dependencies>
</project>

But I don't understand why you would have to add this dependency, spring-core is a dependency of cxf, you should get it transitively. You're not providing enough context information for a more precise answer though.

Pascal Thivent
+1  A: 

Finally I found it by myself, it is due to the error of my springframework-2.5.5 package from local repository. The jar file is not correct. I notice this later in eclipse

Pascal's answer is also correct.

The springframework-2.5.5 is automatically download by maven, unfortunately it is broken, so it still complain the class, and if I put springframework-2.5.6 inside, even it will be downloaded, it will not be used, maven still think it loaded the springframework-2.5.5 into its classpath.

And if I put into %M2_HOME%/lib, surely it will be maven's classpath, and it is wrong to use it.

Since I met this kind of problem before, now I know what it is.

Summary: checking your dependance files to see whether the package is correct

BTW: Thanks for all especially pascal

larrycai