History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: GROOVY-2948
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Paul King
Reporter: A
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
groovy

classloading weird issue

Created: 10/Jul/08 09:54 AM   Updated: 14/Jul/08 05:59 AM
Component/s: Ant integration
Affects Version/s: 1.5.6
Fix Version/s: 1.5.7, 1.6-beta-2

Time Tracking:
Not Specified

File Attachments: 1. Text File groovy_ant_fork.patch (10 kb)
2. File groovy_bug.groovy (2 kb)
3. XML File groovy_bug.xml (0.5 kb)


Testcase included: yes


 Description  « Hide
I have such thing working in our CI environment but couldn't figure out why is it not working when done from command line.

download http://anonsvn.jboss.org/repos/repository.jboss.org/maven2/jboss/jbossall-client/4.2.2.GA/jbossall-client-4.2.2.GA.jar to jbossall-client.jar

"groovy -cp jbossall-client.jar groovy_bug.groovy" works fine

"ant -f groovy_bug.xml" throws an exception although task's classpath is set and otherwise classes from jbossall-client.jar are resolved:
javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]

"ant -lib . -f groovy_bug.xml" works fine.



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
A - 11/Jul/08 02:18 AM
Ok, I figured it out. In our CI environment there is -Djava.ext.dirs defined so that's why it is working there. I hope in future groovy versions specifying classpath for the task itself will be sufficient.

Paul King - 11/Jul/08 07:49 PM
Glad to see your problem is fixed. In any case, this looks like a Java classloader issue not anything to do with Groovy per se.

A - 12/Jul/08 06:24 AM
No, the problem is not resolved! What I say with my comment is that I figured out why does it work in our CI environment as initially I was missing the -Djava.ext.dirs configuration option.

So currently I need to specify "ant -lib <some directory>" to be able to access the external libraries which is not always possible as these are generated during ant's execution.

A solution to this problem would be to make groovy task's classpath work like specifying -lib to ant.


Paul King - 12/Jul/08 07:23 AM
Yes, this will require us to support a fork="true" attribute to the groovy task.

Paul King - 13/Jul/08 03:44 AM
Here is a patch (against trunk) which provides a fork mode for groovy. It still needs more work but might help anyone stuck in a bind because of this issue.

Paul King - 14/Jul/08 05:59 AM
Resolved by adding a fork mode to the groovy ant task. It supports most of the attributes and subelements available for the java ant task.