Compiling JUnit class at runtime in glassfish 3 - java

I have in my application JUnit tests to run, but these JUnit tests are created and compiled at runtime. I'm loading a text template, replace some class tags and want to compile this source code at runtime with the javax.tools.Compiler from java.
I'm deploying and running this application on a glassfish 3 and it seems to be the problem, that the compiler can't find the JUnit library (but it is included in the .war) and throwing compile exceptions. The created JUnit test source code would compile, there are no syntax errors or something like that.
The application is build via maven, here is the pom.xml:
<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>de.phoenix</groupId>
<artifactId>WebService</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>WebService Jersey Webapp</name>
<build>
<finalName>PhoenixWebService</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.glassfish</groupId>
<artifactId>maven-glassfish-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.jersey-test-framework</groupId>
<artifactId>jersey-test-framework-grizzly2</artifactId>
<version>${jersey-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.embedded</groupId>
<artifactId>gf-embedded-api</artifactId>
<version>1.0-alpha-4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.phoenix</groupId>
<artifactId>library</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time-hibernate</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>${hibernate-version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.24</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<jersey-version>1.17.1</jersey-version>
<hibernate-version>3.6.10.Final</hibernate-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<repositories>
<repository>
<id>glassfish.java.net</id>
<name>GlassFish Maven Repository</name>
<url>http://download.java.net/maven/glassfish</url>
<layout>default</layout>
</repository>
<repository>
<id>m2.java.net</id>
<name>Java.net Maven 2 Repository</name>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>
<repository>
<id>phoenixNexus</id>
<name>Phoenix Maven 2 Repository</name>
<url>http://meldanor.dyndns.org:8081/nexus/content/groups/public/</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>m2.java.net</id>
<name>Java.net Maven 2 Repository</name>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>phoenixNexus</id>
<name>Internal Releases</name>
<url>http://meldanor.dyndns.org:8081/nexus/content/repositories/releases</url>
</repository>
<snapshotRepository>
<id>phoenixNexus</id>
<name>Internal Releases</name>
<url>http://meldanor.dyndns.org:8081/nexus/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>
I'm using a little modified version of the CharSequenceCompiler (http://www.ibm.com/developerworks/library/j-jcomp/) to compile the classes at runtime.
The compiler is working for source code using only jdk classes.
Any ideas?

Related

Maven WebObjects, Wonder, maven build does not include framework resources (images etc)

I have worked with WebObjects for quite some time. I decided to move to a maven build and for some reason my associated frameworks resources are not being found in /Contents/Frameworks in the built product. So when I run the D2W application I am getting no Image files, stylesheets or any web files that are part of the frameworks.
The application appears to compile fine. but when run the application, resources from the frameworks are not being found. I found the referenced frameworks under Contents/Frameworks. I did attempt to use WOFrameworkBaseURL to point to /WebObjects/myappname/Frameworks and that did not solve the issue.
Here is my POM.XML
<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.mozaic</groupId>
<artifactId>mozaicv2</artifactId>
<packaging>woapplication</packaging>
<version>1.0-SNAPSHOT</version>
<name>mozaicv2 WebObjects Application</name>
<url>http://maven.apache.org</url>
<properties>
<!-- properties used for filtering and dependency management -->
<jvmtarget>1.6</jvmtarget>
<mainclass>com.nttdata.mozaicv2.application.Application</mainclass>
<webobjects.groupId>com.webobjects</webobjects.groupId>
<webobjects.version>5.4.3</webobjects.version>
<wonder.core.groupId>wonder.core</wonder.core.groupId>
<wonder.version>7.1</wonder.version>
<wonder.classifier>wo54</wonder.classifier>
</properties>
<repositories>
<!--
<repository>
<id>wocommunity</id>
<name>WOCommunity Maven 2 Releases Repository</name>
<url>http://maven.wocommunity.org/content/groups/public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
-->
<repository>
<id>wonder</id>
<name>WOCommunity Maven 2 Releases Repository</name>
<url>https://mvnrepository.com/artifact</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>wocommunity</id>
<name>WOCommunity Maven 2 Releases Repository</name>
<url>http://maven.wocommunity.org/content/groups/public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<build>
<finalName>${project.artifactId}</finalName>
<!--
<resources>
<resource>
<targetPath>Resources</targetPath>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<targetPath>Resources</targetPath>
<directory>${basedir}/src/main/components</directory>
</resource>
<resource>
<targetPath>WebServerResources</targetPath>
<directory>${basedir}/src/main/webserver-resources</directory>
</resource>
</resources>
-->
<plugins>
<plugin>
<groupId>org.objectstyle.woproject.maven2</groupId>
<artifactId>maven-wolifecycle-plugin</artifactId>
<version>2.0.17</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>${jvmtarget}</source>
<target>${jvmtarget}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>wonder.ajax</groupId>
<artifactId>Ajax</artifactId>
<version>7.1</version>
</dependency>
<dependency>
<groupId>wonder.eof</groupId>
<artifactId>ERAttributeExtension</artifactId>
<version>7.1</version>
</dependency>
<dependency>
<groupId>wonder.ajax</groupId>
<artifactId>ERCoolComponents</artifactId>
<version>7.1</version>
</dependency>
<dependency>
<groupId>wonder.core</groupId>
<artifactId>ERDirectToWeb</artifactId>
<version>7.1</version>
</dependency>
<dependency>
<groupId>${wonder.core.groupId}</groupId>
<artifactId>ERExtensions</artifactId>
<version>${wonder.version}</version>
</dependency>
<dependency>
<groupId>wonder.d2w</groupId>
<artifactId>ERModernDefaultSkin</artifactId>
<version>${wonder.version}</version>
</dependency>
<dependency>
<groupId>wonder.d2w</groupId>
<artifactId>ERModernDirectToWeb</artifactId>
<version>${wonder.version}</version>
</dependency>
<dependency>
<groupId>wonder.d2w</groupId>
<artifactId>ERModernLook</artifactId>
<version>7.1</version>
</dependency>
<dependency>
<groupId>${wonder.core.groupId}</groupId>
<artifactId>ERPrototypes</artifactId>
<version>${wonder.version}</version>
</dependency>
<!--webobjects-->
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaDirectToWeb</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaDTWGeneration</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaEOAccess</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaEOControl</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaEOProject</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaFoundation</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaJDBCAdaptor</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaWebObjects</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaWOExtensions</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaXML</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>wonder.misc</groupId>
<artifactId>WOLips</artifactId>
<version>${wonder.version}</version>
</dependency>
<dependency>
<groupId>${webobjects.groupId}</groupId>
<artifactId>JavaWOJSPServlet</artifactId>
<version>${webobjects.version}</version>
</dependency>
<dependency>
<groupId>${wonder.core.groupId}</groupId>
<artifactId>WOOgnl</artifactId>
<version>${wonder.version}</version>
</dependency>
<dependency>
<groupId>${wonder.core.groupId}</groupId>
<artifactId>ERServlet</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>```
Please help.
Thanks in advance.
This is where I would start:
<plugin>
<groupId>org.objectstyle.woproject.maven2</groupId>
<artifactId>maven-wolifecycle-plugin</artifactId>
<version>2.0.17</version>
<extensions>true</extensions>
</plugin>
That is quite an old version of the WOLifecycle Maven Plugin. Replace it with this:
<plugin>
<groupId>org.wocommunity</groupId>
<artifactId>wolifecycle-maven-plugin</artifactId>
<version>2.3</version>
<extensions>true</extensions>
</plugin>
If your issue persists, we can investigate further. As an aside, while I am happy to answer questions here on StackOverflow, there's probably a marginally larger community over on the WebObjects Development mailing list.

Why tests sometimes build failed (maven-surefire-plugin)?

In Netbeans i wrote my projects using selenium. Sometimes projects build ok, sometimes build falied. I think, the problem is in maven-sunfire-plugins. But why from 48 builds only 3-4 is failed?
In jenkins console I see:
org.apache.maven.surefire.util.SurefireReflectionException:
java.lang.reflect.InvocationTargetException; nested exception is
java.lang.reflect.InvocationTargetException: null
POM file
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.com.mycompany.test</groupId>
<artifactId>selenium-test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>selenium-test</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>central</id>
<url>http://maven-repo.myportal.pl:3080/artifactory/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://maven-repo.myportal.pl:3080/artifactory/repo</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
<url>http://maven-repo.myportal.pl:3080/archiva/repository/internal</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<finalName>selenium-test</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<compilerVersion>1.6</compilerVersion>
<source>1.6</source>
<target>1.6</target>
<!--<encoding>Cp1250</encoding> -->
<encoding>UTF-8</encoding>
<!--<encoding>ISO-8859-2</encoding> -->
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<!-- Selenium -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.43.1</version>
</dependency>
<dependency>
<groupId>pl.com.mycompany.selenium.util</groupId>
<artifactId>selenium-listener</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.6.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>pl.com.mycompany.portal</groupId>
<artifactId>commons-portal</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>weblogic</groupId>
<artifactId>weblogic</artifactId>
<version>8.0</version>
</dependency>
<!-- TESTS -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easytesting</groupId>
<artifactId>fest-assert</artifactId>
<version>1.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- -->
<profiles>
<profile>
<id>2db</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.11</version>
<configuration>
<properties>
<property>
<name>listener</name>
<value>pl.com.mycompany.selenium.util.TestNgRunSuiteListener</value>
</property>
</properties>
<systemProperties>
<property>
<name>job_name</name>
<value>${project.artifactId}</value>
</property>
</systemProperties>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Oddest is it a lot of builds its okey. From 48 builds only 3 throw this and I don't understand why.
Where is error?

Missing Artifact error in MAVEN in geoserver

<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>org.geoserver</groupId>
<artifactId>hello_wps</artifactId>
<packaging>jar</packaging>
<version>8-ENTERPRISE-SNAPSHOT</version>
<name>hello_wps</name>
<dependencies>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-process</artifactId>
<version>8-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>main</artifactId>
<version>8-ENTERPRISE-SNAPSHOT</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mockrunner</groupId>
<artifactId>mockrunner</artifactId>
<version>0.3.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>opengeo</id>
<name>opengeo</name>
<url>http://repo.opengeo.org</url>
</repository>
</repositories>
</project>
i'm new to maven and geoserver as well. was just trying basic installation of geoserver and found the error in POM.XML file of maven project. Error is shown in two <dependency> tabs which are exactly 1st and 2nd after <dependencies> tab.
Errors :
Missing artifact org.geotools:gt-process:jar:8-SNAPSHOT
Missing artifact org.geoserver:main:jar:tests:8-ENTERPRISE-SNAPSHOT
Thanks for the solution in advance.
If you look at the quick start docs for geotools:
http://docs.geotools.org/latest/userguide/tutorial/quickstart/maven.html
step 7 "under Creating a new project"
If you are using a nightly build (such as 14-SNAPSHOT) and add a
reference to the snapshot repository.
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>boundless</id>
<name>Boundless Maven Repository</name>
<url>http://repo.boundlessgeo.com/main</url>
</repository>
</repositories>
I have taken a quick look at the versions available in this repository and to use it, you will need to change your maven co-ordinates to something like:
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-process</artifactId>
<version>10-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.geoserver</groupId>
<artifactId>main</artifactId>
<version>2.4.8</version>
<classifier>tests</classifier>
<scope>test</scope>
</dependency>
as the original versions you are after are not present.

Webservices - Configuring JSON for RESTful webservices in Java

Iam new to webservices and Iam trying to create a restful webservice invoking JSON data. After searching I thought I could use maven to create a webservice and used this link to create a webservice. I installed maven and tried to repeat the same steps given in the link. But when I run the application I get the below error.
"Failed to execute goal on project printer-status-webapp: Could not resolve dependencies forproject com.example:printer-status-webapp:jar:1.0-SNAPSHOT: Could not find artifact com.sun.jersey:jersey-grizzly:jar:1.0 in glassfish.java.net (http://download.java.net/maven/glassfish) "
I have tomcat running in my machine. I have not installed glassfish. Is it not possible to run the application with tomcat itself.
Anybody pls help me resolve this error.
Else any simple example for creating restful webservices with json data will also be helpful
Pls find the pom.xml file
<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.example</groupId>
<artifactId>printer-status-webapp</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>printer-status-webapp</name>
<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly</artifactId>
<version>${jersey-version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey-version}</version>
</dependency>
<!-- uncomment this to get Fastinfoset support:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-fastinfoset</artifactId>
<version>${jersey-version}</version>
</dependency>
-->
<!-- uncomment this to get ATOM support:
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-atom</artifactId>
<version>${jersey-version}</version>
</dependency>
-->
<!-- uncomment this to get multipart MIME types support:
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>${jersey-version}</version>
</dependency>
-->
<dependency>
<groupId>com.sun.grizzly</groupId>
<artifactId>grizzly-servlet-webserver</artifactId>
<version>1.9.31</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey-version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<inherited>true</inherited>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://172.16.109.209:8080/manager</url>
<server>mytomcat</server>
<path>/mywebapp</path>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<jersey-version>1.0</jersey-version>
</properties>
<!-- <repositories>
<repository>
<id>glassfish.java.net</id>
<name>GlassFish Maven Repository</name>
<url>http://download.java.net/maven/glassfish</url>
<layout>default</layout>
</repository>
<repository>
<id>m2.java.net</id>
<name>Java.net Maven 2 Repository</name>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>
</repositories> -->
Thanks
The error is basically telling you that maven is looking for the dependency "com.sun.jersey:jersey-grizzly:jar:1.0" in the repository "http://download.java.net/maven/glassfish" that is your pom.xml and it can not find it.
Do you try it with the Maven Central Repository??
Adding Maven central repository:
<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>

java.lang.IncompatibleClassChangeError using Scriptom 1.6 on Groovy 1.7.10

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 of groovy. Looking at scriptom pom, it depends on 1.6.0 version of groovy.

Categories