Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dozer mapping stops working #118

Closed
heneke opened this issue Jul 3, 2013 · 32 comments
Closed

Dozer mapping stops working #118

heneke opened this issue Jul 3, 2013 · 32 comments

Comments

@heneke
Copy link

heneke commented Jul 3, 2013

After a short amount of time (varies between hours up to one day), dozer mapping stop working with

org.dozer.MappingException: java.lang.NoSuchMethodException: Unable to determine write method for Field: 'xxxxx' in Class: class a.b.c.FooBar
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:82)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.invokeWriteMethod(GetterSetterPropertyDescriptor.java:261)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.setPropertyValue(GetterSetterPropertyDescriptor.java:101)
at org.dozer.fieldmap.FieldMap.writeDestValue(FieldMap.java:94)
at org.dozer.MappingProcessor.writeDestinationValue(MappingProcessor.java:870)
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:337)
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:276)
at org.dozer.MappingProcessor.map(MappingProcessor.java:245)
at org.dozer.MappingProcessor.map(MappingProcessor.java:187)
at org.dozer.MappingProcessor.map(MappingProcessor.java:124)
at org.dozer.MappingProcessor.map(MappingProcessor.java:119)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:111)

This is Dozer 5.3.2 on Java 1.7, but happens with 5.4.x also. It's never the same target class or field that fails.

This was already reported here: http://sourceforge.net/p/dozer/bugs/372/

@bleshik
Copy link

bleshik commented Oct 2, 2013

Sounds like it is the same bug :#121
And it is a jdk's bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8013608

@rkfg
Copy link

rkfg commented Feb 6, 2014

If it's a JDK's bug it shouldn't happen on 7u51-2.4.5-2 because it's supposed to be fixed in 7u40. But it does, unfortunately. I couldn't find the pattern but it disappears after I restart jetty and can appear again another day. My DTO class doesn't involve generics so that bug doesn't apply. The failing method (setParent) isn't declared in the base class (though getParent() does). Never was a case with OpenJDK 6.

@wschmitz
Copy link

@bleshik This issue is widely reported online in the recent months, and is not related to the JDK bug you have linked in your post. Here is an excerpt from the JDK site you linked:

"If the read method is defined on the target class but the write method is declared in the base class, the generated PropertyDescriptor does not have the write method. The change in behavior is limited to properties that are defined between the target class and a super class in the class hierarchy. This seems to only affect properties that involve generics. Both the read and write methods are available if both members are defined in the same class or if their type does not involve generics."

First of all, in the examples I've come across and in my own case, the read and write methods are all on the same class. Secondly, the methods do not contain generics.

So this is still an active bug in Dozer and needs to be addressed.

@brabenetz
Copy link
Contributor

With (Sun/Oracle) JDK 6, you have also problems without generics: https://issues.apache.org/jira/browse/BEANUTILS-443

I don't know exactly how, but org.springframework.beans.BeanUtils has solved this problem (it also solved some problems with generics)

ssiahetiong pushed a commit to ssiahetiong/dozer that referenced this issue Apr 10, 2014
@cedricbompart
Copy link

I'm just wondering if this issue is fixed? I can't figure out if this fix has been already release or not?

@lauriharpf
Copy link
Contributor

I can't reproduce this, but having read the discussions and the suggestions I committed 2cd9322, which hopefully fixes the issue.

@buzdin, care to review the commit? The approach used by @ssiahetiong is another alternative; whatever we pick, this needs to be sorted in 5.5.2.

Those affected - @heneke, @cedricbompart, @wschmitz, @rkfg - do you have the possibility to try out the latest version from the repo and see if it resolves the problem?

@wschmitz
Copy link

wschmitz commented Dec 7, 2014

I will try the fix. I cannot reproduce the error on demand, but every once in a while it comes up. I'll post an update here if I run into the issue again. Thanks!!

@rkfg
Copy link

rkfg commented Dec 7, 2014

Sorry, it was an issue long time ago. I don't have it now, many components were updated since, both JRE and dozer. Thanks for the fix anyway, maybe it will help somebody.

@waldemar-schneider
Copy link

It occures occasionally (i think it depends on the garbage collection) in our test systems (all systems run with the JRE 7u51) with the 5.5.1 release. After i found this issue we used the current code base and deployt our application with the fix (mentioned above).
Since then our QS department cannot reproduce this error, but the fix is only a couple of days in the new version of our application on our test systems. I hope that this issue is fixed finally. I will write again if it occures again in our systems.

@tofmonaute
Copy link

Thank you for all your answers, i will try the fix and I will make a report to tell you if it's evreything is ok

@lauriharpf
Copy link
Contributor

@wschmitz, @tofmonaute: Thanks! Please do let us know if the issue still continues after the fix. Alternatively, it's also useful to know if you can run Dozer for a longer period of time without the issue appearing.

@waldemar-schneider, thanks for the info! Did you use c24164b or something else to fix this?

@waldemar-schneider
Copy link

@lauriharpf I think so. We used the codebase from the 3rd december. I can't say if there were another commits. We were a little bit desperate, because our client had these errors in their production environment :-(

@heneke
Copy link
Author

heneke commented Dec 8, 2014

@lauriharpf I changed the code affected long time ago because the production system was affected. I completely removed dozer from the project, so I won't be able to test it. Sorry!

@waldemar-schneider
Copy link

Unfortunately our QA department was able to reproduce this error again with the fixed snapshot version from dozer two days ago :-(

I should mention, that we use a interface (i just call it EntityWithId-interface) for our entity classes in which we define the getter but not the setter.

I think i read some posts that this issue occures if the get / set method for a property are defined on different class hierarchy levels.
Now we want to define also the setId in the EntityWithId-interface. Do you think this will help to prevent this error?

I don't know if the stacktrace is helpful, but i just post it here:

Caused by: org.dozer.MappingException: java.lang.NoSuchMethodException: Unable to determine write method for Field: 'id' in Class: class x.y.server.entities.SomeEntity
at org.dozer.util.MappingUtils.throwMappingException(MappingUtils.java:73) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.invokeWriteMethod(GetterSetterPropertyDescriptor.java:289) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.setPropertyValue(GetterSetterPropertyDescriptor.java:111) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.fieldmap.FieldMap.writeDestValue(FieldMap.java:95) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.writeDestinationValue(MappingProcessor.java:939) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:368) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:307) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.map(MappingProcessor.java:267) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapToDestObject(MappingProcessor.java:216) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.createByCreationDirectiveAndMap(MappingProcessor.java:196) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapCustomObject(MappingProcessor.java:512) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:465) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:361) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:307) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.map(MappingProcessor.java:267) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapToDestObject(MappingProcessor.java:216) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.createByCreationDirectiveAndMap(MappingProcessor.java:196) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapCustomObject(MappingProcessor.java:512) ~[dozer-5.5.2-20140312-1440.jar:na]
at org.dozer.MappingProcessor.mapOrRecurseObject(MappingProcessor.java:465) ~[dozer-5.5.2-20140312-1440.jar:na]
...

@rkfg
Copy link

rkfg commented Dec 17, 2014

Yeah, that probably was it. I had my class implementing a Hierarchic interface that only had getParent() method. setParent() was declared in the class itself (as well as getParent() of course). Dozer couldn't find one of them, I don't really remember which one.

@lauriharpf lauriharpf reopened this Dec 18, 2014
@lauriharpf
Copy link
Contributor

@waldemar-schneider, thanks for the report and apologies for the issue not being resolved. The details you provided (stacktrace and description) do help, much appreciated. I'll look at this during Christmas holidays unless someone beats me to it.

Quick question: Which commons-beanutils JAR are you using during runtime? 1.9.2 (shipped with Dozer) or is something else bringing in a different version?

@waldemar-schneider
Copy link

@lauriharpf It appears that jasper reports (5.1.0) also brings its own version of beanutils (1.8.2). Due to our maven structure of our modules and frameworks this has overriden the beanutils version of dozer.

I didn't notice that until yesterday. thanks for the hint.

@kumaraln
Copy link

kumaraln commented Jan 7, 2015

we have this in our production system as well and we turned off this feature for now. so updating the beantutil to its latest version fixes this issue? or do we need to upddate both dozer and bean util?

@waldemar-schneider
Copy link

After we moved to a new BeanUtils Version (1.9.2) and moved getter and setter for the id (for more info, look at my previous post )into the same interface, this issue is no longer existent in our environment.

@Sukesh-Alluri
Copy link

Is there a possible way of not having to move getter and setter to same base as we've an usage where we override the getters and setters in children in source pojo but not in destination pojo?

@pm-riyanka-dagaonkar
Copy link

Hi, @lauriharpf , @buzdin , We have been using dozer version 5.2.2 in our application and we faced this issue recently on production. It is not reproducible on local set up. Can anyone confirm if the issue is fixed in the latest release 5.5.1 ? Or is there any other way of fixing it?

@Tim-Craig
Copy link

I see this Pull request that is a fix for this issue
2cd9322

I see it has come in after the 5.5.1 release. Is there going to be a new release so this bug fix can come out in an official build? If not, is the current master branch of this repo considered stable enough for people who use dozer in a production environemnet?

