Eclipse Google Cloud plugin Unable to start DevAppServer: InaccessibleObjectException: Unable to make static java.net.URLStreamHandler - eclipse

Trying to get a basic setup working to run the local Google App Engine running in Eclipse using the Google Cloud Tools for Eclipse, but I keep getting the error below when starting the server using the Run As -> App Engine option.
I believe my environment is good because I am able to run the test application with a local app server from the command line using the java_dev_appserver command, so the problem seems specific to the Eclipse environment.
at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:383)
at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:315)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:385)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:59)
at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:259)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:250)
Caused by: java.lang.ExceptionInInitializerError
at com.google.appengine.tools.development.DevAppServerImpl.<init>(DevAppServerImpl.java:136)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:368)
... 5 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make static java.net.URLStreamHandler java.net.URL.getURLStreamHandler(java.lang.String) accessible: module java.base does not "opens java.net" to unnamed module #49c43f4e
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at com.google.appengine.tools.development.StreamHandlerFactory.<clinit>(StreamHandlerFactory.java:53)
... 12 more
I started from a clean Windows 11 machine, installed Google Cloud SDK, added the app-engine-java component, configured a project, tested by deploying to the cloud with the CLI, installed Eclipse, added the Google Tools for Eclipse plugin, created a sample project using the Google plugin Create Project -> Google App Engine Standard project, and tried to run it.
This is probably very simple but I can't figure it out.

The problem was happening with JRE v17 that installs by default with Eclipse 2021-12. Installing Eclipse with JRE v11 solved the problem. Thanks to greg-449 for putting me on the right track.

Downgrading the JVM to jdk-11.0.13 solved this problem for me as well.
Since I didn't un-install JRE v17, I had to change my eclipse.ini file to point to JDK 11, then update the Eclipse workspace settings for installed JRE's to include JDK 11 and update my workspace properties to use that version by default instead of the JRE 17. I also updated the JDK compliance settings to be JDK 11 instead of 17 and disabled the "release" setting that wanted to still use 17.
Thanks for this post. I had been working on this problem for several days upgrade/downgrading libraries, etc.

I am already on java version 11 and after looking here and there, I have downgraded from 11 to 8 but still facing same issue with eclipse plugin.
java.lang.RuntimeException: Unable to create a DevAppServer
at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:378)
at com.google.appengine.tools.development.DevAppServerFactory.createDevAppServer(DevAppServerFactory.java:310)
at com.google.appengine.tools.development.DevAppServerMain$StartAction.apply(DevAppServerMain.java:384)
at com.google.appengine.tools.util.Parser$ParseResult.applyArgs(Parser.java:58)
at com.google.appengine.tools.development.DevAppServerMain.run(DevAppServerMain.java:258)
at com.google.appengine.tools.development.DevAppServerMain.main(DevAppServerMain.java:249)
Caused by: java.lang.ExceptionInInitializerError
at com.google.appengine.tools.development.DevAppServerImpl.<init>(DevAppServerImpl.java:135)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
at com.google.appengine.tools.development.DevAppServerFactory.doCreateDevAppServer(DevAppServerFactory.java:363)
... 5 more
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make static java.net.URLStreamHandler java.net.URL.getURLStreamHandler(java.lang.String) accessible: module java.base does not "opens java.net" to unnamed module #133e16fd
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
at com.google.appengine.tools.development.StreamHandlerFactory.<clinit>(StreamHandlerFactory.java:52)
... 12 more
Any suggestion, What can be the issue?

Related

Tomcat failing to start with ClassNotFoundException

I'm using Tomcat v7.0 and with Eclipse IDE for a Webapp. When trying to start the server , I get the below ClassNotFoundException
java.lang.NoClassDefFoundError: org/apache/tomcat/util/digester/Rule
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
at java.lang.Class.getConstructor0(Class.java:2885)
at java.lang.Class.newInstance(Class.java:350)
at org.apache.catalina.startup.Bootstrap.init(Bootstrap.java:239)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:426)
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.util.digester.Rule
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
On searching, I found the apache-tomcat-util 5.23 jar containing the above class but after adding the jar to the launch configuration of Tomcat I get a series of other errors. The same server installation works good in a different work space with a different webapp. What is the issue here?
You have broken your installation, probably before you found apache-tomcat-util-5.23.jar and most certainly after adding that JAR file to your installation. That JAR you added was from a Tomcat version that is many years old and incompatible with your newer version.
Remove your existing Tomcat installation (but save the webapps/ directory if you put anything in there you want to keep) and reinstall.
If you are still getting that error, check to make sure that your IDE is configured correctly: Tomcat comes with every JAR it needs to launch, so if it won't start, it's because of a misconfiguration with the IDE's integration.
In my case the only problem was version of Apache Tomcat which I used is Apache 7.0 and when I change to Apache 8.0 It will run perfectly fine.
the exception "java.lang.NoClassDefFoundError: org/apache/tomcat/util/digester/Rule" may occur because the server installation was stopped before it was finished.
Make sure of the % of installation when you install the server since nothing appears when we click install and it seems immediate, but in reality it takes a few seconds.
No problem :-)

