Just run a sample Scala SBT project after installing Java 9 on my pc and I took this exception.
I already tried some solutions that I found but nothing.
Is there any incompatibility between Java 9 and Scala?
Scala Version: 2.12.3
Java Version: java version "9"
IDE: IntelliJ
Thanks in advance.
info] Compiling 7 Scala sources and 1 Java source to /Users/ermis/Projects/begining-scala/target/scala-2.12/classes...
[info] p.a.h.EnabledFilters - Enabled Filters (see <https://www.playframework.com/documentation/latest/Filters>):
play.filters.csrf.CSRFFilter
play.filters.headers.SecurityHeadersFilter
play.filters.hosts.AllowedHostsFilter
[info] play.api.Play - Application started (Dev)
Uncaught error from thread [play-dev-mode-akka.actor.default-
dispatcher-2]: javax/xml/bind/DatatypeConverter, shutting down JVM since 'akka.jvm-exit-on-fatal-error' is enabled for for ActorSystem[play-dev-mode]
java.lang.NoClassDefFoundError: javax/xml/bind/DatatypeConverter
at io.jsonwebtoken.impl.Base64Codec.decode(Base64Codec.java:26)
at io.jsonwebtoken.impl.DefaultJwtBuilder.signWith(DefaultJwtBuilder.java:106)
at play.api.mvc.JWTCookieDataCodec$JWTFormatter.format(Cookie.scala:710)
at play.api.mvc.JWTCookieDataCodec.encode(Cookie.scala:569)
at play.api.mvc.JWTCookieDataCodec.encode$(Cookie.scala:567)
at play.api.mvc.DefaultJWTCookieDataCodec.encode(Cookie.scala:760)
at play.api.mvc.FallbackCookieDataCodec.encode(Cookie.scala:734)
at play.api.mvc.FallbackCookieDataCodec.encode$(Cookie.scala:733)
at play.api.mvc.DefaultSessionCookieBaker.encode(Session.scala:95)
at play.api.mvc.CookieBaker.encodeAsCookie(Cookie.scala:414)
at play.api.mvc.CookieBaker.encodeAsCookie$(Cookie.scala:413)
at play.api.mvc.DefaultSessionCookieBaker.encodeAsCookie(Session.scala:95)
at play.api.mvc.Result.$anonfun$bakeCookies$2(Results.scala:281)
at scala.Option.map(Option.scala:146)
at play.api.mvc.Result.bakeCookies(Results.scala:280)
at play.core.server.common.ServerResultUtils.prepareCookies(ServerResultUtils.scala:227)
at play.core.server.AkkaHttpServer.$anonfun$executeAction$3(AkkaHttpServer.scala:302)
at akka.http.scaladsl.util.FastFuture$.strictTransform$1(FastFuture.scala:41)
at akka.http.scaladsl.util.FastFuture$.transformWith$extension1(FastFuture.scala:55)
at akka.http.scaladsl.util.FastFuture$.flatMap$extension(FastFuture.scala:26)
at play.core.server.AkkaHttpServer.executeAction(AkkaHttpServer.scala:301)
at play.core.server.AkkaHttpServer.executeHandler(AkkaHttpServer.scala:254)
I tried this but didn't work.
--add-modules java.xml.bind
or
--add-modules java.se.ee
Try adding a compiler option to temporarily fix this:
--add-modules java.se.ee
since the Module shared by Java EE would not be resolved by default in JDK9.
You can also keep track of the issue to Support JDK 9 at scala-dev repository for updates as well.
I just remove Java 9 until someone gives me some lights and the compile works as usual.
Related
I am trying to get Cassandra v2.1.17 running using Java 11 (Oracle), but cannot get it to startup. I have updated all the JVM args in cassandra-env.sh to the Java 11 equivalents, but I now get the following error on startup:
ERROR 14:48:10 Exception encountered during startup
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.NoSuchMethodError: sun.misc.Unsafe.monitorEnter(Ljava/lang/Object;)V
at com.google.common.base.Throwables.propagate(Throwables.java:160) ~[guava-16.0.jar:na]
...
...
...
Caused by: java.lang.NoSuchMethodError: sun.misc.Unsafe.monitorEnter(Ljava/lang/Object;)V
I have done a good bit of looking about and it seems that this class was removed in Java 9, or at least deprecated, but was still accessible using --add-modules=jdk.unsupported. Adding this to my JVM args didn't help.
Is it possible to run Cassandra 2.1.17 on Oracle Java 11? I can see that the class is still in OpenJDK 11 (https://hg.openjdk.java.net/jdk/jdk11/file/6889f13694c6/src/jdk.unsupported/share/classes/sun/misc/Unsafe.java) but I am stuck using Centos6 and cannot find an install for it.
#MeanwhileInHell, JDK 11 support for Apache Cassandra(R) was explored in the recent Cassandra 4.0 version only and I don't think it's available in very older and unsupported versions like 2.x. Please see https://cassandra.apache.org/doc/latest/cassandra/new/java11.html documentation for additional details.
https://issues.apache.org/jira/browse/CASSANDRA-9608 has details.
I need to deploy my GWT application to an OC4J server using Java 6.
I'm using GWT SDK 2.7.0 - according to the release notes while Java 7 is the default, this can be overridden using -sourceLevel 6 which in Eclipse I am adding as a compiler argument.
This has solved most of the problems the OC4J progress text gave me when deploying my war - but one seems to remain.
Operation failed with error: com/google/gwt/user/server/rpc/RemoteServiceServlet : unsupported classversion 51.0
Ignoring the specificity of OC4J, why is the RemoteServiceServlet a Java 7 class, when I have set the GWT compiler to use Java 6?
It sounds like you aren't using the right version of GWT - either that isn't 2.7.0, or you are using the wrong jar:
$ javap -cp /Users/colin/.m2/repository/com/google/gwt/gwt-servlet/2.7.0/gwt-servlet-2.7.0.jar -v com.google.gwt.user.server.rpc.RemoteServiceServlet
Classfile jar:file:/Users/colin/.m2/repository/com/google/gwt/gwt-servlet/2.7.0/gwt-servlet-2.7.0.jar!/com/google/gwt/user/server/rpc/RemoteServiceServlet.class
Last modified Nov 20, 2014; size 11978 bytes
MD5 checksum ef76115d101d7321764ed74a7d8c1d62
Compiled from "RemoteServiceServlet.java"
public class com.google.gwt.user.server.rpc.RemoteServiceServlet extends com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet implements com.google.gwt.user.server.rpc.SerializationPolicyProvider
minor version: 0
major version: 50
...
I just checked gwt-user also, and it too is 50.0, check that your gwt-servlet is actually the version you think you are using?
This question already has answers here:
import sun.misc.BASE64Encoder results in error compiled in Eclipse
(15 answers)
Closed 1 year ago.
when i run my app in mac, and show up this message
Errors occurred during the build.
Errors running builder 'Android Package Builder' on project 'IMPEXP'.
sun/misc/BASE64Encoder
but this project is work fine in windows 10 computer, and i don't use any about base64Encoder
eclipse Version: Photon Milestone 3 (4.8.0M3)
JRE java se 9.0
edit!
i found something like below
!ENTRY org.eclipse.core.resources 4 2 2017-11-09 11:50:09.047
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.resources".
!STACK 0
java.lang.NoClassDefFoundError: sun/misc/BASE64Encoder
at com.android.sdklib.internal.build.SignedJarBuilder.<init>(SignedJarBuilder.java:177)
at com.android.sdklib.build.ApkBuilder.init(ApkBuilder.java:446)
at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:422)
at com.android.sdklib.build.ApkBuilder.<init>(ApkBuilder.java:362)
at com.android.ide.eclipse.adt.internal.build.BuildHelper.finalPackage(BuildHelper.java:391)
at com.android.ide.eclipse.adt.internal.build.BuildHelper.finalDebugPackage(BuildHelper.java:359)
at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:632)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:735)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:330)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:405)
at org.eclipse.core.internal.resources.Project$1.run(Project.java:566)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2240)
at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:544)
at org.eclipse.core.internal.resources.Project.build(Project.java:120)
at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)
Caused by: java.lang.ClassNotFoundException: sun.misc.BASE64Encoder cannot be found by com.android.ide.eclipse.base_23.0.7.2120684
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:484)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:395)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:387)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:150)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 23 more
As others have pointed out already, this is a compatibility issue—you need exactly Java 8 to run Eclipse.
Install JDK 8 if you don’t have it already.
In Eclipse, go to Window > Preferences > Installed JREs. Make sure Java 8 appears in the list and is selected. After that, close Eclipse.
Additionally, eclipse.ini also has a reference to the Java VM it uses. Make sure the VM it points to is Java 8 (see link on how to find it and how to set VM preferences).
Restart Eclipse and try again.
The Android code you are using is trying to use the sun.misc.BASE64Encoder class.
This deprecated class has been removed from Java 9 so this is not going to work.
You will need to switch back to Java 8 or find an update to the Android code (if there is one).
I'm working with Windows 7. I had to change the preferences and the ini file. Both had C:\Program Files\Java\jdk-12.0.1\bin which I changed to C:\Program Files\Java\jre1.8.0_221\bin. It now works!
In my case it was something very crazy.
I have to download the eclipse IDE Version NEON
Since the project is old almost from 2014
Attached the url of the IDE for which you need it:
Eclipse IDE NEON
I also had to follow the same installation steps
I am getting started with Gradle on a polyglot java/scala project. The java modules are legacy modules built using JDK 1.6 so I decided to have my build environment use the older JDK.
This has a very practical rationale. Code such as the following:
class X{
private int i;
<T extends X> void aMethod(T t){
int it = t.i;
}
}
will compile fine using JDK 1.6 but will break with JDK 1.7 with the following error:
error: i has private access in X
For this reason (although unhappily) I decided to stick to JDK 1.6 (we do have code that looks like that).
Now I created a brand new Gradle project (no dependency/build tool was used before) with two modules:
myApp
|---- common (java module)
|---- someService (depends on common)
| |---- service (scala module)
| |---- api (java client)
and set the java source and target compatibility to 1.6. If I build with gradle everything works fine, i.e., the build runs and the jars get build correctly (both java and scala), without any error.
Now I generated my IntelliJ project files using the 'idea' plugin. IntelliJ loads up the project correctly. Now when I try and build from IntelliJ (Ctrl + F9) I get the following:
Information: Modules "myApp", "someService", "common" were fully rebuilt due to project configuration/dependencies changes
Information: Compilation completed with 4 errors and 44 warnings in 2 sec
Information: 4 errors
Information: 44 warnings
Error: scala: warning: [options] bootstrap class path not set in conjunction with -source 1.6
Error: scala: 1 error
Error: scala: 43 warnings
Warning: scala: Some input files use unchecked or unsafe operations.
Warning: scala: Recompile with -Xlint:unchecked for details.
... (the warnings follow)
error: properties has private access in X
As you can see, I am now getting the JDK 1.7 error (although I'm compiling with 1.6) and the build fails. IntelliJ says there are 4 errors but I believe the root cause is just that one.
Now If I go and fix the code above as follows:
class X{
private int i;
<T extends X> void aMethod(T t){
// SDK 1.7: explicit downcast grants access to base private members
int it = ((X)t).i;
}
}
I get the following error:
scala: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.InternalError
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:838)
...
at java.lang.ClassLoader.getBootstrapResource(ClassLoader.java:1305)
...
at sbt.classfile.Analyze$$anonfun$apply$8$$anonfun$sbt$classfile$Analyze$$anonfun$$processDependency$1$1.apply$mcV$sp(Analyze.scala:49)
...
at scala.collection.immutable.HashSet$HashSet1.foreach(HashSet.scala:153)
...
at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:44)
at org.jetbrains.jps.incremental.scala.local.CompilerImpl.compile(CompilerImpl.scala:63)
...
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
at java.lang.reflect.Method.invoke(Method.java:606)
at com.martiansoftware.nailgun.NGSession.run(Unknown Source)
Caused by: java.io.FileNotFoundException: /usr/lib/jvm/java-7-oracle/jre/lib/resources.jar
...
which I believe is caused by the fact that I uninstalled JDK 1.7 and installed JDK 1.6 and somewhere in the IntelliJ paths something is still pointing at the old JDK.
So I have two questions:
1. How to get rid of any reference to JDK 1.7 in IntelliJ?
2. How to get rid of the first error altogether without changing the code? I know this is possible because Gradle does it successfully.
Silly me! I had uninstalled JDK 7 without restarting IntelliJ so it was still pointing to some of the JDK 7 folders. This was a very odd experience!
I run into an exception whenever trying play run on my Mac.
Detail stack track is as
The new application will be created in /Users/admin/mine/test2
What is the application name?
> test2
Which template do you want to use for this new application?
1 - Create a simple Scala application
2 - Create a simple Java application
3 - Create an empty project
> 2
java.lang.StackOverflowError
at scala.reflect.ClassManifest$class.newArray(ClassManifest.scala:113)
at scala.reflect.ClassTypeManifest.newArray(ClassManifest.scala:233)
at scala.reflect.ClassManifest$class.newWrappedArray(ClassManifest.scala:133)
at scala.reflect.ClassTypeManifest.newWrappedArray(ClassManifest.scala:233)
at scala.collection.mutable.WrappedArrayBuilder.mkArray(WrappedArrayBuilder.scala:31)
at scala.collection.mutable.WrappedArrayBuilder.resize(WrappedArrayBuilder.scala:37)
at scala.collection.mutable.WrappedArrayBuilder.ensureSize(WrappedArrayBuilder.scala:49)
at scala.collection.mutable.WrappedArrayBuilder.$plus$eq(WrappedArrayBuilder.scala:54)
at scala.collection.mutable.WrappedArrayBuilder.$plus$eq(WrappedArrayBuilder.scala:24)
at scala.collection.TraversableLike$$anonfun$filter$1.apply(TraversableLike.scala:213)
at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:34)
at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:33)
at scala.collection.TraversableLike$class.filter(TraversableLike.scala:212)
at scala.collection.mutable.WrappedArray.filter(WrappedArray.scala:33)
at scala.collection.TraversableLike$class.filterNot(TraversableLike.scala:223)
at scala.collection.mutable.WrappedArray.filterNot(WrappedArray.scala:33)
at scalax.file.FileSystem.fromSeq(FileSystem.scala:97)
at scalax.file.FileSystem.apply(FileSystem.scala:108)
at scalax.file.FileSystem.presentWorkingDirectory(FileSystem.scala:48)
at scalax.file.defaultfs.DefaultFileSystem.doCreateFromSeq(DefaultFileSystem.scala:26)
at scalax.file.defaultfs.DefaultFileSystem.doCreateFromSeq(DefaultFileSystem.scala:20)
at scalax.file.FileSystem.fromString(FileSystem.scala:90)
at scalax.file.defaultfs.DefaultPath.toAbsolute(DefaultPath.scala:40)
at scalax.file.defaultfs.DefaultPath.toAbsolute(DefaultPath.scala:36)
at scalax.file.FileSystem.presentWorkingDirectory(FileSystem.scala:48)
at scalax.file.defaultfs.DefaultFileSystem.doCreateFromSeq(DefaultFileSystem.scala:26)
at scalax.file.defaultfs.DefaultFileSystem.doCreateFromSeq(DefaultFileSystem.scala:20)
at scalax.file.FileSystem.fromString(FileSystem.scala:90)
at scalax.file.defaultfs.DefaultPath.toAbsolute(DefaultPath.scala:40)
at scalax.file.defaultfs.DefaultPath.toAbsolute(DefaultPath.scala:36)
at scalax.file.FileSystem.presentWorkingDirectory(FileSystem.scala:48)
at scalax.file.defaultfs.DefaultFileSystem.doCreateFromSeq(DefaultFileSystem.scala:26)
at scalax.file.defaultfs.DefaultFileSystem.doCreateFromSeq(DefaultFileSystem.scala:20)
....
Error during sbt execution: java.lang.StackOverflowError
Java version is OpenJDK Runtime Environment (build 1.7.0-internal-henri_2011_06_08_08_48-b00)
Scala version is 2.9.1 (install via brew)
Sbt version is 0.11.3
Playframework version is 2.0.4 (same problem with 2.10 actually)
What should I do then?
Probably this is because of java version. You should try another java version. I use java version "1.6.0_37" on my mac.