Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A strange compile error with Maven2

 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When trying to "clean install" with maven2 I receive an error like this.

RoutingDataSource is not abstract and does not override method isWrapperFor(java.Lang.Class<?> in java.sql.Wrapper

But when I do a clean under Eclipse - Project the classes are compiled without any error, including this RoutingDataSource I have. Then I do a simple "install" with maven and it compiles fine. Because I never change the RoutingDataSource this is never altered and never need recompiling I could compile this once in eclipse and then just do a mvn install to get the war file. But I would like to be able to go mvn clean install.

RoutingDataSource is an implementation of Spring AbstractRoutingDataSource
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.sql.Wrapper is a new interface in Java 6. Many JDBC interfaces extend it, so these interfaces have a few new abstract methods. That means that any Java 5 code which implements (for example) javax.sql.DataSource will not compile with JDK 1.6, because those methods will go unimplemented! Isn't that special! I've had this sort of problem in the past, and it's always annoying when Sun makes a change like this.

Just to be perfectly clear: it looks like you're compiling with JDK 1.6 under Maven, and JDK 1.5 within Eclipse. If there's a Spring version for JDK 1.6 yet, then you need to get it. If not, then your choices are (1) Don't use JDK 1.6, or (2) implement the methods of java.sql.Wrapper in your concrete subclass as a workaround.
 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have spesifically defined both in eclipse that Java 1.5 should be used.

In Eclipse I have set Java 1.5.0_12 to be the default Java versjon and my maven configuration file has explicit 1.5 compiling

<plugin>
<groupId></groupId>
<artifactId></artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>

My JAVA_HOME is set to the path to Java 1.5.0_12, but yet is seems when starting Java -version in command line gives the 1.6 version. Perhaps thats where the problem is
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you compile with javac from JDK 1.6, then it's going to use the 1.6 libraries, which will have this problem, even if you specify -source 1.5. The -source and -target switches don't actually check that your library usage conforms to the targeted JVM version.
 
Sverre Moe
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I get Maven to use Java 1.5 instead of 1.6 without having to uninstall the 1.6 version?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that this is a "how do I configure Maven" question, I'll move it to a more appropriate forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic