Running Groovy scripts

Hi. Problems with included Sax libraries when running from Intellij.

Groovy script that I run on the command line:

> groovy updateMembersLocal.groovy

Groovy 2.2.1. Intellij 13.0.1

I have setup the script in a module in a project that also contains a grails project. Run config has everything removed (make especially):

Screen Shot 2014-01-20 at 12.41.27 PM.png


Module settings are cut back. Purpose - try to get rid of conflicted Sax library.

Screen Shot 2014-01-20 at 12.41.27 PM.png

I get this Sax error:

/System/Library/Frameworks/JavaVM.framework/Home/bin/java -Dtools.jar=/System/Library/Frameworks/JavaVM.framework/Home/lib/tools.jar -Dgroovy.home=/Users/johnrobens/opt/groovy-2.2.1 -Dgroovy.starter.conf=/Users/johnrobens/opt/groovy-2.2.1/conf/groovy-starter.conf -Didea.launcher.port=7538 "-Didea.launcher.bin.path=/Applications/IntelliJ IDEA 13.app/bin" -Dfile.encoding=UTF-8 -classpath "/Users/johnrobens/opt/groovy-2.2.1/lib/groovy-2.2.1.jar:.:/Users/johnrobens/NetBeansProjects/civiLink/out/production/CiviWart:/Users/johnrobens/NetBeansProjects/civiLink/CiviWart:/Applications/IntelliJ IDEA 13.app/lib/idea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.groovy.tools.GroovyStarter --conf /Users/johnrobens/opt/groovy-2.2.1/conf/groovy-starter.conf --main groovy.ui.GroovyMain /Users/johnrobens/NetBeansProjects/civiLink/CiviWart/updateMembersLocal.groovy
Caught: java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/jaxp/SAXParserImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/Parser used in the signature
java.lang.LinkageError: loader constraint violation: when resolving overridden method "org.apache.xerces.jaxp.SAXParserImpl.getParser()Lorg/xml/sax/Parser;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/jaxp/SAXParserImpl, and its superclass loader (instance of <bootloader>), have different Class objects for the type org/xml/sax/Parser used in the signature
 at org.apache.xerces.jaxp.SAXParserFactoryImpl.newSAXParser(Unknown Source)
 at org.apache.ivy.util.XMLHelper.newSAXParser(XMLHelper.java:62)
 at org.apache.ivy.util.XMLHelper.parse(XMLHelper.java:133)
 at org.apache.ivy.util.XMLHelper.parse(XMLHelper.java:109)
 at org.apache.ivy.util.XMLHelper.parse(XMLHelper.java:99)

The script does have @Grab in it - and intellij is not recognising HTTPBuilder.

@Grapes([

@Grab(group = 'org.codehaus.groovy.modules.http-builder', module = 'http-builder', version = '0.6'),

@Grab('mysql:mysql-connector-java:5.1.27'),

@GrabConfig(systemClassLoader = true)

])

import au.com.interlated.civiLink.civiWart.UpdateCiviCRM

import au.com.interlated.civiLink.civiWart.UpdateCiviLink

import groovy.sql.Sql

import java.sql.*

//import au.com.interlated.civiLink.sync.ChangeRecordBatch

import groovyx.net.http.HTTPBuilder

import groovy.json.JsonBuilder

import static groovyx.net.http.ContentType.URLENC

import groovyx.net.http.HttpResponseException

import groovy.json.JsonSlurper

new RunCiviSync(args)

class RunCiviSync {



How do I run this script?

Thanks for your help.

John

0

I am sure this worked in 12, and from my searching other people are hinting at that too. Must be a 'change in the way 13 works'.

0

Hi John,

Try to Alt+Enter with a caret positioned on @Grab to download artifacts.

I cannot reproduce compilation failure with a simple Grails (2.1.1) project. The script works perfectly.
So could you provide a project reproducing the issue?

Thanks,
Max Medvedev

0

Max - here is the project.

runLocal is the run config in it.

Thanks
John



Attachment(s):
CiviWart.zip
0

Works for me in 13.0.2

0

OK - does too for me in the cut-down-project. Still doesn't work in module as part of grails project.

I'll work with the separate project.

Thanks
John

0

I can suggest to use a separate module instead of a separate project.

JFYI you can make red au.* references green by setting a package prefix for au source root (see screenshot)
Screen Shot 2014-01-31 at 11.51.44 .png

0
Avatar
Permanently deleted user

I have a similar problem while trying to switch to Java 1.8 and groovy 2.3.1  (I am not using grails: just simple groovy AND jgroups that uses the library to read xml conf):
java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.apache.xerces.dom.NodeImpl.getChildNodes()Lorg/w3c/dom/NodeList;" the class loader (instance of org/codehaus/groovy/tools/RootLoader) of the current class, org/apache/xerces/dom/NodeImpl, and the class loader (instance of <bootloader>) for interface org/w3c/dom/Node have different Class objects for the type org/w3c/dom/NodeList used in the signature

what can I do?
(I suspect they do not have the same notion of what "NodeList" is)

thanks

PS: does work now (old xml-apis were lurking in the shadow of inherited Maven dependencies!). So no longer an issue

1

请先登录再写评论。