aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes A strange compile error with Maven2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "A strange compile error with Maven2" Watch "A strange compile error with Maven2" New topic
Author

A strange compile error with Maven2

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
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

Joined: Jul 08, 2003
Posts: 24184
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
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

Joined: Jul 08, 2003
Posts: 24184
    
  34

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

Joined: Jul 10, 2007
Posts: 110
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

Joined: Jul 08, 2003
Posts: 24184
    
  34

Now that this is a "how do I configure Maven" question, I'll move it to a more appropriate forum.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A strange compile error with Maven2