How to change Eclipse-Groovy plugin Groovy libraries?

I am using the newest version (2.8.0) of the Eclipse-Groovy plugin that ships with groovy-all-2.1.5.jar. I added Guice to my Groovy project, and when I go to run them from inside Eclipse I get the following error in the console output:
Caught: java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
java.lang.NoClassDefFoundError: org/codehaus/groovy/runtime/typehandling/ShortTypeHandling
at net.me.myapp.utils.restclient.RestClient.<init>(RestClient.groovy:57)
at net.me.myapp.inject.UserServiceClientModule.configure(UserServiceClientModule.groovy:34)
at com.google.inject.AbstractModule.configure(AbstractModule.java:59)
at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:223)
at com.google.inject.spi.Elements.getElements(Elements.java:101)
at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:133)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:103)
at com.google.inject.Guice.createInjector(Guice.java:95)
at com.google.inject.Guice.createInjector(Guice.java:72)
at com.google.inject.Guice.createInjector(Guice.java:62)
at net.me.myapp.UserServiceClient.<init>(UserServiceClient.groovy:37)
at net.me.myapp.UserServiceClient.main(UserServiceClient.groovy:45)
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.runtime.typehandling.ShortTypeHandling
... 12 more
According to this answer it's because ShortTypeHandling wasn't added until 2.3.x. So I would now like to attach groovy-all-2.3.3.jar to my Eclipse project's classpath.
The problem is that I don't seem to have edit permissions to change what library the Groovy Libraries library uses under the hood. And when I manually add the 2.3.3 JAR to my build path, I get the following error:
Caught: java.lang.ExceptionInInitializerError
java.lang.ExceptionInInitializerError
Caused by: groovy.lang.GroovyRuntimeException: Conflicting module versions. Module [groovy-all is loaded in version 2.1.5 and you are trying to load version 2.3.3
What are my options?
Groovy-eclipse versions have its own compilers and are "locked" to them. You may change the versions to whatever is listed under Window > Preferences > Groovy > Compilers, but, AFAIK, you can't change to an arbitrary version of the compiler by simply changing the groovy-all jar in the guts of the plugin dir.
You can install new compiler versions using the update site or eclipse marketplace
Update: install additional compiler versions through Help > Install new Software, select Groovy update site and expand the Extra Groovy Compilers session:
Note i'm using snapshot update site, because i like to live dangerously.

Adding JDK dependencies to jboss 6

I am using JBOSS EAP 6.1 using JDK 1.6. I have registered all my dependencies as static module. I have dependencies on JDK apis.
During deployment I am faced with following issue:
java.lang.NoClassDefFoundError: javax/crypto/CipherInputStream
java.lang.NoClassDefFoundError: org/omg/CORBA/portable/IDLEntity
java.lang.NoClassDefFoundError: javax/swing/ImageIcon
I was able to resolve the above issue by creating a static module and adding rt.jar and des.jar as resources in moudle.xml but then I am facing another issue regarding algorithm not found.
java.security.NoSuchAlgorithmException: PBEWithMD5AndDES SecretKeyFactory not available
at javax.crypto.SecretKeyFactory.(DashoA13*..)
at javax.crypto.SecretKeyFactory.getInstance(DashoA13*..)
at utilities.algorithm.DesEncrypter.(DesEncrypter.java:49)
at utilities.algorithm.DesEncrypter.decryptStream(DesEncrypter.java:177)
I want to add include these dependencies from system without creating static module as shown on different forums.
https://community.jboss.org/thread/195182
https://community.jboss.org/message/717881#717881#717881
Can we do it in for EAP 6.1 or its just available for JBOSS AS 7. Can someone please show me an example for EAP 6.1.
I have been able to fix the issue. The api included in JDK are exported in different modules and we need to include those modules in our modules as dependences.
For Example: org/omg/CORBA/portable/IDLEntity was available in org.omg.api module.
Similarly, javax/swing/ImageIcon & javax/crypto/CipherInputStream was available in javax.api.

Setup eclipse + svn

I've got a Java project versioned by svn and trying to configure the build for linux. On my work computer all works fine and I committed the changes. To both my home computers however I get this error which seems like some trivial setup problem:
Exception in thread "main" java.lang.NoClassDefFoundError: adventure/Adventure
Caused by: java.lang.ClassNotFoundException: adventure.Adventure
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: adventure.Adventure. Program will exit.
Did I forget to add the src to some path? The way it looks in ubuntu is here:
It was committed with Java 7 but on the ubuntu I have only Java 6. Could it still work or do I need to completely harmonize Java versions?
Update
I cleaned the build path and set up the JARs again and I'm going to add the Java 6 JRE since I don't use any Java 7 specific features so it should work if I only get the JRE set up. But I don't know how to add my JRE with linux? I can try also with windows and then maybe I can add a suitable JRE. Now there is a build problem:
Thanks but now I have no JDK which looks like the main problem and just a build problem:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
String cannot be resolved to a type
at adventure.Adventure.main(Adventure.java:74)
My Java version seems well though:
$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu3)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
The installed JRE is OpenJDK 6 that should work:
My classpath variables look like this
Usually Java projects should be committed without the bin folder (set it to ignore).
It looks like your project was checked-in including the compiled class files from Java 7 with of course can not be loaded by Java 6.
You should proceed as follows:
Open a terminal and change into your project directory
execute svn delete bin
execute svn propset svn:ignore bin .
Does anybody how to do this from whithin Eclipse?
Switch back to Eclipse and execute "Clean" command on the project so that Eclipse re-builds it using your Java version.
But I don't know how to add my JRE with linux?
You surely know Preferences->Java->Installed JREs. Please browse for your Java installations in usr/lib/jvm sub directories.

