ComminutyCommons Compilation Error: cannot find symbol

0
Hi Guys, I've just added the CommunityCommons module to my app and now I cannot buildit. I get the following error (even after cleaning down the deployment directory):   Buildfile: C:\Users\ateale\Documents\Mendix\PrimarkPSM-main\deployment\build_core.xml compile:     [javac] Compiling 367 source files to C:\Users\ateale\Documents\Mendix\PrimarkPSM-main\deployment\run\bin     [javac] C:\Users\ateale\Documents\Mendix\PrimarkPSM-main\javasource\communitycommons\actions\GetImageDimensions.java:37: error: cannot find symbol     [javac]         BufferedImage bimg = ImageIO.read(Core.getImage(getContext(), this.ImageParameter1.getMendixObject(), false));     [javac]                                                                           ^     [javac]   symbol: variable ImageParameter1     [javac] Note: Some input files use or override a deprecated API.     [javac] Note: Recompile with -Xlint:deprecation for details.     [javac] 1 error BUILD FAILED C:\Users\ateale\Documents\Mendix\PrimarkPSM-main\deployment\build_core.xml:25: Compile failed; see the compiler error output for details. Total time: 7 seconds   Does anyone know how to solve this?   Regards Adrian
asked
3 answers
2

I have experienced this error before. Sometimes when compiling the java code Mendix renames inputparameters of the java action, but does not update the actual code which refers to the inputparameter. 

 

This probably happens when there is somewhere else also a referral to an inputparameter with the same name or when an inputparameter has a reserved name (like index, length, etc.). 

 

It is not very apparent to me WHY this happens, but the fix is fairly easy. Dive into the Java action in which this error is occurring and check the inputparameter name versus the name the same parameter should have in the code. Update the name in the code, press F4 in the Modeler and rerun your project.

Hope this helps!

answered
1

This usually happens where there are two versions of the same jar file in the userlib. But I have run into this a few times with this exact java action. I just ended up deleting it in the modeler and deleting the java action in the project directory,

 

I think it has to do with this parameter

this.ImageParameter1.getMendixObject(), false))

I recently was exporting a module I created and kept running into compile errors when I was importing it into another project. During export, the parameter name was changed. Somehow "Parameter1" was added onto it, so my code in the java action wouldnt refer to the correct parameter. If this is a java action you need, try editing it and deleting the "Parameter1" part. 

answered
0

The "Cannot find symbol" errors generally occur when you try to reference an undeclared variable in your code. A "Cannot find symbol" error means that the compiler cannot do this. Your code appears to be referring to something that the compiler doesn't understand.

When your code is compiled, the compiler needs to work out what each and every identifier in your code means. As the compiler is going through the code it will find something and know what to do with it or not. Your Cannot find symbol error relates to the identifiers and means that Java cannot figure out what the "symbol" means.

The general causes for a Cannot find symbol error are things like:

  • Incorrect spelling.
  • Wrong case. Halo is different from halo.
  • Improper use of acceptable identifier values (letters, numbers, underscore, dollar sign), my-class is not the same as myclass.
  • No variable declaration or variable is outside of the scope you are referencing it in.
answered