2

I'm working on a Griffon app, using IntelliJ, and I'm trying to use the dcm4che project libraries. I've managed to get IntelliJ's code editor to stop complaining about missing classes, but when I go to run the Griffon app, the compiler goes down in flames, complaining that it is unable to resolve class DicomInputStream, etc.

I'm not doing anything fancy. All I'm doing is trying to include a few simple jar files, but for whatever reason, things are not working correctly.

I admit, I'm not particularly well versed in dealing with classpath issues, and I've only been using IntelliJ for a little while, and Griffon / Groovy for even less time, but I'm completely stumped.

Here's the set of import statements that fail:

import org.dcm4che2.io.DicomInputStream
import org.dcm4che2.data.DicomObject
import org.dcm4che2.data.DicomElement

And this is the set of error messages I get in the IntelliJ console when I try to run or debug the app:

Base Directory: C:\Users\[REDACTED]\MyApp\MyAppClient
Resolving dependencies...
Dependencies resolved in 698ms.
Running script C:\Program Files (x86)\Griffon\Griffon-0.9.4\scripts\RunApp.groovy
Environment set to development
 [griffonc] Compiling 32 source files to C:\Users\[REDACTED]\.griffon\0.9.4\projects\MyApp\classes
 [griffonc] org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
 [griffonc] C:\Users\[REDACTED]\MyApp\MyAppClient\griffon-app\controllers\myappclient\SelectRootController.groovy: 9: unable to resolve class org.dcm4che2.data.DicomElement
 [griffonc]  @ line 9, column 1.
 [griffonc]    import org.dcm4che2.data.DicomElement
 [griffonc]    ^
 [griffonc] 
 [griffonc] C:\Users\[REDACTED]\MyApp\MyAppClient\griffon-app\controllers\myappclient\SelectRootController.groovy: 7: unable to resolve class org.dcm4che2.io.DicomInputStream
 [griffonc]  @ line 7, column 1.
 [griffonc]    import org.dcm4che2.io.DicomInputStream
 [griffonc]    ^
 [griffonc] 
 [griffonc] C:\Users\[REDACTED]\MyApp\MyAppClient\griffon-app\controllers\myappclient\SelectRootController.groovy: 8: unable to resolve class org.dcm4che2.data.DicomObject
 [griffonc]  @ line 8, column 1.
 [griffonc]    import org.dcm4che2.data.DicomObject
 [griffonc]    ^
 [griffonc] 
 [griffonc] 3 errors
Compilation error: Compilation Failed

To install the dcm4che libraries, I did the following:

  1. Download the library binaries (the -bin zip) and unpack the zip to MyApp\MyAppClient\lib\dcm4che-2.0.25-bin
  2. In the Project Structure dialog, under Modules->MyAppClient, under the Dependencies tab, I click "Add" and select the folder: MyAppClient\lib\dcm4che-2.0.25-bin\dcm4che-2.0.25\lib

At this point, the code editor stops complaining about not being able to find and resolve the classes, but when I run or debug the application, I get the compilation errors. Everything works just fine without importing those classes (and the code that uses them).

What can I do to resolve this? What other info would be helpful to figure out what is going on?

CharlesB
  • 86,532
  • 28
  • 194
  • 218
cdeszaq
  • 30,869
  • 25
  • 117
  • 173
  • How exactly did you tell IDEA where your dependencies are? AFAIK the orthodox way is to either put them into lib directory, or use a special DSL to point to them via Maven ids. – Peter Gromov Dec 07 '11 at 19:19
  • @PeterGromov, I added a description of how I added the libraries. Based on the console output with and without those imports, the Java call isn't changing at all (like, to add the directory to the classpath) – cdeszaq Dec 07 '11 at 19:48
  • Please try putting the jar directly under the MyAppClient\lib. – Peter Gromov Dec 07 '11 at 20:01
  • @PeterGromov, Putting all of the jar files in the `lib` directory works, but if I put them inside any directory therein, like `lib/dcm4che/`, the IDE can find them, no problem, but Griffon cannot. Is there something that can be done to fix this? I'd really hate to have to have _all_ of my jar files in one massive directory with no organization, especially when multiple projects need the same things. – cdeszaq Dec 07 '11 at 20:19
  • 1
    That's how Griffon works, sorry. You could try managing dependencies via DSL (http://griffon.codehaus.org/guide/0.9.4/guide/3.%20Configuration.html#3.4%20Dependency%20Resolution) but be aware that IDEA doesn't currently support that (http://youtrack.jetbrains.net/issue/IDEABKL-6134), and you'll have to manage the module dependencies manually. – Peter Gromov Dec 07 '11 at 20:23

1 Answers1

4

As Peter suggests, either you configure the library as a dependency using the dependency DSL (if it's available from a maven or ivy repo) or place it inside MyApp/lib (no additional sub directories). Those are the conventions set by Griffon.

Andres Almiray
  • 3,236
  • 18
  • 28
  • It would be _great_ if Griffon could more easily handle having more organization in the `MyApp/lib` directory. – cdeszaq Dec 20 '11 at 14:04
  • That's why we have the dependency DSL in the first place. However we might supported nested dependencies inside $app/lib after Griffon goes 1.0. – Andres Almiray Dec 20 '11 at 18:54