Gears complaints about JRE 1.5 in GWT project

I just tried to use Gears in my GWT application and got following error:
Jul 12, 2009 6:26:29 AM com.google.apphosting.utils.jetty.JettyLogger info
INFO: jetty-6.1.x
Jul 12, 2009 6:26:29 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: failed com.google.apphosting.utils.jetty.DevAppEngineWebAppContext#c45809{/,/Users/work/workspace/Athena/war}
javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
at javax.xml.parsers.SAXParserFactory.newInstance(SAXParserFactory.java:113)
at org.mortbay.xml.XmlParser.<init>(XmlParser.java:69)
at org.mortbay.jetty.webapp.WebXmlConfiguration.webXmlParser(WebXmlConfiguration.java:83)
at org.mortbay.jetty.webapp.WebXmlConfiguration.<init>(WebXmlConfiguration.java:78)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
at java.lang.Class.newInstance0(Class.java:350)
at java.lang.Class.newInstance(Class.java:303)
at org.mortbay.jetty.webapp.WebAppContext.loadConfigurations(WebAppContext.java:838)
at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:417)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:117)
at org.mortbay.jetty.Server.doStart(Server.java:217)
at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:40)
at com.google.appengine.tools.development.JettyContainerService.startContainer(JettyContainerService.java:147)
at com.google.appengine.tools.development.AbstractContainerService.startup(AbstractContainerService.java:116)
at com.google.appengine.tools.development.DevAppServerImpl.start(DevAppServerImpl.java:211)
at com.google.appengine.tools.development.gwt.AppEngineLauncher.start(AppEngineLauncher.java:86)
at com.google.gwt.dev.HostedMode.doStartUpServer(HostedMode.java:365)
at com.google.gwt.dev.HostedModeBase.startUp(HostedModeBase.java:590)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:397)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)
I know this error is because I'm using (1) OS X, (2) Eclipse with Google Plugin, (3) JRE 1.5. But I have no choice because Hosted Mode plugin requires JRE 1.5 and when I switch to JRE 1.6 Hosted mode complains. I also tried to set JRE 1.6 just to the project, still Plugin does not like it.
This problem occurs only when I'm including
<inherits name='com.google.gwt.gears.Gears'/>
into my gwt.xml file.
There is one guy who has same problem, he solved it by just switching JRE's but I'm using Mac and I assume there is different story with Mac. Is there any solutions to this problem in my case?
Which version of gwt-gears.jar are you using? Make sure you are
running the latest gwt-gears release (1.2.1) and try
gwt-gears-noredist.jar if you are using the Google Plugin.