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

Key: XFIRE-806
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dan Diephouse
Reporter: Geert Engels
Votes: 0
Watchers: 0
Operations

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

wsgen ClassCastException from JPrimitiveType to JClass

Created: 15/Dec/06 07:12 AM   Updated: 13/Mar/07 01:55 PM
Component/s: Generator
Affects Version/s: 1.2.3
Fix Version/s: 1.2.5

Time Tracking:
Not Specified

Environment: Windows, Ant

Testcase included: yes


 Description  « Hide
Using Ant wsgen task from xfire 1.2.3 against WSDL from https://adwords.google.com/api/adwords/v8/CampaignService?wsdl I get:

[wsgen] 15-Dec-2006 09:20:04 org.codehaus.xfire.gen.Wsdl11Generator generate
[wsgen] INFO: Generating code for WSDL at file:/c:/work/workspace/bcp/src/etc/wsdl/ggl/CampaignService.wsdl with a ba
e URI of file:/c:/work/workspace/bcp/src/etc/wsdl/ggl/CampaignService.wsdl
[wsgen] 15-Dec-2006 09:20:04 org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator generate
[wsgen] INFO: Creating class com.teracode.bcp.api.ggl.CampaignInterface

BUILD FAILED
C:\work\workspace\bcp\build\build.xml:72: org.codehaus.xfire.gen.GenerationException: Could not find holder type.

This seems to be the same as question posted on Nov 2nd here http://www.mail-archive.com/user@xfire.codehaus.org/msg01259.html to which there never was a reply.

Running the Ant task through a debugger, I can intercept an embedded ClassCastException, which originates at line org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator.java:252.

The code there is as follows:

protected JType getHolderType(GenerationContext context,MessagePartInfo part)
throws GenerationException
{
JType genericType = context.getSchemaGenerator().getType(context, part.getName(), part.getSchemaType().getSchemaType());

try { JClass holder = context.getCodeModel().ref("javax.xml.ws.Holder"); holder = holder.narrow((JClass) genericType); /* THIS IS WHERE THE CLASSCASTEXCEPTION OCCURS */ return holder; } catch (Exception e) { throw new GenerationException("Could not find holder type.", e); }
}

The MessagePartInfo, when the ClassCast is thrown, contains a schemaType which stringifies to "org.codehaus.xfire.aegis.type.basic.ObjectType[class=<null>,
QName={https://adwords.google.com/api/adwords/v8}responseTime]".

The ClassCastException is from JPrimitiveType to JClass.

Anybody know how to get Xfire wsgen to work with this WSDL? All others from WSDLs from Google AdWords API, not only this service but all others, and not only v8 but v7 and v6 as well, fail in the same way.

It's easy to reproduce, using a testcase as per below:

import junit.framework.TestCase;

public class WsGenTest extends TestCase {

public void testIt() throws Exception {
WsGenTask task = new WsGenTask();
task.setOutputDirectory("C:/EXT");
task.setWsdl("https://adwords.google.com/api/adwords/v8/CampaignService?wsdl");
task.setPackage("blah");
task.setOverwrite(true);
task.setGenerateServerStubs(false);
//task.setCaseSensitive(false);
//task.setDefaultexcludes(false);
try { task.execute(); } catch( Throwable t ) { t.printStackTrace(); fail(t.toString()); }
}

}



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Geert Engels - 13/Jan/07 07:26 AM

This is still an issue in XFire 1.2.4, BTW.

I worked around it by means of the following. In org.codehaus.xfire.gen.jsr181.AbstractServiceGenerator, around line 252, add the an instanceof check for JClass, like this:

try {
JClass holder = context.getCodeModel().ref("javax.xml.ws.Holder");
if( genericType instanceof JClass ) { holder = holder.narrow((JClass) genericType); }
return holder;
} catch (Exception e) { throw new GenerationException("Could not find holder type.", e); }

That works for me, for now.


Dan Diephouse - 13/Jan/07 12:57 PM
Sorry we missed this for 1.2.4 Scheduling for 1.2.5 so we don't forget. Thanks for the insights!

Dan Diephouse - 13/Mar/07 01:55 PM
Fixed this issue in SVN. Thanks!