Grails target folder doesn't appear to be on application's classpath

Posted by Kobi on Stack Overflow See other posts from Stack Overflow or by Kobi
Published on 2010-04-23T02:41:31Z Indexed on 2010/04/23 2:43 UTC
Read the original article Hit count: 207

Filed under:
|
|
|

I have a grails project with some additional java source files under src/java folder. When compiling/running the server, the files under that directory get compiled into the project's target folder, together with all other groovy/grails classes. So far so good.

However, when I try to load one of the java source files (from src/java) using reflection (Class.forName to be exact), a ClassNotFoundException gets thrown. What is peculiar about the whole thing is that if I copy that same class from project's target/ folder into the following location (on windows):

<myuser>\.grails\1.2.2\projects\<MyProjectName>\resources

then no exception gets thrown and the corresponding class is loaded fine. This seems to indicate to me that the integrated grails server only looks at classes within the user's dynamically generated project folder, and not the actual project's target folder.

Is my understanding correct? Is there a way to force grails to copy certain classfiles from target/ folder into the resources folder within the user dir? Is there a different way to load the classfiles using reflection? I was looking at using the grailsApplication's classloader but that didn't seem to work either. Any tips would be more than welcome. Thanks a lot in advance!

© Stack Overflow or respective owner

Related posts about java

Related posts about groovy