NoSuchBeanException for MapStruct generated classes in Micronaut Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!How to generate a random alpha-numeric string?Java inner class and static nested classHow do I generate random integers within a specific range in Java?How to create a generic array in Java?How to get a class instance of generics type THow to write Junit test for mapstruct abstract mapper injected via SpringMapStruct - @Mapper annotation don't create beanHow to map JAXB elements annotated with @XMLSeeAlso using mapStruct?Passing data from a POST request and broadcasting to a websocket in MicronautSpring Boot with Mapstruct build fails when add Spring Security

How can I make names more distinctive without making them longer?

What is this single-engine low-wing propeller plane?

Why is "Consequences inflicted." not a sentence?

What's the difference between `auto x = vector<int>()` and `vector<int> x`?

How do I stop a creek from eroding my steep embankment?

Models of set theory where not every set can be linearly ordered

Is 1 ppb equal to 1 μg/kg?

Determinant is linear as a function of each of the rows of the matrix.

What's the purpose of writing one's academic bio in 3rd person?

Disable hyphenation for an entire paragraph

What is the longest distance a 13th-level monk can jump while attacking on the same turn?

How much radiation do nuclear physics experiments expose researchers to nowadays?

The logistics of corpse disposal

Dominant seventh chord in the major scale contains diminished triad of the seventh?

Can inflation occur in a positive-sum game currency system such as the Stack Exchange reputation system?

Should I call the interviewer directly, if HR aren't responding?

List *all* the tuples!

ListPlot join points by nearest neighbor rather than order

Is the argument below valid?

When to stop saving and start investing?

Why is "Captain Marvel" translated as male in Portugal?

Right-skewed distribution with mean equals to mode?

"Seemed to had" is it correct?

Proof involving the spectral radius and the Jordan canonical form



NoSuchBeanException for MapStruct generated classes in Micronaut



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!How to generate a random alpha-numeric string?Java inner class and static nested classHow do I generate random integers within a specific range in Java?How to create a generic array in Java?How to get a class instance of generics type THow to write Junit test for mapstruct abstract mapper injected via SpringMapStruct - @Mapper annotation don't create beanHow to map JAXB elements annotated with @XMLSeeAlso using mapStruct?Passing data from a POST request and broadcasting to a websocket in MicronautSpring Boot with Mapstruct build fails when add Spring Security



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








2















When generating mapper-implementations with MapStruct, using "jsr330" componentModel, micronaut will throw a NoSuchBeanException during runtime when trying to inject those.



A workaround would be to use a provider that will supply the mapper-objects, but the generated code should work.



Mapper definition:



@Mapper(componentModel = "jsr330")
public interface FooBarMapper
Foo toFoo(Bar bar);



Controller:



@Controller
public class SomeController
@Inject
public SomeController(FooBarMapper mapper)


@Get
public String foo()
return "foo";




pom.xml excerpt:



<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>$mapstruct.version</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>$micronaut.version</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>$micronaut.version</version>
</path>
</annotationProcessorPaths>


When calling the method on the controller, I would expect Micronaut to find the Mapstruct generated class (it is annotated with @Singleton), but instead, the result is



Message: No bean of type [com.example.FooBarMapper] exists. Ensure the class is declared a bean and if you are using Java or Kotlin make sure you have enabled annotation processing.
Path Taken: new SomeController([FooBarMapper mapper])
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [mapper] of class: com.example.SomeController










share|improve this question






















  • Are the mappers generated?

    – Filip
    Jan 10 at 21:05











  • Yes, mappers have been generated and I can also instantiate one manually in the controller. Just the wiring using @Inject doesn't work.

    – age
    Jan 11 at 6:25











  • When is this message coming from Micronaut? During compilation or runtime? Maybe micronaut is not waiting for the other annotation processors

    – Filip
    Jan 11 at 10:26











  • During runtime, if I change the order of annotation processors in the pom, so that mapstruct is after micronaut, no mapstruct code is generated.

    – age
    Jan 11 at 15:23











  • This is a known issue see github.com/micronaut-projects/micronaut-core/issues/991

    – Filip
    Jan 11 at 16:46


















2















When generating mapper-implementations with MapStruct, using "jsr330" componentModel, micronaut will throw a NoSuchBeanException during runtime when trying to inject those.



A workaround would be to use a provider that will supply the mapper-objects, but the generated code should work.



