Why does my REST API Extension compilation generate 'unable to resolve class' error?

marielle.spiteri's picture
Blog Categories: 

My REST API extension does not compile anymore. It used to work, it broke after I imported a workspace from an old Studio version into my current 7.7.5 Studio. My colleague got the same compilation error after he pulled changed from a remote Git server, to synchronize his local repository.

I see the messages generated in the Studio's console:

...[INFO] Scanning for projects...[INFO]                                                                      
[INFO] ------------------------------------------------------------------------
[INFO] Building CarWash REST API 1.0.0-SNAPSHOT[INFO] ------------------------------------------------------------------------[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ carWashRestAPI ---
[INFO] Deleting /home/wbates/opt/BonitaStudioSubscription-7.7.5/workspace/default/restAPIExtensions/carWashRestAPI/target[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ carWashRestAPI ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.[INFO] Copying 2 resources[INFO]
[INFO] --- maven-compiler-plugin:3.6.0:compile (default-compile) @ carWashRestAPI ---
[INFO] Changes detected - recompiling the module![INFO] Using Groovy-Eclipse compiler to compile both Java and Groovy files/home/wbates/opt/BonitaStudioSubscription-7.7.5/workspace/default/restAPIExtensions/carWashRestAPI/src/main/groovy/com/support/rest/api/Index.groovy: 18 Groovy:unable to resolve class com.support.bonita.model.WashingMachine
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :[INFO] -------------------------------------------------------------[ERROR] /home/wbates/opt/BonitaStudioSubscription-7.7.5/workspace/default/restAPIExtensions/carWashRestAPI/src/main/groovy/com/support/rest/api/Index.groovy:[18,33] 1\. ERROR in /home/wbates/opt/BonitaStudioSubscription-7.7.5/workspace/default/restAPIExtensions/carWashRestAPI/src/main/groovy/com/support/rest/api/Index.groovy (at line 18)import com.support.bonita.model.WashingMachine                                ^^^^^^^^^^^^^^Groovy:unable to resolve class com.support.bonita.model.WashingMachine[ERROR] Found 1 error and 0 warnings.[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE[INFO] ------------------------------------------------------------------------[INFO] Total time: 0.844 s
[INFO] Finished at: 2018-12-06T16:22:48+01:00[INFO] Final Memory: 17M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (default-compile) on project carWashRestAPI: Compilation failure: Compilation failure:[ERROR] /home/wbates/opt/BonitaStudioSubscription-7.7.5/workspace/default/restAPIExtensions/carWashRestAPI/src/main/groovy/com/support/rest/api/Index.groovy:[18,33] 1\.
ERROR in /home/wbates/opt/BonitaStudioSubscription-7.7.5/workspace/default/restAPIExtensions/carWashRestAPI/src/main/groovy/com/support/rest/api/Index.groovy (at line 18)
[ERROR] import com.support.bonita.model.WashingMachine
[ERROR] ^^^^^^^^^^^^^^
[ERROR] Groovy:unable to resolve class com.support.bonita.model.WashingMachine[ERROR][ERROR] Found 1 error and 0 warnings.
[ERROR] -> [Help 1][ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.[ERROR] Re-run Maven using the -X switch to enable full debug logging.[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureExceptionXA Process ID 3322 startedXA Process ID 3322 is working!...

It used to work and then it stopped working without explanation.

Why do you have this error?

This error happens when dealing with a BDM generated class. After having synchronized the local repository with the remote server the BDM definition is up-to-date but the classes need to be generated.

How to fix the problem?

Force the generation of new BDM classes

Use the procedure below:

  1. Click on Development in the menu bar
  2. Click on Business Data Model
  3. Click on Define
  4. Click on the Finish button
  5. Click on the OK button
Update the maven eclipse plugin's cache:

The Studio is based on the OSGI Eclipse platform. A maven eclipse plugin is used, and it is using caching.

There is the procedure below to refresh and update this plugin's cache:

  1. Click on Development in the menu bar
  2. Click REST API extension...
  3. Click on Open
  4. Select the one which does not compile
  5. Click on the Open button
  6. On the left, click in the REST API Extensions tab
  7. Press CTRL-A
  8. Right-Click
  9. Click Refresh

Continue with the procedure bellow:

  1. Rigth-Click on the left on the REST API extension involved
  2. Click on Maven
  3. Click Update Project...

  1. Tick the Force Update of Snapshots/Releases checkbox
  2. Click the OK button