[ http://jira.codehaus.org/browse/JIBX-105?page=comments#action_62686 ] 

Nathan Egge commented on JIBX-105:
----------------------------------

I figured out what is causing the problem.  Hibernate instruments the domain 
objects (in this case the Survey and Locale objects) and goes through replacing 
references to member variables with proxy references to a representation of the 
database (since it is a level 1 cache).

The problem is that the marshalling methods which are generated by 
org.jibx.binding.ant.CompileTask are final, and the runtime instrumenting that 
hibernate does cannot modify them.  I was able to fix this by changing line 76 
of org/jibx/binding/classes/MarshalBuilder.java from:

mf, (mf == cf) ? Constants.ACC_PUBLIC | Constants.ACC_FINAL :

to

mf, (mf == cf) ? Constants.ACC_PUBLIC :

and then rerunning the jibx-test against my modified jibx libraries.

I really don't understand the sense behind methods that are created via byte 
code instrumentation being final,  but I don't see any harm in going through 
and removing the final keyword from all generated methods.

Incidently, doing this also fixes JIBX-106.

> Marshalling throws null value exception when value not null
> -----------------------------------------------------------
>
>          Key: JIBX-105
>          URL: http://jira.codehaus.org/browse/JIBX-105
>      Project: JiBX
>         Type: Bug

>   Components: core
>     Versions: JiBX 1.1, JiBX 1.0.1
>  Environment: blackdown-jdk-1.4.2.03
>     Reporter: Nathan Egge
>     Assignee: Dennis Sosnoski
>  Attachments: jibx-test.tar.gz
>
>
> I have a project where I have a Survey object that contains a Set of Locale 
> objects.  These are managed by hibernate and the collection is lazy loaded.  
> I have the following binding definition:
> <binding>
>   <mapping name="survey" class="model.Survey">
>     <value name="name" field="name"/>
>     <collection name="locales" field="locales" 
> factory="model.Survey.hashSetFactory">
>       <structure name="locale" type="model.Locale" pre-get="debug">
>         <value name="language" field="language"/>
>       </structure>
>     </collection>
>   </mapping>
> </binding>
> I have a JUnit test that attempts to load the Survey object and serialize it 
> using JiBX.  When it runs here is the output:
> test-module:
>      [echo] Testing domain...
>     [mkdir] Created dir: /home/nathan/svn/jibx-test/build/test/data
>     [junit] DEBUG --- Locale.debug()V(27) | id=1
>     [junit] DEBUG --- Locale.debug()V(28) | language=en
>     [junit] DEBUG --- Locale.debug()V(29) | country=null
>     [junit] DEBUG --- Locale.debug()V(30) | variant=null
>     [junit] DEBUG --- Locale.debug()V(31) | description=English
>     [junit] Testsuite: test.JibxTest
>     [junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.531 sec
>     [junit] ------------- Standard Error -----------------
>     [junit] org.jibx.runtime.JiBXException: null value for element "language" 
> from object of type model.Locale$$EnhancerByCGLIB$$9405c66f
>     [junit]     at 
> org.jibx.runtime.impl.MarshallingContext.element(ILjava/lang/String;Ljava/lang/String;)Lorg/jibx/runtime/impl/MarshallingContext;(Unknown
>  Source)
>     [junit]     at 
> model.Locale.JiBX_binding_marshal_2_0(Lorg/jibx/runtime/impl/MarshallingContext;)V(Locale.java:???)
>     [junit]     at 
> model.JiBX_MungeAdapter.JiBX_binding_marshal_1_0(Ljava/util/Set;Lorg/jibx/runtime/impl/MarshallingContext;)V(:???)
>     [junit]     at 
> model.Survey.JiBX_binding_marshal_2_0(Lorg/jibx/runtime/impl/MarshallingContext;)V(Survey.java:???)
>     [junit]     at 
> model.JiBX_bindingSurvey_access.marshal(Ljava/lang/Object;Lorg/jibx/runtime/IMarshallingContext;)V(:???)
>     [junit]     at 
> model.Survey.marshal(Lorg/jibx/runtime/IMarshallingContext;)V(Survey.java:???)
>     [junit]     at 
> org.jibx.runtime.impl.MarshallingContext.marshalRoot(Ljava/lang/Object;)V(Unknown
>  Source)
>     [junit]     at 
> org.jibx.runtime.impl.MarshallingContext.marshalDocument(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Boolean;Ljava/io/OutputStream;)V(Unknown
>  Source)
>     [junit]     at test.JibxTest.testJibx()V(JibxTest.java:27)
>     [junit]     at 
> jrockit.reflect.NativeMethodInvoker.invoke0(Ljava/lang/Object;ILjava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown
>  Source)
>     [junit]     at 
> jrockit.reflect.NativeMethodInvoker.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown
>  Source)
>     [junit]     at 
> jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;(Unknown
>  Source)
>     [junit]     at 
> java.lang.reflect.Method.invoke(Ljava/lang/Object;[Ljava/lang/Object;I)Ljava/lang/Object;(Unknown
>  Source)
>     [junit]     at junit.framework.TestCase.runTest()V(TestCase.java:154)
>     [junit]     at junit.framework.TestCase.runBare()V(TestCase.java:127)
>     [junit]     at 
> junit.framework.TestResult$1.protect()V(TestResult.java:106)
>     [junit]     at 
> junit.framework.TestResult.runProtected(Ljunit/framework/Test;Ljunit/framework/Protectable;)V(TestResult.java:124)
>     [junit]     at 
> junit.framework.TestResult.run(Ljunit/framework/TestCase;)V(TestResult.java:109)
>     [junit]     at 
> junit.framework.TestCase.run(Ljunit/framework/TestResult;)V(TestCase.java:118)
>     [junit]     at 
> junit.framework.TestSuite.runTest(Ljunit/framework/Test;Ljunit/framework/TestResult;)V(TestSuite.java:208)
>     [junit]     at 
> junit.framework.TestSuite.run(Ljunit/framework/TestResult;)V(TestSuite.java:203)
>     [junit]     at 
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run()V(JUnitTestRunner.java:289)
>     [junit]     at 
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(Lorg/apache/tools/ant/taskdefs/optional/junit/JUnitTest;ZZZZLjava/util/Properties;)I(JUnitTestRunner.java:656)
>     [junit]     at 
> org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main([Ljava/lang/String;)V(JUnitTestRunner.java:558)
>     [junit] ------------- ---------------- ---------------
> I'm not sure what exactly is going on, but when i disassembled the modified 
> Locale.class using Jad v1.5.8e, this is what the 
> model.Locale.JiBX_binding_marshal_2_0 method looked like:
>     public final void JiBX_binding_marshal_2_0(MarshallingContext arg1)
>         throws JiBXException
>     {
>         debug();
>         arg1.pushObject(this);
>         arg1.element(0, "language", language);
>         arg1.popObject();
>         return;
>     }
> Somehow its printing out the fields of the Locale object, and then trying to 
> add the language field to the MarshallingContext and it becomes null before 
> the call to element().
> I have created a project that demonstrates this behavior.  I will tar it up 
> and attach it.h

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
jibx-devs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-devs

Reply via email to