cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Lundquist ...@wrinkledog.com>
Subject Hibernate + Flowscript = trouble? Help!
Date Wed, 22 Jun 2005 05:40:21 GMT
Hi all,

I got a really nasty bug goin' on here.

An object percolating up into flow from my model layer was retrieved by 
Hibernate, and I'm getting the old "TypeError: xxxx is not a 
function.", and of course it is a public function in a freshly cleaned 
and compiled class in a cold-started Jetty instance (i.e. my usual 
dumb-@$$ reasons for this error already checked :-).

I have my flowscript print the object, and it's of the type I expect:

	us.rocketsurgery.ecommerce.creditcards.CreditCardPayment@2eda5e

...or so it would seem.  But if I say this:

    print (order.payment.getClass().getName());

...then I get this:

	us.rocketsurgery.ecommerce.payment.Payment$$EnhancerByCGLIB$$309df4c3

OK, now maybe we are getting somewhere — Payment is the abstract base 
class of CreditCardPayment, and I've got a CGLIB proxy from Hibernate.  
I guess Rhino has to reflect on the object to wrap it, and this is 
screwing it up.

This:

	 print (order.payment.process);			// a method from Payment
      print (order.payment.getCreditCard);	// a method from 
CreditCardPayment


...gets this:

	function process() {/*
		void process()
	*/}

	undefined

So Rhino is not able to figure out that this is really a 
CreditCardPayment, I guess.

I figured that if I rummaged around in Rhino, I just might find 
something to help me.  I'm a total babe-in-the-woods here, I started 
with a "jar tf" on the Rhino jar to look for promising Javadocs to 
Google.  "Hmm, org.mozilla.javascript.NativeJavaObject, that looks 
hopeful, at least it might start me in the right direction... hey, it 
has this static method coerceType, that looks like just what I need!"

SooOOOOooo, I tried this:

	var creditCardPaymentClass =
             java.lang.Class.forName 
("us.rocketsurgery.ecommerce.creditcards.CreditCardPayment");
	.
	.
	.
	if (order.payment.type == PaymentMethod.CREDIT_CARD) {         		var 
ccPayment = NativeJavaObject.coerceType (
                                         creditCardPaymentClass,
                               		 	order.payment
                                		);
		.
		.


and.... pfffft.  I guess it did sound too good to be true.  I get:

	Cannot convert 
us.rocketsurgery.ecommerce.creditcards.CreditCardPayment@d4446b to 
	us.rocketsurgery.ecommerce.creditcards.CreditCardPayment

Well... shoot and phooey!!!  I'm stuck and out of ideas.  Has anybody 
else ever run into anything like this, or have any ideas what I might 
try next?

Grumble, grumble, time for bed...
—ml—

P.S.  Oh yeah, I tried setting 
hibernate.cglib.use_reflection_optimizer=false.  Didn't help.

Mime
View raw message