0

I've been using mapstruct for a while now, but have found this problem while trying to deploy one of my webservices:

Target state: deploy failed on Server my_server
java.lang.ClassNotFoundException: Cannot find implementation for bar.foo.mapper.MyMapper

at weblogic.deploy.api.tools.deployer.Jsr88Operation.report(Jsr88Operation.java:547)
at weblogic.deploy.api.tools.deployer.Deployer.perform(Deployer.java:140)
at weblogic.deploy.api.tools.deployer.Deployer.runBody(Deployer.java:88)
at weblogic.utils.compiler.Tool.run(Tool.java:158)
at weblogic.utils.compiler.Tool.run(Tool.java:115)
at weblogic.Deployer.run(Deployer.java:74)
... 15 more

When I check the WAR being deployed, in the same bar.foo.mapper folder there's MyMapper.class and MyMapperImpl.class, as in other services that work correctly.

In the POM, I've followed the setup as stated in the official doc.

I've already read @gunnar's answer here, but in my case the implementation is beside the interface in the WAR.

Any ideas?

Thanks!

UPDATE: I just tried with version 1.1.0.Beta1 with the same results

UPDATE-2: This is the log of the exception thrown:

Caused By: java.lang.ClassNotFoundException: Cannot find implementation for bar.foo.mapper.MyMapper
        at org.mapstruct.factory.Mappers.getMapper(Mappers.java:94)

While debugging, the exception is thrown here:

T mapper = (T) classLoader.loadClass( clazz.getName() + IMPLEMENTATION_SUFFIX ).newInstance();

...because classLoader.loadClass doesn't find bar.foo.mapper.MyMapperImpl, even though the class is beside the interface.

Andremoniy
  • 34,031
  • 20
  • 135
  • 241
Edu Castrillon
  • 527
  • 1
  • 12
  • 28

1 Answers1

1

Could you try and create a copy of the Mappers class, and use clazz.getClassLoader() as the loader for the impl class? This should do the trick. Can you let me know whether that works? If so, we'll change it in the next release. Thanks!

Gunnar
  • 18,095
  • 1
  • 53
  • 73
  • This did it! I changed the `Thread.currentThread().getContextClassLoader()` (the privileged action) with `clazz.getClassLoader()` – Edu Castrillon Apr 12 '16 at 13:04