`Error:osgi: [optaplanner-core] Unexpected build error` on building CloudBalancingHelloWorld - intellij-idea

I cloned optaplanner's repository.
I imported the top-level pom.xml in IntelliJ IDEA.
Then I tried to run org.optaplanner.examples.cloudbalancing.app.CloudBalancingHelloWorld.
I get the following error: Error:osgi: [optaplanner-core] Unexpected build error
The doc says the maven integration will take care of the rest, so I guess I am missing something.
Question 1: Can I somewhat configure IDEA (or use the CLI) to show more verbose errors, so that I can debug it? Unexpected build error is not enough information for me to figure that problem out.
Question 2: How can I fix this error?
FYI, this box is running Ubuntu 18.04 (edit: exact same issue on Fedora 28). My maven version is as follows.
$ mvn --version
Apache Maven 3.5.3 (3383c37e1f9e9b3bc3df5050c29c8aff9f295297; 2018-02-25T04:49:05+09:00)
Maven home: /opt/apache-maven-3.5.3
Java version: 1.8.0_181, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-32-generic", arch: "amd64", family: "unix"
EDIT: IntelliJ version: 2018.2.1
Run configuration:

You should disable the Osmorc plugin in IDEA. After thay the project will normally build

Intellij IDEA's OSGI plugin chould not recongnized properties like parsedVersion.*, which was generate by org.codehaus.mojo:build-helper-maven-plugin added in parent project org.kie:kie-parent.
You should disable the OSGI plugin, or add following code to /pom.xml manually.
<properties>
...
<parsedVersion.majorVersion>7</parsedVersion.majorVersion>
<parsedVersion.minorVersion>28</parsedVersion.minorVersion>
<parsedVersion.incrementalVersion>0</parsedVersion.incrementalVersion>
</properties>
Drools and jbpm has the same issue, because they also use org.kie:kie-parent as parent project. It could be sloved by the same way.

i meet the same problem,and solve it later.
first,remove the osgi module in Project Structure->Facets .
then, change the Run/Debug Configurations as the project README.adoc said.
after all ,i can run it successfully.

Related

Updated intellij messed up Kotlin with 'Check your module classpath for missing or conflicting dependencies'