@Naa007
Copy link

Naa007 commented Apr 25, 2016

Hi we are using dozer 5.2.2 and getting this exception...

MapId: null
Type: null
Source parent class: org.akc.ngen.domain.impl.EventEntity
Source field name: eventPlanPendingEntities
Source field type: class org.hibernate.collection.PersistentBag
Source field value: Unable to determine source field value
Dest parent class: org.akc.ngen.biz.model.Event
Dest field name: editMessages
Dest field type: java.util.List

Getters and Setters are in abstract super class.

We are facing the issue only in Production not able to reproduce in Local.
Is it fixed ? Or any alternative way to fix it?

@jsebfranck
Copy link

Hi, same problem for me, dozer mappings are instable in preproduction. When will you release the version 5.5.2 ? Or at least in beta ? Otherwise I will have to compile myself the trunk and push it in our nexus instance...

@shakunahuja
Copy link

Hi ,
Same Problem for me ,Any temporary solution??

@MarshallShi
Copy link

Hi there, any update on this issue? Is this issue fixed on 5.5.1?

@shakunahuja
Copy link

My problem has been solved by replacing the common beanutils jar version to 1.8.3 (working fine from last two days after changing the mention beanutils version) and I am using dozer 5.3.2 version.Basically beanutils version mentioned in dozer pom.

and second thing getter setter of a variable should not be in two diff interfaces in its respective hierarchy.

@husmukhh
Copy link

husmukhh commented Feb 14, 2017

Hi ,
I am using Dozer 5.5.1 but facing problem with JAXB maping without setter for collection.
Here is the stack trace :

2017-02-14 18:11:58,241 ERROR [IBSOutboundProcess:124]: IBSOutboundProcessor DataAccessException occured for batch : 6ab7f78e-d75f-4866-b2ad-981597aa2d8f
java.lang.NullPointerException
at org.dozer.util.ReflectionUtils.invoke(ReflectionUtils.java:329)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.writeDeepDestinationValue(GetterSetterPropertyDescriptor.java:232)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.setPropertyValue(GetterSetterPropertyDescriptor.java:96)
at org.dozer.fieldmap.FieldMap.writeDestValue(FieldMap.java:96)
at org.dozer.MappingProcessor.writeDestinationValue(MappingProcessor.java:939)
at org.dozer.MappingProcessor.mapFromFieldMap(MappingProcessor.java:368)
at org.dozer.MappingProcessor.mapField(MappingProcessor.java:307)
at org.dozer.MappingProcessor.map(MappingProcessor.java:267)
at org.dozer.MappingProcessor.mapToDestObject(MappingProcessor.java:216)
at org.dozer.MappingProcessor.createByCreationDirectiveAndMap(MappingProcessor.java:196)
at org.dozer.MappingProcessor.mapGeneral(MappingProcessor.java:170)
at org.dozer.MappingProcessor.map(MappingProcessor.java:104)
at org.dozer.MappingProcessor.map(MappingProcessor.java:99)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:120)
at com.dhl.gcdb.intg.outbd.ibs.IBSOutboundProcess.generaetCMFTaskFeed(IBSOutboundProcess.java:162)
at com.dhl.gcdb.intg.outbd.ibs.IBSOutboundProcess.processIBSOutbound(IBSOutboundProcess.java:91)
at com.dhl.gcdb.intg.outbd.ibs.IBSOutboundProcess$$FastClassByCGLIB$$45b1bb4c.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:701)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:634)
at com.dhl.gcdb.intg.outbd.ibs.IBSOutboundProcess$$EnhancerByCGLIB$$1cad4035.processIBSOutbound()

Some sample mapping :

<field> <a>collectionSource[0].fieldAbc</a> <b>collectionDestination[0].fieldXyz</b> <b-deep-index-hint>xxx.abc.pckg.ClassExample</b-deep-index-hint> </field>

@gauravtyagi77
Copy link

I am also facing the same issue even after commonbeanutils-1.8.3 and dozer 5.3.2 and abstract setter is also in only one interface in interface hierarchy . Have anyone found any other solution for this.

org.dozer.MappingException: java.lang.NoSuchMethodException: Unable to determine write method for Field: 'id' in Class: class

@garethahealy
Copy link
Collaborator

@gauravtyagi77 ; can you build from latest source and retest please?

@garethahealy garethahealy removed this from the 5.5.2 milestone May 31, 2017
@garethahealy
Copy link
Collaborator

Please re-test with 6.0.0

@asadabdin
Copy link

try adding default constructor in your class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests