Hi Ralf!
I have revision after bug 1342 (proxy) checked out. set proxy property
and it runs super!
Great! Thanks!
Jubel, jubel, freu, freu! :)
Regards
Jozef
On 10/18/07, *Ralf Joachim* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi Jozef,
the new featur is disabled by default. Take a look at following part of
the release notes which explains the details about using proxy
detection.
<h3>Added special processing of proxied classes</h3>
<p>Objects that were lazy loaded from a persistence
layer often are
wrapped by dynamic proxies. This usually happens by
extending the
original class. In this case a call to getClass()
does not return
the original call but the proxy instead. As the
class respectively
its name is used to lookup class mapping or
ClassDescriptor of any
class to marshal, Castor fail to find the right
one.
The result is
that the object gets introspected and the XML
document produced does
not look as expected. Even if you do not use
ClassDescriptors
generated by Castor's code generator or a mapping
file as you want
objects to get introspected, the resulting XML
document is crap. The
problem here is, that introspection not only finds
the properties of
your object but also those of the proxy which also
get marshalled.</p>
<p>The solution to all of this problems is a new
property in castor.properties
file. It allows you to specify a list of interfaces
that such proxied
objects implement. If your object implements one of
these interfaces
Castor will not use the class itself but its
superclass at introspection
or to find class mappings and ClassDescriptors.</p>
<code-panel>
# Property specifying whether or not to search for an proxy interface at
marshalling.
# If property is not empty the objects to be marshalled will be searched
if they
# implement one of the given interface names. If the interface is
implemented the
# superclass will be marshalled instead of the class itself.
#
org.exolab.castor.xml.proxyInterfaces=\
net.sf.cglib.proxy.Factory , \
org.hibernate.proxy.HibernateProxy</code-panel>
<p>Be aware that no proxy interfaces are defined by
default as the interface
search slightly decreases marshalling
performance.</p>
Regards
Ralf
Jozef Kubov schrieb:
> Hallo Werner!
>
> I was tried to use svn snapshot, but with no results. Am I doing
> somthing worng? I chcked out trunk directoy and run ant task
> "jar.all"... Can you look my last post? There is all in.
>
> what does you mean under SVN Head?
>
> Thank for your help.
>
> Schoenen Gruss!
>
> Jozef
>
> On 10/16/07, *Jozef Kubov* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>> wrote:
>
> Hello!
>
> So I am using spring for loading castor mapping files.
>
> this is my spring config:
>
/-----------------------------------------------------------------------------------
>
> <bean id="MyResolver"
>
class="com.ibs.rdc.util.castor.MyCastorResolverFactoryBean">
> <property name="mappingLocations">
> <list>
> <value>
> /WEB-INF/mapping/attachment- mapping.xml
> </value>
> <value>
> /WEB-INF/mapping/attachmentOriginator-
mapping.xml
> </value>
> ..... many ....
> </list>
> </property>
> </bean>
>
>
> <bean id="DefaultUnmarshaller"
>
class="org.castor.spring.xml.CastorUnmarshallerFactoryBean">
> <property name="resolver">
> <ref local="MyResolver" />
> </property>
> </bean>
>
> <bean id="DefaultMarshaller"
> class="
org.castor.spring.xml.CastorMarshallerFactoryBean">
> <property name="resolver">
> <ref local="MyResolver" />
> </property>
> </bean>
>
> <bean id="MarshallerHelper"
> class="com.ibs.rdc.util.castor.MarshallerHelper">
> <constructor-arg>
> <ref bean="DefaultMarshaller" />
> </constructor-arg>
> </bean>
>
> <bean id="MarshallerFacade"
> class=" com.ibs.rdc.util.castor.MarshallerFacade">
> <property name="unmarshaller">
> <ref local="DefaultUnmarshaller" />
> </property>
> <property name="helper">
> <ref local="MarshallerHelper" />
> </property>
> </bean>
>
> <bean id="MarshallerManager"
> class="com.ibs.rdc.util.castor.MarshallerManager">
> <property name="marshallerFacade"
ref="MarshallerFacade" />
> </bean>
>
>
/--------------------------------------------------------------------------------------------
> this is class MyCastorResolverFactoryBean
>
> public class MyCastorResolverFactoryBean extends
> CastorResolverFactoryBean implements FactoryBean,
InitializingBean {
>
> /**
> * Spring resource defining Castor properties
> */
> private Properties castorProperties;
>
> /**
> * Spring resource defining mapping file locations
> */
> private List mappingLocations;
>
> /**
> * XMlClassDescriptorResolver interface
> */
> private XMLClassDescriptorResolver resolver;
>
> /**
> * [EMAIL PROTECTED]
> *
> * @see
>
org.springframework.beans.factory.InitializingBean#afterPropertiesSet ()
> */
> @Override
> public void afterPropertiesSet() throws Exception {
> this.resolver = (XMLClassDescriptorResolver)
> ClassDescriptorResolverFactory
> .createClassDescriptorResolver( BindingType.XML);
>
> String mappingLocation = null;
> if (mappingLocations != null &&
mappingLocations.size() > 0) {
> Iterator iter = mappingLocations.iterator();
> try {
> Mapping mapping = new Mapping();
> while (iter.hasNext()) {
> mappingLocation = ((String)
iter.next()).trim();
> RDCLogger.getLogger().info("Loading: " +
> mappingLocation);
> mapping.loadMapping(new
> InputSource(SpringUtils.getInputStream (mappingLocation)));
> }
> Resource resource =
> SpringUtils.getWebApplicationContext().getResource("/");
> URL url = resource.getURL ();
> String path = url.toExternalForm() +
> Constants.MAPPING_FILE_LOACTION_PREFIX;
> mapping.setBaseURL(path);
>
> MappingUnmarshaller mappingUnmarshaller = new
> MappingUnmarshaller();
> MappingLoader loader =
> mappingUnmarshaller.getMappingLoader(mapping, BindingType.XML);
>
> this.resolver.setMappingLoader (loader);
> } catch (MappingException e) {
> RDCLogger.logException(e);
> throw e;
> }
> }
> }
>
> /**
> * [EMAIL PROTECTED]
> *
> * @see
org.springframework.beans.factory.FactoryBean#getObject()
> */
> public Object getObject() throws Exception {
> return this.resolver;
> }
>
> /**
> * [EMAIL PROTECTED]
> *
> * @see
> org.springframework.beans.factory.FactoryBean#getObjectType ()
> */
> public Class getObjectType() {
> if (this.resolver == null) {
> return ClassDescriptorResolver.class;
> }
>
> return this.resolver.getClass();
> }
>
> /**
> * [EMAIL PROTECTED]
> *
> * @see
org.springframework.beans.factory.FactoryBean#isSingleton()
> */
> public boolean isSingleton() {
> return true;
> }
>
> public void setCastorProperties(Properties
castorProperties) {
> this.castorProperties = castorProperties;
> }
>
> /**
> * Sets a collection of mapping (file) locations.
> *
> * @param mappingLocations
> * A collection of mapping (file) locations.
> */
> public void setMappingLocations(List mappingLocations) {
> this.mappingLocations = mappingLocations;
> }
>
> }
> //
>
------------------------------------------------------------------------------------
>
>
> when i am using last release castor 1.1.2.1 <http://1.1.2.1>
<http://1.1.2.1> all run
> good, but i become output with
> <hibernate-lazy-initializer>....</...> tag.
>
> I have tried to copy snapshot from svn, I have checked out a
trunk
> directory and then run ant task " jar.all". Then i have taken
castor
> 1.1.2.1 <http://1.1.2.1> <http://1.1.2.1> from "dist"
directory and involved in my
> project instead last stable release.
>
> biut it does not work. i become this warning:
>
> 14:12:12,356 INFO [STDOUT] 14:12:12,356 [http-127.0.0.1-8080-2]
> WARN castor.xml.XMLMappingLoader : Internal context or class
> descriptor resolver within are not valid
>
> and then an exception is thrown:
>
> org.springframework.beans.factory.BeanCreationException : Error
> creating bean with name 'MyResolver' defined in class path
resource
> [ castor-mapping.xml]: Invocation of init method failed; nested
> exception is java.lang.IllegalStateException: Internal context or
> class descriptor resolver within are not valid
>
> i have no idea.
>
> thanks for your help!
>
>
>
>
>
> On 10/16/07, *Ralf Joachim* < [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>> wrote:
>
> Hi Jozef,
>
> see my comments inline.
>
> Jozef Kubov schrieb:
> > I have one more question...
> >
> > If you look on the mapping files and output. For
example the
> Language
> > object has additional tags/attributtes after marshalling
> > <hibernate-lazy-...></..>. But why object ProcessType
has no such
> > attribute? This object is hibernate pojo too.
>
> When Castor is not able to find a mapping for the class to
> marshal it
> uses introspection to find the properties to marshal. This
> causes Castor
> to also find methods of the proxy in addition to those of the
> proxied
> object. With SVN HEAD this additional properties should also
> disapear.
>
> > I can't now exactly remember, but an the beginnig i
have used only
> > castor a i think there wasn't such problem with
hibernate pojos
> > marshalling... But later I make a decision to load
mapping with
> > castor-spring. Can be this a reason why i have such
additional
> > attributes in my output?
> >
> > On the other side, I made changes in hibernate
transaction
> handlig and
> > lazy loading. so this can be reason too.
>
> Lazy loading is the point that makes hibernate use proxies.
>
> > can you tell me pls when is next release of castor
planned?
> >
> > thaks!
> >
> > jozef
> >
> > On 10/15/07, *Jozef Kubov* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>>
> > <mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>>> wrote:
> >
> > Great! Thanks!
> >
> > And when will be next release?
> >
> >
> >
> >
> > On 10/15/07, *Werner Guttmann* <
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
> <mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
> > <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>
> <mailto: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>>> wrote:
> >
> > This has been fixed already, and will be
shipped with
> the next
> > release.
> > If you are intersted to get yourself acquainted
with this,
> > please feel
> > free to look at the snapshot releases for 1.1.3.
> >
> > Werner
> >
> > Jozef Kubov wrote:
> > > Hello!
> > >
> > > I have a following problem. I want to marshall
> hibernate pojo
> > into xml.
> > >
> > > this is my castor mapping files:
> > >
> > > processType object
> >
> > /----------------------------------------------------------
> > > <?xml version=" 1.0" encoding="UTF-8"?>
> > > <mapping>
> > >
> > >
> > > <class name="com.ibs.rdc.conf.bo.ProcessType"
> > auto-complete="false">
> > > <description>Default mapping for class
> > > com.ibs.rdc.conf.bo.ProcessType </description>
> > > <map-to xml="processType"/>
> > > <field name="id" type="integer"
> required="false"
> > direct="false"
> > > transient="false">
> > > <bind-xml name="id" node="element"
> reference="false"/>
> > > </field>
> > > <field name="isNonAutomatic"
type="boolean"
> > required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="isNonAutomatic"
> node="element"
> > > reference="false"/>
> > > </field>
> > > <field name="tolerance" type="
> > com.ibs.rdc.conf.bo.Tolerance"
> > > required="false" direct="false"
> transient="false">
> > > <bind-xml name="tolerance"
node="element"
> > reference="false"/>
> > > </field>
> > > <field name="processTypeId"
type="string"
> required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="processTypeId"
node="element"
> > > reference="false"/>
> > > </field>
> > > <field name="description"
> > >
> type="com.ibs.rdc.conf.bo.ProcessTypeDescription"
> > > required="false" direct="false"
> transient="false"
> > > collection="set">
> > > <bind-xml
name="processTypeDescription"
> node="element"
> > >
location="processTypeDescriptionList"
> > reference="false"/>
> > > </field>
> > > <field name="processServicesUri"
type="string"
> > required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="processServicesUri"
> node="element"
> > > reference="false"/>
> > > </field>
> > > <field name="factoryCalendarId"
type="string"
> > required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="factoryCalendarId"
> node="element"
> > > reference="false"/>
> > > </field>
> > > <field name="illicitProcessId"
type="string"
> > required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="illicitProcessId"
> node="element"
> > > reference="false"/>
> > > </field>
> > > </class>
> > > </mapping>
> > >
> >
>
----------------------------------------------------------------------------------------------------------------------
>
> >
> > > procesTypeDescription:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <mapping>
> > >
> > >
> > > <class
> name="com.ibs.rdc.conf.bo.ProcessTypeDescription "
> > > auto-complete="true">
> > > <description>Default mapping for class
> > > com.ibs.rdc.conf.bo.ProcessTypeDescription
</description>
> > > <map-to xml="processTypeDescription"/>
> > > <field name="id" type="integer"
> required="false"
> > direct="false"
> > > transient="false">
> > > <bind-xml name="id" node="element"
> reference="false"/>
> > > </field>
> > > <field name="textline" type="string"
> required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="textline"
node="element"
> > reference="false"/>
> > > </field>
> > > <!--
> > > -->
> > > <field name="language"
> type="com.ibs.rdc.conf.bo.Language"
> > > required="false" direct="false"
> transient="false">
> > > <bind-xml name="languages"
node="element"
> > reference="false"/>
> > > </field>
> > > </class>
> > > </mapping>
> > >
> >
>
-----------------------------------------------------------------------------------------------------------------------------------
> >
> > > language object:
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <mapping>
> > > <class name="com.ibs.rdc.conf.bo.Language "
> > auto-complete="true">
> > > <description>
> > > Default mapping for class
> com.ibs.rdc.conf.bo.Language
> > > </description>
> > > <map-to xml="language" />
> > > <field name="languageKey" type="string"
> required="false"
> > > direct="false" transient="false">
> > > <bind-xml name="languageKey"
node="element"
> > > reference="false" />
> > > </field>
> > > <field name="id" type="integer"
required="false"
> > direct="false"
> > > transient="false">
> > > <bind-xml name="id" node="element"
> > reference="false" />
> > > </field>
> > > </class>
> > > </mapping>
> > >
> >
>
-------------------------------------------------------------------------------------------------------------------------------------
>
> >
> > >
> > > So i try to marshall object processType. i
awaits
> somthing
> > like that:
> > >
> > >
> > > <processType>
> > > <isNonAutomatic>true</isNonAutomatic>
> > > <tolerance>
> > >
> <isLaterRequested>true</isLaterRequested>
> > >
<toleratedDays>0</toleratedDays>
> > > </tolerance>
> > >
<processTypeId>REQUESTLOAN</processTypeId>
> > > <processTypeDescriptionList>
> > > <processTypeDescription>
> > > <textline>loan request
> (market)</textline>
> > >
> <languageKey>ENGLISH</languageKey>
> > > </languages>
> > > </processTypeDescription>
> > > <processTypeDescription>
> > > <textline>Krediterfassung im
> Markt</textline>
> > > <languages>
> > >
> <languageKey>DEUTSCH</languageKey>
> > >
> <language-key>DEUTSCH</language-key>
> > > </languages>
> > > </processTypeDescription>
> > > </processTypeDescriptionList>
> > >
> <processServicesUri>local</processServicesUri>
> > >
<factoryCalendarId></factoryCalendarId>
> > > <illicitProcessId></illicitProcessId>
> > > </processType>
> > >
> > >
> > > but i have become this:
> > >
> > > <processType>
> > > <isNonAutomatic>true</isNonAutomatic>
> > > <tolerance
> > > xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance
> > < http://www.w3.org/2001/XMLSchema-instance
<http://www.w3.org/2001/XMLSchema-instance>>"
> > > is-later-requested="true"
> > > xsi:type="java:
> com.ibs.rdc.conf.bo.Tolerance_$$_javassist_17 ">
> > > <hibernate-lazy-initializer
> unwrap="false"
> > > uninitialized="false"
> > >
> >
>
xsi:type="java:org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer">
> > >
> > > <implementation
> xsi:type="tolerance">
> > >
> <isLaterRequested>true</isLaterRequested>
> > >
<toleratedDays>0</toleratedDays>
> > > </implementation>
> > >
> >
<entity-name>com.ibs.rdc.conf.bo.Tolerance</entity-name>
> > > </hibernate-lazy-initializer>
> > >
<tolerated-days>0</tolerated-days>
> > > </tolerance>
> > >
<processTypeId>REQUESTLOAN</processTypeId>
> > > <processTypeDescriptionList>
> > > <processTypeDescription>
> > > <textline>loan request
> (market)</textline>
> > > <languages
> > >
> > > xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
> > > xsi:type="java:
> com.ibs.rdc.conf.bo.Language_$$_javassist_11 ">
> > >
<hibernate-lazy-initializer
> unwrap="false"
> > > uninitialized="false"
> > >
> >
> xsi:type="java:
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer
> >
> > > ">
> > > <implementation
> xsi:type="language">
> > >
> <languageKey>ENGLISH</languageKey>
> > > </implementation>
> > >
> >
> <entity-name>com.ibs.rdc.conf.bo.Language</entity-name>
> > >
</hibernate-lazy-initializer>
> > >
> <language-key>ENGLISH</language-key>
> > > </languages>
> > > </processTypeDescription>
> > > <processTypeDescription>
> > > <textline>Krediterfassung im
> Markt</textline>
> > > <languages
> > >
> > > xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance
> > < http://www.w3.org/2001/XMLSchema-instance>"
> > > xsi:type="java:
> com.ibs.rdc.conf.bo.Language_$$_javassist_11 ">
> > >
<hibernate-lazy-initializer
> unwrap="false"
> > > uninitialized="false"
> > >
> >
> xsi:type="java:
org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer
> >
> > > ">
> > > <implementation
> xsi:type="language">
> > >
> <languageKey>DEUTSCH</languageKey>
> > > </implementation>
> > >
> >
> <entity-name>com.ibs.rdc.conf.bo.Language</entity-name>
> > >
</hibernate-lazy-initializer>
> > >
> <language-key>DEUTSCH</language-key>
> > > </languages>
> > > </processTypeDescription>
> > > </processTypeDescriptionList>
> > >
> <processServicesUri>local</processServicesUri>
> > >
<factoryCalendarId></factoryCalendarId>
> > > <illicitProcessId></illicitProcessId>
> > > </processType>
> > >
> > >
> > > there is some with hibernate proxies... and lazy
> loading. I
> > have no idea
> > > how can fix it.
> > >
> > > thanks for advice.
> > >
> > > jozef
> > >
> > >
> > >
> >
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe from this list please visit:
> >
> > http://xircles.codehaus.org/manage_email
> >
> >
> >
>
> --
>
> Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
> Ralf Joachim
> Raiffeisenstraße 11
> 72127 Kusterdingen
> Germany
>
> Tel. +49 7071 3690 52
> Mobil: +49 173 9630135
> Fax +49 7071 3690 98
>
> Internet: www.syscon.eu
> E-Mail: [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>>
>
> Sitz der Gesellschaft: D-72127 Kusterdingen
> Registereintrag: Amtsgericht Stuttgart, HRB 382295
> Geschäftsleitung: Jens Joachim, Ralf Joachim
>
>
---------------------------------------------------------------------
>
> To unsubscribe from this list please visit:
>
> http://xircles.codehaus.org/manage_email
> <http://xircles.codehaus.org/manage_email
<http://xircles.codehaus.org/manage_email>>
>
>
>
--
Syscon Ingenieurbüro für Meß- und Datentechnik GmbH
Ralf Joachim
Raiffeisenstraße 11
72127 Kusterdingen
Germany
Tel. +49 7071 3690 52
Mobil: +49 173 9630135
Fax +49 7071 3690 98
Internet: www.syscon.eu
E-Mail: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
Sitz der Gesellschaft: D-72127 Kusterdingen
Registereintrag: Amtsgericht Stuttgart, HRB 382295
Geschäftsleitung: Jens Joachim, Ralf Joachim
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email