Lot's of frustration here. I decided to follow the pop-up prompting an intellij upgrade so it'd stop nagging me.
And now I get a compiler error on certain parts of the code:
Cannot access 'java.io.Serializable' which is a supertype of 'kotlin.String'. Check your module classpath for missing or conflicting dependencies
I can make a new kotlin project with only the following and run it:
fun main() {
println("helloWorld")
}
But if I change it to the following it does not compile:
fun main() {
println("hello" to "World")
}
$ java -version
java version "1.8.0_201"
Java(TM) SE Runtime Environment (build 1.8.0_201-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
I'm on windows. I find it very challenging to debug these kind of things. It feels very similar to this and this upvoted one
It was solved by downloading a jdk and applying it to the project:
Click the plus, select a vendor and download:
And then apply it to the project:
And rebuild.
I encountered some similar problem on IntelliJ and end up with clicking reload all maven projects button.
Invalidate Cache and Restart helped

Strange error when upgrading play-services-auth from 15.0.0 to 16.0.1

For my android project I upgraded play-services-auth library version from 15.0.0 to 16.0.1
Since then I see following error during the build and it also produces
ajcore files
I have removed my .gradle caches and done build and still see this error.
Anybody else seen this before, how do I fix it?
java.lang.IllegalStateException: Expecting .,<, or ;, but found authapi while unpacking Lcom/google/android/gms/common/api/internal/BaseImplementation$ApiMethodImpl;
at org.aspectj.util.GenericSignatureParser.parseClassTypeSignature(GenericSignatureParser.java:204)
at org.aspectj.util.GenericSignatureParser.parseFieldTypeSignature(GenericSignatureParser.java:155)
at org.aspectj.util.GenericSignatureParser.parseTypeArgument(GenericSignatureParser.java:267)
In my case, removing the Hugo logging plugin fixed the issue.
Check in your gradle file if you have it configured.
classpath 'com.jakewharton.hugo:hugo-plugin:1.2.1'
It happens because some plugin (added by you) use libs:
org.aspectj:aspectjtools
or
org.aspectj:aspectjrt for codegeneration

PluginException: TOPIC[Plugin: com.alayouni.ansiHighlight] | Unable to start IntelliJ

I tried to
start IntelliJ in normal mode,
open my existing projects
check out my projects from Version Controls
but all said activities gives me this error:
Cannot load project:
com.intellij.ide.plugins.PluginManager$StartupAbortedException:
com.intellij.diagnostic.PluginException: TOPIC[Plugin:
com.alayouni.ansiHighlight]
Version:
IntelliJ Community Edition 2016.1.4
logs: Suggest me where do I get logs from
Plugins can be removed manually from the plugins directory or directly from IDE settings.
In your case ansiHighlight plug-in should be removed/disabled.

IntelliJ Error:java: java.lang.ExceptionInInitializerError

Every time I encounter this exception in IntelliJ, I fix it trivially and forget the fix easily.
Code:
package whatever;
import org.junit.Test;
public class TestClass
{
#Test
void test() {}
}
Scenario:
Add new TestClass.
Right-click TestClass.
Select "Run 'TestClass'" to run test cases.
The "Messages Build" pane shows:
Information:javac 9-ea was used to compile java sources
Information:Module "dummy" was fully rebuilt due to project configuration/dependencies changes
Information:8/16/17 11:35 PM - Compilation completed with 1 error and 0 warnings in 1s 663ms
Error:java: java.lang.ExceptionInInitializerError
What can possibly go wrong?
What are the likely issues in this simple scenario?
IntelliJ: COMMUNITY 2017.1 (idea-IC-171.4424.56)
To fix the issue, I do:
File -> Project Structure... -> Project Settings / Project -> Project SDK.
Change from "9-ea" to "1.8".
DETAILS
Apparently, the issue is discrepancies in selected JDK-s to build (java 9) and run (java 8).
I'm not sure how "9-ea" gets re-selected there for the same project - neither IntelliJ itself runs in "9-ea" JRE (according to Help -> About) nor JAVA_HOME env var is set to it nor other possible settings (like Maven -> Runner) suggest any "9-ea".
I also didn't manage to run the test under the same JDK (java 9) which it gets compiled under. However, it's unclear what JDK tests are run under because IntelliJ reports only about JDK for compilation.
If you use Lombok: For me it was a solution to set the newest version for my maven lombok dependency in the pom.xml.
*<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
<version>1.18.8</version>
</dependency>*
I was facing same error when i tried to run my application in IntelliJ-2019.2 version. Below are the steps i followed to resolve this issue.
Versions:
IntelliJ : IDEA-IntelliJ-2019.2
Java : jdk1.8_221
Go to below path in IntelliJ
File -> Project Structure -> Project -> Project SDK -> (select java version which you want to use )
(In my case under 'project SDK' java-11 was selected, I changed it to 'java8')
Click on 'Apply' and then 'OK'.
I feel I ran into this issue because IntelliJ was trying to compile my java classes using in-built java-11 whereas my java classes are built on java-8. So when i explicitly configured java-8 in IntelliJ, It worked!! Hope this helps.
I started seeing this exception once I installed Java 11 in my machine. JAVA_HOME was by default pointing to Java 11 and my project was still in Java 8. Changing JAVA_HOME to Java 8 jdk fixed the issue for me.
If you have multiple projects each running on a different JDK, use this command to temporarily change the Java version per command.
JAVA_HOME=/path/to/JVM/jdk/Home mvn clean install
If you have recently updated your IDE then you can try these steps.
Delete .idea directory for the idea project/workspace
Then go to File -> Invalidate Caches / Restart...
Once Idea is restarted re-add/import your module(s)
I faced a similar issue with JARs and Jena (while run from IntelliJ it works).
I was using Apache Jena v4.0.0 in my project and have built a JAR (with a main class for the JAR to act as a console app).
The JAR builts successfully with IntelliJ but when run throws java.lang.ExceptionInInitializerError ... Caused by: java.lang.NullPointerException. NPE suggests that something was not initialized properly.
The jar built with previous version Jena 3.17.0 works perfectly.
What I did to fix it
I've opened both the JARs, compared their META-INF folders and encountered the difference in
my.jar\META-INF\services\org.apache.jena.sys.JenaSubsystemLifecycle
The new version (jena v4.0.0) contains only one line:
org.apache.jena.tdb.sys.InitTDB
The old version (jena v3.17.0) contains two different lines:
org.apache.jena.riot.system.InitRIOT
org.apache.jena.sparql.system.InitARQ
I've added the old two lines to the file and repacked new JAR with it:
org.apache.jena.tdb.sys.InitTDB
org.apache.jena.riot.system.InitRIOT
org.apache.jena.sparql.system.InitARQ
It resolved my issue.
Update: recent Jena v4.4.0 builts with the same "bug".
I'm not an expert and there is probably a better way than patching a JAR by hand.
But I still hope that this solution will help someone like me.

What's the reason for "Error:Cannot determine Java VM executable in selected JDK"?

I am using IntelliJ IDEA 13.1.4 and also tried the latest release 14.
Running SBT I get the following error:
Error:Cannot determine Java VM executable in selected JDK
I have JDK 1.7 installed on my machine and on PATH.
In the logs (~/Library/Logs/IntelliJIdea14/idea.log on MacOS) there's the following stack trace:
2014-11-03 11:22:05,054 [4896641] WARN - nal.AbstractExternalSystemTask - Cannot determine Java VM executable in selected JDK
com.intellij.openapi.externalSystem.model.ExternalSystemException: Cannot determine Java VM executable in selected JDK
at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$10.apply(SbtExternalSystemManager.scala:97)
at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$10.apply(SbtExternalSystemManager.scala:97)
at scala.Option.getOrElse(Option.scala:120)
at org.jetbrains.sbt.project.SbtExternalSystemManager$.executionSettingsFor(SbtExternalSystemManager.scala:96)
at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$getExecutionSettingsProvider$1.apply(SbtExternalSystemManager.scala:54)
at org.jetbrains.sbt.project.SbtExternalSystemManager$$anonfun$getExecutionSettingsProvider$1.apply(SbtExternalSystemManager.scala:54)
at org.jetbrains.sbt.package$$anon$3.fun(package.scala:29)
at org.jetbrains.sbt.package$$anon$3.fun(package.scala:28)
at com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil.getExecutionSettings(ExternalSystemApiUtil.java:590)
at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager.a(ExternalSystemFacadeManager.java:201)
at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager.a(ExternalSystemFacadeManager.java:178)
at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager.doInvoke(ExternalSystemFacadeManager.java:133)
at com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager$MyHandler.invoke(ExternalSystemFacadeManager.java:270)
at com.sun.proxy.$Proxy57.getResolver(Unknown Source)
at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:48)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:137)
at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:123)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$2.execute(ExternalSystemUtil.java:475)
at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3$1.run(ExternalSystemUtil.java:543)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:609)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$7.run(ProgressManagerImpl.java:410)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$3.run(ProgressManagerImpl.java:194)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.a(ProgressManagerImpl.java:281)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:233)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:181)
at com.intellij.openapi.application.impl.ApplicationImpl$10$1.run(ApplicationImpl.java:640)
at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:405)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56)
What can be the reason for this?
You should be able to work it around by setting the jdk from the settings not from the open/import project dialog.
From the welcome screen, go to Configure -> Project defaults -> Project structure and add the jdk.
Opening the sbt project should work well then.
Found solution from here
Another way to set JDK is from your current module/project settings (for your current project)
PickOpen Module Settings from project context menu (or default hit F4), then from left tab select Project and point correct Project SDK on dropdown.
The issue is usually caused by a wrong JDK version in ".idea/sbt.xml", e.g.:
<option name="jdk" value="1.7" />
This option is not updated accordingly when the Project SDK is changed, see SCL-10085. If you have the other JDK (1.7 in my example) generally configured, no error will occur, but the Project SDK will silently be changed back. Otherwise, this error occurs.
The problem can easily be resolved by manually editing the value in ".idea/sbt.xml" to the right JDK version.
Same error also occurs when you try to do a refresh in "SBT tasks".
Open
Preferences -> Language & Frameworks -> Scala Compiler Server
Turn on
Run compile server (in external build mode)
Once you done with refreshing the project, turn it off again to enable hotswapping back when you change your code in the editor.
I had to open Settings -> Language & Frameworks -> Scala Compiler Server
Then set the JVM SDK there, which was <No SDK>.
This was in addition to setting the Project SDK in Project Structure -> Project.
See the screenshot here.
IntelliJ 13.1.6 > File > Project Structure > set Project SDK
I got the same problem after I delete Java1.6 and Java1.7 from Project Settings(with Java8 as default).
Finally I solve the problem by change SBT JVM config to Custom Java(Settings -> Build, Execution, Deployment -> Build Tools -> SBT).
For me the above suggestions did not help for some reason. However, I did figure out that under Project Defaults > Project Structure (Welcome screen) my default Project SDK was set to the Go SDK.
What worked for me was setting this default SDK to the Java JDK.
For me, I had selected the JDK in "Open Module Settings" > Module > Dependencies > Module SDK.
However, SBT was looking for JDK at project level which is set in "Open Module Settings" > Project > Project SDK as #michasm has pointed out above
The latest Nightlies of the Scala plugin change how the project JDK is set, which should solve this in most cases. Let me know if it still breaks on some cases.
This happened to me in a multi-language project when my primary module's Project SDK was Python and I was trying to add a secondary module that was JDK (importing an sbt project).
I had to temporarily switch the primary module's Project SDK to JDK in order to add the sbt module. I then had the ability to go back and change each module to the correct SDK.