Scala: no corresponding Java Class found - java

While Compiling an Scala 2.10 Project, I got an error I cannot even understand
java.lang.NoClassDefFoundError: no Java class corresponding to MongoPersistable.this.type found
at scala.reflect.runtime.JavaMirrors$JavaMirror.typeToJavaClass(JavaMirrors.scala:1218) ~[scala-reflect-2.10.0.jar:na]
at scala.reflect.runtime.JavaMirrors$JavaMirror.runtimeClass(JavaMirrors.scala:202) ~[scala-reflect-2.10.0.jar:na]
at scala.reflect.runtime.JavaMirrors$JavaMirror.runtimeClass(JavaMirrors.scala:65) ~[scala-reflect-2.10.0.jar:na]
...
How is this even possible to get such a error message if the code got well in eclipse in first place?
Following line of Code produces this error:
trait MongoPersistable {
def save() {
val dao : MongoDAO[MongoPersistable.this.type] = MongoDAO[this.type];
....
I would upload more code if I know where to search

Related

How to customize the gradle error message from javacompile error

We want to custom or change the error log of JavaCompileTask.
We used a special java source location "build\intermediates\merged\main\java" which contains some processed java code that generated before JavaCompileTask executing.Now, when the task compile error and it prints the source code path start with "build\intermediates\merged\main\java". We want to replace the "build/**" preifix with original source code , then we can click the console link and jump to the correct file.
Gadle 3.5, AndroidPlugin 2.3.3 Jdk8
The console is showing the code path which was not what we wanted.
D:\m4399_GameCenter\app\build\intermediates\merged\main\java\com\m4399\gamecenter\plugin\main\models\shop\ShopExchangeRecommendAppModel.java:29: error: ShopExchangeRecommendAppModel was not abstract, and not override method getTorrentId() of IAppDownloadModel
We want to format it to :
D:\m4399_GameCenter\app\src\main\java\com\m4399\gamecenter\plugin\main\models\shop\ShopExchangeRecommendAppModel.java:29: error: ShopExchangeRecommendAppModel was not abstract, and not override method getTorrentId() of IAppDownloadModel .

Missing resolveStrategy breaks DSL when executed from runnable jar

I'm using the Groovy Spreadsheet Builder within one of my Grails projects to export some data as Excel file.
Everything works great until I create a runnable jar (using gradle assemble) and use this.
I'm using the builder within a service like this:
class ExcelService {
...
void export(OutputStream outputStream) {
...
PoiSpreadsheetBuilder.create(outputStream).build {
apply ExcelStylesheet
...
}
}
...
}
When I try to export my data from the app started using the generated jar I will get the following MissingMethodException:
groovy.lang.MissingMethodException: No signature of method: my.package.ExcelService.apply() is applicable for argument types: (java.lang.Class)
The (Java) interface of SpreadsheetBuilder looks like this:
public interface SpreadsheetBuilder {
void build(#DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = WorkbookDefinition.class) #ClosureParams(value = FromString.class, options = "builders.dsl.spreadsheet.builder.api.WorkbookDefinition") Configurer<WorkbookDefinition> workbookDefinition);
}
While debugging the execution of the code and the jar I found the difference while stepping through invokeMethod() of ClosureMetaClass.
When closure.getResolveStrategy(); in the working version is called Closure.DELEGATE_FIRST will be returned. Debugging the jar, the result will be 0 so that the MissingMethodException will be thrown later due to the wrong resolve strategy.
For now I have no idea how to solve this problem.
What is/could be the reason for this behavior?
What can I do to solve this issue?
I'm using Grails 3.3.8 with Java OpenJDK 1.8.0_192.
If you don't need to support JDK 7, you could upgrade to Groovy Spreadsheet Builder 2.0.0.RC1 which is only JDK 8 compatible but appears to solve the problem.
#ClosureParams and #DelegatesTo are applicable to parameters of type groovy.lang.Closure. In this case, you have applied it to Configurer<WorkbookDefinition>.

compilation java javax.el.ExpressionFactory

i tried to compile a code, this class compiled and i broke someth
I search impossible to find this method and which jar miss
import javax.el.ExpressionFactory
org.apache.commons.jexl2.Expression e = ExpressionFactory.newInstance().createExpression;
i tried to add commons-jexl_2.1.1.jar and i hava this error
Multiple markers at this line
- The method createExpression(String) is undefined for the type
ExpressionFactory
i tried grepcode but it seem not recognized createExpression
Do you have any ideas?
Thanks

Kotlin Runtime errors on basic operators

I am running a project on IntelliJ that has a mix of kotlin and Java; when I build the project I get a heap of errors which shouldnt occur. for example, the following code throws the error:
Error:(129, 23) Kotlin: Unresolved reference: +=
override fun startMessagingService(RPCOps: RPCOps?) {
// Start up the embedded MQ server
messageBroker?.apply {
runOnStop += Runnable { messageBroker?.stop() }
start()
bridgeToNetworkMapService(networkMapService)
}
}
Obviously these are just basic operations and shouldn't fail. When I click on the error message it doesn't show an error in the actual code file. Perhaps my configuration is wrong? If so; how to go about fixing it?
There are many other errors that throw on basic operations like the one above.

XText: 7 languages tutorial can't resolve reference to JvmIdentifiableElement in example 1 scripting

I'm following 7 languages tutoiral from XText homepage (http://www.eclipse.org/Xtext/7languages.html)
In the first example "scripting" I've managed to get almost everything running, but there seems to be a problem with identifiers scoping.
I have editor running and code generation for empty script, but trying to write anything useful doesn't work.
I typed code for grammar and model inferer verbatim from tutorial and also tried to use versions from github repo with examples https://github.com/xtext-dev/seven-languages-xtext
demo.script
val i = 1
demo.java generated
public class demo {
public static void main(final String[] args) {
final int i = 1;
}
}
This works fine
Now here is input that causes problems
error.script
println("test")
This reports two errors:
Error 1
Description: Couldn't resolve reference to JvmIdentifiableElement 'println'.
Resource: error.script
Path: /org.xtext.scripting.demo/scripting
Location: line: 3 /org.xtext.scripting.demo/scripting/demo.script
Type: Scripting Problem
Error 2
Description: This expression is not allowed in this context, since it doesn't cause any side effects.
Resource: error.script
Path: /org.xtext.scripting.demo/scripting
Location: line: 1 /org.xtext.scripting.demo/scripting/error.script
Type: Scripting Problem
I'm using XText plugins in version 2.4.0
Any suggestions what to change to make this example working as described in tutorial?
You have to add a dependency to the xbase.lib to the project that contains the script file.

Categories