Mapper definition:



@Mapper(componentModel = "jsr330")
public interface FooBarMapper
Foo toFoo(Bar bar);



Controller:



@Controller
public class SomeController
@Inject
public SomeController(FooBarMapper mapper)


@Get
public String foo()
return "foo";




pom.xml excerpt:



<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>$mapstruct.version</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>$micronaut.version</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>$micronaut.version</version>
</path>
</annotationProcessorPaths>


When calling the method on the controller, I would expect Micronaut to find the Mapstruct generated class (it is annotated with @Singleton), but instead, the result is



Message: No bean of type [com.example.FooBarMapper] exists. Ensure the class is declared a bean and if you are using Java or Kotlin make sure you have enabled annotation processing.
Path Taken: new SomeController([FooBarMapper mapper])
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [mapper] of class: com.example.SomeController










share|improve this question






















  • Are the mappers generated?

    – Filip
    Jan 10 at 21:05











  • Yes, mappers have been generated and I can also instantiate one manually in the controller. Just the wiring using @Inject doesn't work.

    – age
    Jan 11 at 6:25











  • When is this message coming from Micronaut? During compilation or runtime? Maybe micronaut is not waiting for the other annotation processors

    – Filip
    Jan 11 at 10:26











  • During runtime, if I change the order of annotation processors in the pom, so that mapstruct is after micronaut, no mapstruct code is generated.

    – age
    Jan 11 at 15:23











  • This is a known issue see github.com/micronaut-projects/micronaut-core/issues/991

    – Filip
    Jan 11 at 16:46














2












2








2








When generating mapper-implementations with MapStruct, using "jsr330" componentModel, micronaut will throw a NoSuchBeanException during runtime when trying to inject those.



A workaround would be to use a provider that will supply the mapper-objects, but the generated code should work.



Mapper definition:



@Mapper(componentModel = "jsr330")
public interface FooBarMapper
Foo toFoo(Bar bar);



Controller:



@Controller
public class SomeController
@Inject
public SomeController(FooBarMapper mapper)


@Get
public String foo()
return "foo";




pom.xml excerpt:



<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>$mapstruct.version</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>$micronaut.version</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>$micronaut.version</version>
</path>
</annotationProcessorPaths>


When calling the method on the controller, I would expect Micronaut to find the Mapstruct generated class (it is annotated with @Singleton), but instead, the result is



Message: No bean of type [com.example.FooBarMapper] exists. Ensure the class is declared a bean and if you are using Java or Kotlin make sure you have enabled annotation processing.
Path Taken: new SomeController([FooBarMapper mapper])
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [mapper] of class: com.example.SomeController










share|improve this question














When generating mapper-implementations with MapStruct, using "jsr330" componentModel, micronaut will throw a NoSuchBeanException during runtime when trying to inject those.



A workaround would be to use a provider that will supply the mapper-objects, but the generated code should work.



Mapper definition:



@Mapper(componentModel = "jsr330")
public interface FooBarMapper
Foo toFoo(Bar bar);



Controller:



@Controller
public class SomeController
@Inject
public SomeController(FooBarMapper mapper)


@Get
public String foo()
return "foo";




pom.xml excerpt:



<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>$mapstruct.version</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>$micronaut.version</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>$micronaut.version</version>
</path>
</annotationProcessorPaths>


When calling the method on the controller, I would expect Micronaut to find the Mapstruct generated class (it is annotated with @Singleton), but instead, the result is



Message: No bean of type [com.example.FooBarMapper] exists. Ensure the class is declared a bean and if you are using Java or Kotlin make sure you have enabled annotation processing.
Path Taken: new SomeController([FooBarMapper mapper])
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for parameter [mapper] of class: com.example.SomeController







java mapstruct micronaut






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 10 at 20:57









ageage

1312




