Using guava in griffon gives Prohibited package exception - guava

I am using Griffon and want to add the guava libraries as a dependency in my project. However, when I do this, even without using 1 class of it, I get the following exception:
Compilation error: BUG! exception in phase 'canonicalization' in source unit
'/home/wdb/myproject/griffon-app/controllers/MyController.groovy' Prohibited
package name: java.util.concurrent
Any idea what might be wrong? This is my java version (on Ubuntu 11.10):
wdb#wdb-laptop:~$ java -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) Server VM (build 20.2-b06, mixed mode)
I found this link that talks about using the bootclasspath for a similar problem, but that seems a bit drastic.
regards,
Wim

My wild guess is that our bootclasspath copy of java.util.concurrent.ExecutorService (necessary due to an incompatible change between JDK5 and JDK6) is showing up in your classpath. I don't really know Maven, but I would think that, because we identify the dependency as "provided", this shouldn't be happening.
That's not really an answer, but I hope it's enough to get you or someone else started.

It must be that Griffon does not honor 'provided' scope. I managed to get it working by editing BuilderConfig.groovy to:
compile( 'com.google.guava:guava:10.0.1' ) {
exclude 'guava-bootstrap'
}

Related

How to solve the 'Unable to find Asm for stackmap generation' error on startup of STS?

I am trying to use the Spring Tool Suite 3.8.3 on Ubuntu 16.04. Upon startup I get this error:
An internal error occured during: "Initializing Java Tooling"
with the detailed message:
An internal error occurred during: "Initializing Java Tooling". Unable
to find Asm for stackmap generation (Looking for
'aj.org.objectweb.asm.ClassReader'). Stackmap generation for woven
code is required to avoid verify errors on a Java 1.7 or higher
runtime when weaving type org.eclipse.jdt.core.search.SearchPattern
when weaving classes when weaving
I have to admit that I have no idea what I should do here and I failed to find any pointers online. Any advice or hint is welcome.
It was for me due to the scala plug-in which I have installed a few days back. Uninstall the scala plugin and change to JDK 8 or JDK 11 it will work.
If anyone is still having a similar problem with Eclipse and needs to use Java 11 or higher (Eclipse nowadays seems to require Java 11) then have a look into this plugin as it seems to be required for the kotlin plugin.
https://marketplace.eclipse.org/content/aspectj-development-tools
I think you have installed Java 9 on your system. That's why you are facing compatibility issue and getting the stated errors. I therefore suggest you to degrade your java version to 8 for which it will work well and you wont be facing any error issue in that.
You can install java8 from this link!
I had to downgrade the JRE used to run Eclipse. Downgrading from Java 15 to Java 11 solved the problem.
Use the -vm option in eclipse.ini, eg.
-vm
c:\Dev\jdk-11\bin
My STS did not even start after installing scala plugin. I had to manually delete scala jars and folders from the STS /plugins. After that it started working.

SCALA REPL throwing error at launch

I get the following error when I try to run the SCALA REPL. Note that I have already looked into this post where it talks about downgrading java version.
sg#IN0D196716 C:\Users\sg
$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
sg#IN0D196716 C:\Users\sg
$ scala
Exception in thread "main" java.lang.NoSuchMethodError: scala.util.matching.Regex.unapplySeq(Ljava/lang/CharSequence;)Lscala/Option;
at scala.tools.nsc.settings.ScalaVersion$.apply(ScalaVersion.scala:104)
at scala.tools.nsc.settings.ScalaVersion$.apply(ScalaVersion.scala:114)
at scala.tools.nsc.settings.ScalaVersion$.<init>(ScalaVersion.scala:119)
at scala.tools.nsc.settings.ScalaVersion$.<clinit>(ScalaVersion.scala)
at scala.tools.nsc.settings.ScalaSettings$class.$init$(ScalaSettings.scala:138)
at scala.tools.nsc.settings.MutableSettings.<init>(MutableSettings.scala:20)
at scala.tools.nsc.Settings.<init>(Settings.scala:12)
at scala.tools.nsc.GenericRunnerSettings.<init>(GenericRunnerSettings.scala:11)
at scala.tools.nsc.GenericRunnerCommand.<init>(GenericRunnerCommand.scala:18)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:41)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
Sorry, dude, that's my fault.
A few years ago, someone said you should only be able to use a regex to extract from strings (char sequences).
That was such a reasonable request. "Tell me if I try to match a regex to something that isn't even a string!"
Unfortunately, because JVM and maven and ivy, you never know what backwards compatibility issues you'll discover.
As you have discovered.
Scala requires that you build and run with the same "major" version.
Here is a similar issue where "user experience" diverges:
https://issues.scala-lang.org/browse/SI-9380
Additional apologies if you don't prefer the gendered "dude", if it is gendered.

Missing dependencies in Apache Crunch Scala build

I'm trying to build the Apache Crunch source code on my CentOS 7 machine, but am getting the following error in the crunch-spark project when I execute mvn package:
[ERROR] /home/bwatson/programming/git/crunch/crunch-spark/src/it/scala/org/apache/crunch/scrunch/spark/PageRankClassTest.scala:71: error: bad symbolic reference. A signature in PTypeH.class refers to term protobuf
[ERROR] in package com.google which is not available.
[ERROR] It may be completely missing from the current classpath, or the version on
[ERROR] the classpath might be incompatible with the version used when compiling PTypeH.class.
[ERROR] .map(line => { val urls = line.split("\\t"); (urls(0), urls(1)) })
[ERROR] ^
Other SO questions about similar errors (here and here) seem to involve PATH or version issues. I've been messing around but can't seem to resolve them. For completeness:
[bwatson#ben-pc crunch]$ scala -version
Scala code runner version 2.11.5 -- Copyright 2002-2013, LAMP/EPFL
[bwatson#ben-pc crunch]$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
[bwatson#ben-pc crunch]$ mvn -version
Apache Maven 3.0.5 (Red Hat 3.0.5-16)
Maven home: /usr/share/maven
Java version: 1.8.0_31, vendor: Oracle Corporation
Java home: /usr/java/jdk1.8.0_31/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-123.20.1.el7.x86_64", arch: "amd64", family: "unix"
Any advice? I'm not really sure where Scala is looking for its dependencies, but I'd have thought that Maven would take care of it.
Unfortunately Different versions of Scala are binary incompatible. Currently by default Apache Spark uses Scala 2.10.4, not Scala 2.11. Apache Scrunch is dependent on Spark. Maven does not know anything about this so it can't help. It is necessary to make some modifications to Scrunch to get it to compile for Scala 2.11 / JDK 1.8. I am working on this at the moment, but I don't have a solution yet. However I get the error message you report if I compile Scala 2.10.4 with JDK 1.8, not Scala 2.11, so I don't think it is doing quite what you intend. The error seems be coming from the Protobuf compiler or jar but I don't know why that is.
When I solve it myself, I will report back!
It turns out the official documentation for Crunch was missing a Maven parameter. The issue was solved by building using:
mvn package -Dcrunch.platform=2

UnsupportedClassVersionError deploying EJB "HelloWord" in Glasshfish 3

I try to deploy a simple "Hello Word" in my local server GlasshFish 3, but at the deploy the console print this message
[#|2013-01-15T15:00:02.458+0100|SEVERE|glassfish3.1.2|
javax.enterprise.system.tools.admin.org.Exception while deploying the app
[HelloWorldEJB] :UnsupportedClassVersionError: Class ejb_other.PlaceAuctionItemBean
as unsupported major or minor version numbers, which are greater than those found
in the Java Runtime Environment version 1.6.0_27|#]
My JAVA_HOME has java version 1.6.0_27 (it refers to _C:\Program Files\Java\jdk1.6.0_27_), my Eclipse (indigo) project refers to java 1.6.0_27.
I think (i don't know how to verify) that GlasshFish refers to JAVA_HOME.
In my PC (Windows 7) I found 2 directory having java.exe:
C:\Windows\SysWOW64>java -version -->>java version "1.6.0_29"
C:\Windows\System32>java -version -->>java version "1.6.0_27"
I found more discussions about this exception (f.e. this or this ), but I need of something more specific for Eclipse/Glasshfish, because I can't to solve. I see that the JVM is the same for compilation and execution.
Post Scriptim
I add the screenshot about the places where I declare JVM: it's always 1.6.
one:
two:
three:
Where can I see that I compile with java 7 or it runs with another JVM?
ejb_other.PlaceAuctionItemBean was obviously compiled for Java 7 which won't work if you run it in a Java 6 JVM.
Found solution
There's another place where setting the compiler's options:
how do I get eclipse to use a different compiler version for Java?

How to fix NoSuchMethodError?

I use Scala 2.10.0RC1 and sbt 0.12.1.
What causes and how can I fix this runtime error (runs fine on 2.9.2)?
The exact error message is:
java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/Object;)Lscala/Tuple2;
You're running the code with the wrong Scala version. This can have several causes:
misconfiguration of the project with sbt – search for 2.9.2 in config files
stale cache used by sbt – sbt reboot
something else?
If you meticulously check all your sbt configuration files for 2.9.2 and then wipe out all caches, things should run better. Dependencies usually have a version number in the name of the jar file, so running a find on your system will likely point you to the ones you missed.