I'm getting some very strange behavior here. Extracting the Authors
from the list is silently failing without throwing any exceptions. It
seems to be just skipping code.
Here's the method I have that sets the Authors of the
LibraryItemInfoData object:
public final void setAuthors( final List<Author> allAuthors )
{
getLogger().info( "Set Authors as list: " + allAuthors + ",
num authors = " +
allAuthors.size() );
try
{
Class allAuthorsClass = allAuthors.getClass();
getLogger().info( "allAuthors class = " +
allAuthorsClass );
getLogger().info( "allAuthors interfaces = " +
allAuthorsClass.getInterfaces() );
}
catch( Exception e )
{
System.out.println( "got exception trying to examine
allAuthors class." );
}
if( allAuthors.size() >= 1 )
{
getLogger().info( "clearing authors." );
authors.clear();
int numNewAuthors = allAuthors.size();
getLogger().info( "allAuthors size, numNewAuthors = " +
numNewAuthors );
for( int i = 0; i < numNewAuthors; i++ )
{
try
{
getLogger().info( "Getting author: " + i );
Author author = allAuthors.get( i );
getLogger().info( "Got author" );
System.out.println( "author is person = " +
author.isPerson() );
getLogger().info( "Making author data" );
try
{
AuthorData newAuthor = new AuthorData
( author );
System.out.println( "new author = " +
newAuthor );
authors.add( newAuthor );
}
catch( Exception e )
{
System.out.println(
"got exception trying to make new
AuthorData object: " + e );
}
}
catch( Exception e )
{
System.out.println(
"got exception trying to get author " + i +
": " + e );
}
}
getLogger().info( "authors list is now: " + authors );
}
}
As I said before, Author is an interface. I don't mind XFire sending
back a dynamic proxy because, I would think anyway, I can call the
standard getters on that to create a new implementation class
(AuthorData) instance based on the proxy. That's not working. Here's
the log output I'm getting:
2006-04-19 13:31:16,910 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <Set Authors as list:
[EMAIL PROTECTED], num authors = 1>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <allAuthors class =
class java.util.ArrayList>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <allAuthors interfaces
= [Ljava.lang.Class;@3d54d4>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <clearing authors.>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <allAuthors size,
numNewAuthors = 1>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <Getting author: 0>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <Got author>
2006-04-19 13:31:16,911 INFO
[edu.ucsc.whisper.core.LibraryItemInfoData] - <authors list is now: []>
You can see that as soon as I try to access a field of the proxy
Author instance, the entire loop just skips to the end where it
prints that the authors list is now []. No exception is logged. In
addition, trying to use an Iterator on the newAuthors list failed to
return any of the objects in the list, as did the Java 5 for( Author
author : allAuthors ) loop. I would expect this line would be
executed at least:
getLogger().info( "Making author data" );
I'm using xfire-all-1.1-beta-1.jar, and cglib 2.1_3 is in my project
as well (I'm assuming that's how the dynamic proxies are being created).
Is this a known issue? Or am I still doing something wrong?
Mark
On Apr 19, 2006, at 11:20 AM, Dan Diephouse wrote:
Mark Slater wrote:
As far as the Author type goes, it is an interface. The
implementation class is AuthorData. Could that be causing this
problem? Is there a way to tell XFire to create AuthorData
instances whenever it gets an Author inside a SOAP body, rather
than changing the method signatures? I actually tried to change
the method signatures, saw the WSDL update, but didn't get any
change in behavior; the authors were still not set.
Currently there isn't a way to do this. There is a JIRA for it
however:
http://jira.codehaus.org/browse/XFIRE-321
Right now XFire can only create a dynamic proxy which implements
the interface and it will use the interface to generate the WSDL.
- Dan
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com
http://netzooid.com/blog