1312












  • Are the mappers generated?

    – Filip
    Jan 10 at 21:05











  • Yes, mappers have been generated and I can also instantiate one manually in the controller. Just the wiring using @Inject doesn't work.

    – age
    Jan 11 at 6:25











  • When is this message coming from Micronaut? During compilation or runtime? Maybe micronaut is not waiting for the other annotation processors

    – Filip
    Jan 11 at 10:26











  • During runtime, if I change the order of annotation processors in the pom, so that mapstruct is after micronaut, no mapstruct code is generated.

    – age
    Jan 11 at 15:23











  • This is a known issue see github.com/micronaut-projects/micronaut-core/issues/991

    – Filip
    Jan 11 at 16:46


















  • Are the mappers generated?

    – Filip
    Jan 10 at 21:05











  • Yes, mappers have been generated and I can also instantiate one manually in the controller. Just the wiring using @Inject doesn't work.

    – age
    Jan 11 at 6:25











  • When is this message coming from Micronaut? During compilation or runtime? Maybe micronaut is not waiting for the other annotation processors

    – Filip
    Jan 11 at 10:26











  • During runtime, if I change the order of annotation processors in the pom, so that mapstruct is after micronaut, no mapstruct code is generated.

    – age
    Jan 11 at 15:23











  • This is a known issue see github.com/micronaut-projects/micronaut-core/issues/991

    – Filip
    Jan 11 at 16:46

















Are the mappers generated?

– Filip
Jan 10 at 21:05





Are the mappers generated?

– Filip
Jan 10 at 21:05













Yes, mappers have been generated and I can also instantiate one manually in the controller. Just the wiring using @Inject doesn't work.

– age
Jan 11 at 6:25





Yes, mappers have been generated and I can also instantiate one manually in the controller. Just the wiring using @Inject doesn't work.

– age
Jan 11 at 6:25













When is this message coming from Micronaut? During compilation or runtime? Maybe micronaut is not waiting for the other annotation processors

– Filip
Jan 11 at 10:26





When is this message coming from Micronaut? During compilation or runtime? Maybe micronaut is not waiting for the other annotation processors

– Filip
Jan 11 at 10:26













During runtime, if I change the order of annotation processors in the pom, so that mapstruct is after micronaut, no mapstruct code is generated.

– age
Jan 11 at 15:23





During runtime, if I change the order of annotation processors in the pom, so that mapstruct is after micronaut, no mapstruct code is generated.

– age
Jan 11 at 15:23













This is a known issue see github.com/micronaut-projects/micronaut-core/issues/991

– Filip
Jan 11 at 16:46






This is a known issue see github.com/micronaut-projects/micronaut-core/issues/991

– Filip
Jan 11 at 16:46













1 Answer
1






active

oldest

votes


















0














I found Micronaut PR which should resolve the problem with mapstruct using jsr330 component model. They are planning to include the fix in 1.1.0.



UPDATE: The issue if fixed in 1.1.0.RC1






share|improve this answer

























  • Thank you for the effort - this is exactly what i was looking for.

    – age
    Mar 13 at 15:28











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54136772%2fnosuchbeanexception-for-mapstruct-generated-classes-in-micronaut%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














I found Micronaut PR which should resolve the problem with mapstruct using jsr330 component model. They are planning to include the fix in 1.1.0.



UPDATE: The issue if fixed in 1.1.0.RC1






share|improve this answer

























  • Thank you for the effort - this is exactly what i was looking for.

    – age
    Mar 13 at 15:28















0














I found Micronaut PR which should resolve the problem with mapstruct using jsr330 component model. They are planning to include the fix in 1.1.0.



UPDATE: The issue if fixed in 1.1.0.RC1






share|improve this answer

























  • Thank you for the effort - this is exactly what i was looking for.

    – age
    Mar 13 at 15:28













0












0








0







I found Micronaut PR which should resolve the problem with mapstruct using jsr330 component model. They are planning to include the fix in 1.1.0.



UPDATE: The issue if fixed in 1.1.0.RC1






share|improve this answer















I found Micronaut PR which should resolve the problem with mapstruct using jsr330 component model. They are planning to include the fix in 1.1.0.



UPDATE: The issue if fixed in 1.1.0.RC1







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 22 at 8:38

























answered Mar 13 at 8:14









SirWojtekSirWojtek

198311




198311












  • Thank you for the effort - this is exactly what i was looking for.

    – age
    Mar 13 at 15:28

















  • Thank you for the effort - this is exactly what i was looking for.

    – age
    Mar 13 at 15:28
















Thank you for the effort - this is exactly what i was looking for.

– age
Mar 13 at 15:28





Thank you for the effort - this is exactly what i was looking for.

– age
Mar 13 at 15:28



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54136772%2fnosuchbeanexception-for-mapstruct-generated-classes-in-micronaut%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript