I try to use scriptom 1.6 on Windows 7 to connect to excel application. However I keep getting the error:
Caught: java.lang.IncompatibleClassChangeError: Class org.codehaus.groovy.scriptom.ActiveXObject does not implement the requested interface groovy.lang.GroovyObject
at GoBeby.main(GoBeby.groovy:14)
Here is my code:
import org.codehaus.groovy.scriptom.ActiveXObject;
class GoExcel {
public static void main(String[] args) {
ActiveXObject excel = new ActiveXObject("Excel.Application")
excel.Visible = true;
}
}
and maven file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.examples</groupId>
<name>${project.artifactId}</name>
<artifactId>go_excel</artifactId>
<packaging>jar</packaging>
<version>0.1</version>
<properties>
<gmaven.version>1.2</gmaven.version>
<groovy.version>1.7.10</groovy.version>
<slf4j.version>1.5.10</slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.13</version>
</dependency>
<!-- scriptom -->
<dependency>
<groupId>org.codehaus.groovy.modules.scriptom</groupId>
<artifactId>scriptom</artifactId>
<version>1.6.0</version>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<type>dll</type>
<classifier>x64</classifier>
</dependency>
<dependency>
<groupId>net.sf.jacob-project</groupId>
<artifactId>jacob</artifactId>
<version>1.14.3</version>
<type>dll</type>
<classifier>x86</classifier>
</dependency>
<!-- / scriptom -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
<projectnatures>
<projectnature>org.eclipse.jdt.groovy.core.groovyNature
</projectnature>
<projectnature>org.eclipse.jdt.core.javanature</projectnature>
</projectnatures>
</configuration>
</plugin>
</plugins>
</build>
</project>
I just run out of ideas. I have check to use jacob 64bit and 32 bit dll, change groovy framework to 1.5. Has anybody any idea how to make it work?
One possibility is that you are using 1.6.0 version of
scriptom
and 1.7.0 version ofgroovy
. Looking at scriptom pom, it depends on1.6.0
version of groovy.