Git Product home page Git Product logo

Comments (8)

jhalterman avatar jhalterman commented on July 3, 2024

I think this issue is related to #18

That one was put on hold since we didn't really have any good solutions yet. Feel free to post if you have any ideas.

from modelmapper.

xfolch avatar xfolch commented on July 3, 2024

Ok. I think I've solved it exporting these packages in my manifest, but now I have another problem when I add a new mapping (modelMapper.addMappings()).

In this case, I get the following exception:


Caused by: java.lang.IllegalArgumentException: class com.young.mknotif.dto.Notification$$EnhancerByModelMapper$$7f7540f3 is not an enhanced class
        at org.modelmapper.internal.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:621)
        at org.modelmapper.internal.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:612)
        at org.modelmapper.internal.cglib.proxy.Enhancer.registerCallbacks(Enhancer.java:581)
        at org.modelmapper.internal.ProxyFactory.proxyFor(ProxyFactory.java:87)
        at org.modelmapper.internal.MappingBuilderImpl.getSource(MappingBuilderImpl.java:166)
        at org.modelmapper.PropertyMap.configure(PropertyMap.java:267)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[:1.6.0_30]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)[:1.6.0_30]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)[:1.6.0_30]
        at java.lang.reflect.Method.invoke(Method.java:597)[:1.6.0_30]
        at org.modelmapper.internal.MappingBuilderImpl.build(MappingBuilderImpl.java:123)
        ... 33 more

Have you an idea how to solve it?

from modelmapper.

jhalterman avatar jhalterman commented on July 3, 2024

What does the mapping code look like?

from modelmapper.

xfolch avatar xfolch commented on July 3, 2024

This is my map:


public class NotificationUnconsumedMappingBuilder extends PropertyMap<Notification, NotificationUnconsumed> {
    @Override
    protected void configure() {
        map(source.getFact().getFactContexts()).setContextList(null);
        map().setCreated(source.getFact().getCreated());
        map().setMessage(source.getFact().getMessage());
        map().setRecipient(source.getRecipient().getUri());
        map().setType(source.getFact().getFactType().getUri());
    }
    
}

And I add property map to the model mapper:


mapperManager.addMappings(new NotificationUnconsumedMappingBuilder());

from modelmapper.

jhalterman avatar jhalterman commented on July 3, 2024

The mapping code looks fine. Was there any more to the stacktrace?

from modelmapper.

xfolch avatar xfolch commented on July 3, 2024

I've solved the problem, but I've had to modify the pom file for regenerate the MANIFEST file. I've removed the shade plugin and I've only used the bundle plugin without any special configuration:


<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
</plugin>

This configuration does not copy cglib packages neither ignores it. See the result:


Manifest-Version: 1.0
Bnd-LastModified: 1355310050839
Build-Jdk: 1.6.0_30
Built-By: xavi
Bundle-ManifestVersion: 2
Bundle-Name: ModelMapper
Bundle-SymbolicName: org.modelmapper.modelmapper
Bundle-Version: 0.5.3
Created-By: Apache Maven Bundle Plugin
Export-Package: org.modelmapper;uses:="org.modelmapper.spi,org.modelmapp
 er.config,org.modelmapper.builder";version="0.5.3",org.modelmapper.buil
 der;uses:="org.modelmapper";version="0.5.3",org.modelmapper.config;uses
 :="org.modelmapper.spi,org.modelmapper";version="0.5.3",org.modelmapper
 .convention;uses:="org.modelmapper.spi";version="0.5.3",org.modelmapper
 .spi;uses:="org.modelmapper";version="0.5.3"
Import-Package: javax.xml.datatype,net.sf.cglib.core,net.sf.cglib.proxy,
 org.modelmapper.builder,org.modelmapper.config,org.modelmapper.conventi
 on
Tool: Bnd-1.50.0

I guess is not the best solution, but it works in OSGi

from modelmapper.

jhalterman avatar jhalterman commented on July 3, 2024

I just merged #18 which should resolve this problem. Try the latest build and see how it looks.

from modelmapper.

darklynx avatar darklynx commented on July 3, 2024

Hi,

I had similar problem with ReflectUtils and Spring Source dm Server 2.0.5

Thanks to the approach described by xfolch, I recompiled the latest version of model mapper according to his description and added external dependency on net.sf.cglib.* packages to bundle where mapper is used and to bundle that contains model classes.

This helped me to solve my problem.

Thanks a lot jhalterman for the great mapping tool!
And thank you xfolch for a good tip on how to solve OSGi issue!

from modelmapper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.