Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
531 views
in Technique[技术] by (71.8m points)

sockets - Weird java.net.SocketException Permission Denied connect error when running Groovy in Intellij IDEA

When running a VERY simple URL grab script from within IntelliJ IDEA, I get:

java.net.SocketException: Permission denied: connect

but when I run it from the Groovy Console, it works just fine.

Here is the full script:

def data = new URL("http://wisc.edu").getText()

and here is the full console output from IntelliJ:

"C:Program FilesJavajdk1.7.0_01injava" "-Dtools.jar=C:Program FilesJavajdk1.7.0_01libools.jar" "-Dgroovy.home=C:Program Files (x86)GroovyGroovy-1.8.2" "-Dgroovy.starter.conf=C:Program Files (x86)GroovyGroovy-1.8.2confgroovy-starter.conf" -Didea.launcher.port=7534 "-Didea.launcher.bin.path=C:Program Files (x86)JetBrainsIntelliJ IDEA 110.492in" -Dfile.encoding=UTF-8 -classpath "C:Program Files (x86)GroovyGroovy-1.8.2libgroovy-1.8.2.jar;C:Program Files (x86)JetBrainsIntelliJ IDEA 110.492libidea_rt.jar" com.intellij.rt.execution.application.AppMain org.codehaus.groovy.tools.GroovyStarter --conf "C:Program Files (x86)GroovyGroovy-1.8.2confgroovy-starter.conf" --main groovy.ui.GroovyMain --classpath "C:Users[REDACTED]IdeaProjectsestoutproductionest;C:Program Files (x86)GroovyGroovy-1.8.2libant-1.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libant-antlr-1.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libant-junit-1.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libant-launcher-1.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libantlr-2.7.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libasm-3.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libasm-analysis-3.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libasm-commons-3.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libasm-tree-3.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libasm-util-3.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2liballoontip-20090102.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-anim-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-awt-util-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-bridge-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-codec-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-css-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-dom-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-ext-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-extension-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-gui-util-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-gvt-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-parser-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-script-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-svg-dom-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-svggen-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-swing-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-transcoder-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-util-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libatik-xml-1.7.jar;C:Program Files (x86)GroovyGroovy-1.8.2libsf-2.4.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libcommons-cli-1.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libcommons-logging-1.1.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libcssbuilder-0.5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libcssparser-0.9.5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libeasyb-0.9.8.jar;C:Program Files (x86)GroovyGroovy-1.8.2libextra166y-1.7.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libflamingo-4.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libflamingobuilder-0.4.jar;C:Program Files (x86)GroovyGroovy-1.8.2libforms-1.2.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgant-1.9.6_groovy-1.8.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgfxbuilder-core-0.5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgfxbuilder-svg-0.5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgfxbuilder-swingx-0.5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgmock-0.8.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgpars-0.12.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgroovy-1.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgroovypp-0.9.0_1.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libgroovyserv-0.9.jar;C:Program Files (x86)GroovyGroovy-1.8.2libivy-2.2.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjacob-1.14.3.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjansi-1.6.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjcsp-1.1-rc5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjide-oss-2.9.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjidebuilder-4.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjline-0.9.94.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjna-3.2.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjsilhouette-geom-0.4.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjsp-api-2.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjsr166y-1.7.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libjunit-4.8.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libl2fprod-common-all-6.9.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libmacwidgets-0.9.4.jar;C:Program Files (x86)GroovyGroovy-1.8.2libmacwidgetsbuilder-0.4.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libmaven-ant-tasks-2.1.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libmultiplegradientpaint-1.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libmultiverse-beta-0.7-RC-1.jar;C:Program Files (x86)GroovyGroovy-1.8.2lib
etty-3.1.5.GA.jar;C:Program Files (x86)GroovyGroovy-1.8.2libsac-1.3.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-ie-6-tlb-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-office-2K3-tlb-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-sapi-tlb-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-scripting-tlb-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-wbem-tlb-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libscriptom-wsh-tlb-1.6.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2libservlet-api-2.4.jar;C:Program Files (x86)GroovyGroovy-1.8.2libspock-core-0.6-groovy-1.8-SNAPSHOT.jar;C:Program Files (x86)GroovyGroovy-1.8.2libswing-worker-1.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libswingx-beaninfo-1.6.2-2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libswingx-core-1.6.2-2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libswingxbuilder-0.1.8.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libswingxtrasbuilder-0.3.jar;C:Program Files (x86)GroovyGroovy-1.8.2libimingframework-1.0.jar;C:Program Files (x86)GroovyGroovy-1.8.2librident-6.2.jar;C:Program Files (x86)GroovyGroovy-1.8.2libridentbuilder-0.5.jar;C:Program Files (x86)GroovyGroovy-1.8.2libxml-apis-ext-1.3.04.jar;C:Program Files (x86)GroovyGroovy-1.8.2libxmlpull-1.1.3.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libxstream-1.4.1.jar;C:Program Files (x86)GroovyGroovy-1.8.2libxswingx-0.2.jar" --encoding=UTF-8 C:Users[REDACTED]IdeaProjectsestest.groovy
Caught: java.net.SocketException: Permission denied: connect
java.net.SocketException: Permission denied: connect
    at test.run(test.groovy:9)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Process finished with exit code 1

I have absolutely no idea what is causing the problem, but my guess is that it's something IDEA is doing when it runs the groovy code that keeps it from being able to access the network.

Has anyone else experienced this? Does anyone know of a workaround?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is a known bug in JDK 1.7 related to IPv6.

Adding -Djava.net.preferIPv4Stack=true in VM Options should fix the problem.

See also related question on this site.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...