Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

ClassCastException running project in IntelliJ Idea 2016.1.1 #1

Closed
shendrix opened this issue Apr 14, 2016 · 7 comments
Closed

ClassCastException running project in IntelliJ Idea 2016.1.1 #1

shendrix opened this issue Apr 14, 2016 · 7 comments
Assignees

Comments

@shendrix
Copy link

I created a new project and when trying to run it, I receive the stack trace below. I am using:
IntelliJ 2016.1.1: Build #IU-145.597, built on March 29, 2016
JRE: 1.8.0_60-b27 x86
JVM: Java HotSpot(TM) Server VM by Oracle Corporation

Error:Internal error: (java.util.concurrent.ExecutionException) java.lang.ClassCastException: org.jetbrains.jps.model.impl.JpsDummyElementImpl cannot be cast to org.jetbrains.jps.model.JpsSimpleElement
java.util.concurrent.ExecutionException: java.lang.ClassCastException: org.jetbrains.jps.model.impl.JpsDummyElementImpl cannot be cast to org.jetbrains.jps.model.JpsSimpleElement
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadModules(JpsProjectLoader.java:281)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadModules(JpsProjectLoader.java:238)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadFromDirectory(JpsProjectLoader.java:124)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadProject(JpsProjectLoader.java:100)
    at org.jetbrains.jps.model.serialization.impl.JpsSerializationManagerImpl.loadModel(JpsSerializationManagerImpl.java:41)
    at org.jetbrains.jps.cmdline.JpsModelLoaderImpl.loadModel(JpsModelLoaderImpl.java:45)
    at org.jetbrains.jps.cmdline.BuildRunner.load(BuildRunner.java:78)
    at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:266)
    at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:125)
    at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:232)
    at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:44)
    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)
Caused by: java.lang.ClassCastException: org.jetbrains.jps.model.impl.JpsDummyElementImpl cannot be cast to org.jetbrains.jps.model.JpsSimpleElement
    at io.github.liias.monkey.jps.model.JpsMonkeyModelSerializerExtension.loadRootModel(JpsMonkeyModelSerializerExtension.java:23)
    at org.jetbrains.jps.model.serialization.module.JpsModuleRootModelSerializer.loadRootModel(JpsModuleRootModelSerializer.java:145)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.loadModule(JpsProjectLoader.java:310)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader.access$000(JpsProjectLoader.java:62)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader$2.call(JpsProjectLoader.java:276)
    at org.jetbrains.jps.model.serialization.JpsProjectLoader$2.call(JpsProjectLoader.java:273)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at com.intellij.util.concurrency.BoundedTaskExecutor$2.run(BoundedTaskExecutor.java:187)
    ... 6 more
@liias
Copy link
Owner

liias commented Apr 14, 2016

Hi,
Thanks for reporting the issue.

This probably happens when the plugin is trying to build a module, which is not "Connect IQ" module.
You can look at project structure (cltr+alt+shift+s, damn that's a lot of keys) and in there module structure
and compare it to this screenshot https://plugins.jetbrains.com/files/8253/screenshot_15730.png if there any modules which don't have the IQ icon in front of the name.

There is no simple way to change module type in IntelliJ, but you can recreate the module by removing the module from project (there's a delete button in that same project structure dialog) and then importing it again and selecting "create module from existing sources". If IDEA will ask you if you want to overwrite the old model say yes.

I did some fixes lately to importing from existing sources, which are not yet released, so I'm not quite sure how well the latest released plugin handles this.

After importing, make sure to mark sources and resources directories in that dialog (sources will be automatically marked in the future release, but resources not).

Also you need to select the device to which the building is done.

Unfortunately you currently need to set target device in module settings and in run configuration. As one is used for simply building the module without running it (I guess I should enhance this process that when running the building device will be set to whatever is used in that run configuration).

I'll exclude non-Connect IQ modules from building by the plugin to avoid the error.

@shendrix
Copy link
Author

Hi,
Thanks for the quick response. I had another (non-IQ) module in the project. Once I removed that, the error went away

@shendrix
Copy link
Author

Two other things I had to do:

  1. I had to change the project SDK to a Java SDK (it had defaulted to the IQ SDK).
  2. I had to make sure I used a Java 8 SDK (failed to work with Java 7)

@liias
Copy link
Owner

liias commented Apr 14, 2016

Can you tell me what error you get when you use IQ SDK as project SDK?

@shendrix
Copy link
Author

The error was: Error:Module 'mymodule' production: java.lang.RuntimeException: could not find JDK

@liias
Copy link
Owner

liias commented Apr 14, 2016

Alright, thanks.

This is probably the case that if JAVA_HOME environment variable is not set, it tries to use that one instead. I have had similar issue reported by another user as well and might do something about it.

So another workaround at the moment is to set JAVA_HOME to JDK home. But if using JDK as project SDK (while still using IQ SDK as module SDK) helps, then that's fine too.

liias added a commit that referenced this issue Apr 14, 2016
@liias
Copy link
Owner

liias commented Apr 15, 2016

Both issues should be fixed with 0.2.2 release now.

@liias liias closed this as completed Apr 15, 2016
@liias liias self-assigned this Apr 15, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants