tckuntz (3) [Avatar] Offline
#1
I was hoping to find sample code for Chapter 12 as I am running into some problems with a custom task based on that chapter. In short, I have created a custom jar with a Task and SubTask but get the following error message when trying to invoke the SubTask.

BUILD FAILED
file:c:/tpc/dist/build/ejb-build7.xml:354: Can't create a model element under flex. Make sure the jar file containing the corresponding subtask class is on the classpath specified in the <taskdef> that defined {2}.

I have tried the following...

1. Remove the jar to verify it is correctly found. This works because the taskdef throws an error regarding the "flex" task definition.

2. Remove the "model" element and add a checkClass() to the validateOptions() method of the task to verify that indeed the SubTask can be found.

3. Define a taskdef for "model" to test that it is being found and constructed. This works but throws a NPE, which I assume is due to the fact that XDoclet assumes it is a Task not a SubTask.

I can't think of any other options so I am including relevant info below in hopes that someone (namely one of the authors <g>smilie might have an idea.

Any help is appreciated.
Thanks - Tim


* Ant target contents

<taskdef >
name="flex"
classname="xdoclet.modules.flex.FlexTask"
classpathref="xdoclet.classpath"
/>

<flex destdir="${gen.src.dir}">
<fileset dir="${src.dir}">
<include name="com/tpc/model/domain/meetings/registration/*.java" />
</fileset>
<model />
</flex>

* xdoclet.xml

<?xml version="1.0" encoding="UTF-8"?>

<xdoclet-module>

<subtask >
name="model"
implementation-class="xdoclet.modules.flex.FlexModelSubTask"
parent-task-class="xdoclet.modules.flex.FlexTask" />

</xdoclet-module>

* xdoclet-flex-module.jar contents

meta-inf
Manifest.xml
xdoclet.xml
xdocletmodulesflex
FlexModelSubTask.class
FlexTask.class
xdocletmodulesflex esources
flex-asmodel.xdt

* FlexTask

public class FlexTask extends DocletTask {

public FlexTask() {
super();
}

public void validateOptions() {
super.validateOptions();
// redundant
checkClass("xdoclet.modules.flex.FlexModelSubTask");
}

}

* FlexModelSubTask

public class FlexModelSubTask extends TemplateSubTask {

private static String XDT_RESOURCE = "resources/flex-asmodel.xdt";

public FlexModelSubTask() {
setTemplateURL(getClass().getResource(FlexModelSubTask.XDT_RESOURCE));
setDestinationFile("{0}.as");
setHavingClassTag("flex.class");
}

protected void engineStarted() throws XDocletException {
System.out.println("Generating Flex ActionScript model for... " + getCurrentClass().getQualifiedName());
}

}
habuma (279) [Avatar] Offline
#2
Re: Chapter 12 - Custom Task Problem
I only have a few seconds to reply, so I'll take the quickest stab possible: I notice that when you list the contents of the JAR file that you don't include the paths for the .class files. Was that just to be brief or is it a mistake?

That's the only thing I see wrong at a glance...but as I said, I've got to run. Perhaps Norm can find something. Otherwise, I'll take another longer look at this later.
tckuntz (3) [Avatar] Offline
#3
Re: Chapter 12 - Custom Task Problem
Thanks Craig. The directory structure is there above the class names and was easy to see when I typed the message up. I didn't anticipate the formatting change.
orb (16) [Avatar] Offline
#4
Re: Chapter 12 - Custom Task Problem
Is your META-INF directory "meta-inf" or "META-INF". XDoclet cares that it is named appropriately...
tckuntz (3) [Avatar] Offline
#5
Re: Chapter 12 - Custom Task Problem
Beautiful... I had originally named the directory META-INF per your book but renamed it after opening some of the jar files that shipped with XDoclet. I used Winzip which displays all path info in lowercase. Examining the same files with the Jar utility revealed the actual case.

Good catch... thanks much. Also, nice job on the book.