You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by COURTAULT Francois <Fr...@gemalto.com> on 2017/05/05 11:54:56 UTC

Issue with CDI injection: got CreationException with StackOverflowError

Hello everyone,

I have a POJO with several injections (@Inject) in it which runs fine when performing some tests using Swagger UI.

Yesterday, in this POJO, I have added a new @Inject and if I test this one with Swagger UI, I got 500 with this payload:
{ "code": 500, "messages": [ "javax.enterprise.inject.CreationException", "java.lang.StackOverflowError", " - Caused by: null" ] }

The issue I have is that, in TomEE log files, I don't see any stacktrace :(
Is there any settings to help me to find out what is the real issue ?

BTW, have you any idea what could cause this issue ? (I was thinking of circular dependency but according my source code analysis this is not the case)

Best Regards.
________________________________
This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.

RE: Issue with CDI injection: got CreationException with StackOverflowError

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Tomee will log the exception. Likely not done here cause of the exception
mapper using this specific format. Said otherwise: debug swagger
serializer/mapper.


Le 5 mai 2017 16:57, "COURTAULT Francois" <Fr...@gemalto.com>
a écrit :

> Hello Romain,
>
> First, you have to know that in our application, Jackson is the JAX-RS
> provider:
> @Provider
> @Consumes(MediaType.APPLICATION_JSON)
> @Produces(MediaType.APPLICATION_JSON)
> public class MyJacksonJsonProvider extends JacksonJsonProvider {
> }
>
> But according to me the issue is not on the JAX-RS provider side bur
> rather on CDI part.
>
> I perform the same test by using curl instead of Swagger UI and I got the
> same response:  {"code":500,"messages":["javax.enterprise.inject.
> CreationException","java.lang.StackOverflowError"," - Caused by: null"]}.
> So the question is : how to debug/log any CDI issue in TomEE ?
>
> Best Regards.
>
> -----Original Message-----
> From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
> Sent: vendredi 5 mai 2017 15:06
> To: users@tomee.apache.org
> Subject: Re: Issue with CDI injection: got CreationException with
> StackOverflowError
>
> Hi
>
> Looks like a cyclic reference. Likely a cause of the exception. Johnzon 1
> fixed it i think for stacks but here the format looks specific so likely a
> model issue. Can be linked to swagger model which relies on jackson by
> default.
>
> That said the error means a cdi bean cant be created so you should be able
> to fix this root cause instead of the serialization consequence.
>
>
> Le 5 mai 2017 13:55, "COURTAULT Francois" <Fr...@gemalto.com>
> a écrit :
>
> Hello everyone,
>
> I have a POJO with several injections (@Inject) in it which runs fine when
> performing some tests using Swagger UI.
>
> Yesterday, in this POJO, I have added a new @Inject and if I test this one
> with Swagger UI, I got 500 with this payload:
> { "code": 500, "messages": [ "javax.enterprise.inject.CreationException",
> "java.lang.StackOverflowError", " - Caused by: null" ] }
>
> The issue I have is that, in TomEE log files, I don't see any stacktrace
> :( Is there any settings to help me to find out what is the real issue ?
>
> BTW, have you any idea what could cause this issue ? (I was thinking of
> circular dependency but according my source code analysis this is not the
> case)
>
> Best Regards.
> ________________________________
> This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
> ________________________________
>  This message and any attachments are intended solely for the addressees
> and may contain confidential information. Any unauthorized use or
> disclosure, either whole or partial, is prohibited.
> E-mails are susceptible to alteration. Our company shall not be liable for
> the message if altered, changed or falsified. If you are not the intended
> recipient of this message, please delete it and notify the sender.
> Although all reasonable efforts have been made to keep this transmission
> free from viruses, the sender will not be liable for damages caused by a
> transmitted virus.
>

RE: Issue with CDI injection: got CreationException with StackOverflowError

Posted by COURTAULT Francois <Fr...@gemalto.com>.
Hello,

Thanks everyone for your help.
The issue comes from my factory class holding a @Produces method where I forget to use a qualifier used for the bean I want to be injected.

But I learn that if we use some Exception mappers, it's quite difficult to get the root cause.

Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
Sent: vendredi 5 mai 2017 17:45
To: users@tomee.apache.org
Subject: Re: Issue with CDI injection: got CreationException with StackOverflowError

Or just scoping beans a ans b. Lazy init of cdi would work. That said it can be a missing dep or a conflicting api too. Put a breakpoint in the exception constructor and print the stack, you ll know very quickly ;).


Le 5 mai 2017 17:38, "Laird Nelson" <lj...@gmail.com> a écrit :

> On Fri, May 5, 2017 at 7:57 AM COURTAULT Francois <
> Francois.Courtault@gemalto.com> wrote:
>
> > I perform the same test by using curl instead of Swagger UI and I
> > got the same response:
> > {"code":500,"messages":["javax.enterprise.inject.
> CreationException","java.lang.StackOverflowError","
> > - Caused by: null"]}.
> >
>
> I can't speak to TomEE here but this means almost certainly that you
> have something like:
>
> public class A {
>   @Inject
>   private B b;
> }
> public class B {
>   @Inject
>   private A a;
> }
>
> You can resolve these situations with:
>
> public class A {
>   @Inject
>   private *Provider<B> bProvider*;
> }
> public class B {
>   @Inject
>   private A a;
> }
>
> …or:
>
> public class A {
>   @Inject
>   private B b;
> }
> public class B {
>   @Inject
>   private *Provider<A> aProvider*;
> }
>
> Best,
> Laird
> --
> http://about.me/lairdnelson
>
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.

Re: Issue with CDI injection: got CreationException with StackOverflowError

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Or just scoping beans a ans b. Lazy init of cdi would work. That said it
can be a missing dep or a conflicting api too. Put a breakpoint in the
exception constructor and print the stack, you ll know very quickly ;).


Le 5 mai 2017 17:38, "Laird Nelson" <lj...@gmail.com> a écrit :

> On Fri, May 5, 2017 at 7:57 AM COURTAULT Francois <
> Francois.Courtault@gemalto.com> wrote:
>
> > I perform the same test by using curl instead of Swagger UI and I got the
> > same response:
> > {"code":500,"messages":["javax.enterprise.inject.
> CreationException","java.lang.StackOverflowError","
> > - Caused by: null"]}.
> >
>
> I can't speak to TomEE here but this means almost certainly that you have
> something like:
>
> public class A {
>   @Inject
>   private B b;
> }
> public class B {
>   @Inject
>   private A a;
> }
>
> You can resolve these situations with:
>
> public class A {
>   @Inject
>   private *Provider<B> bProvider*;
> }
> public class B {
>   @Inject
>   private A a;
> }
>
> …or:
>
> public class A {
>   @Inject
>   private B b;
> }
> public class B {
>   @Inject
>   private *Provider<A> aProvider*;
> }
>
> Best,
> Laird
> --
> http://about.me/lairdnelson
>

Re: Issue with CDI injection: got CreationException with StackOverflowError

Posted by Laird Nelson <lj...@gmail.com>.
On Fri, May 5, 2017 at 7:57 AM COURTAULT Francois <
Francois.Courtault@gemalto.com> wrote:

> I perform the same test by using curl instead of Swagger UI and I got the
> same response:
> {"code":500,"messages":["javax.enterprise.inject.CreationException","java.lang.StackOverflowError","
> - Caused by: null"]}.
>

I can't speak to TomEE here but this means almost certainly that you have
something like:

public class A {
  @Inject
  private B b;
}
public class B {
  @Inject
  private A a;
}

You can resolve these situations with:

public class A {
  @Inject
  private *Provider<B> bProvider*;
}
public class B {
  @Inject
  private A a;
}

…or:

public class A {
  @Inject
  private B b;
}
public class B {
  @Inject
  private *Provider<A> aProvider*;
}

Best,
Laird
--
http://about.me/lairdnelson

RE: Issue with CDI injection: got CreationException with StackOverflowError

Posted by COURTAULT Francois <Fr...@gemalto.com>.
Hello Romain,

First, you have to know that in our application, Jackson is the JAX-RS provider:
@Provider
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class MyJacksonJsonProvider extends JacksonJsonProvider {
}

But according to me the issue is not on the JAX-RS provider side bur rather on CDI part.

I perform the same test by using curl instead of Swagger UI and I got the same response:  {"code":500,"messages":["javax.enterprise.inject.CreationException","java.lang.StackOverflowError"," - Caused by: null"]}.
So the question is : how to debug/log any CDI issue in TomEE ?

Best Regards.

-----Original Message-----
From: Romain Manni-Bucau [mailto:rmannibucau@gmail.com]
Sent: vendredi 5 mai 2017 15:06
To: users@tomee.apache.org
Subject: Re: Issue with CDI injection: got CreationException with StackOverflowError

Hi

Looks like a cyclic reference. Likely a cause of the exception. Johnzon 1 fixed it i think for stacks but here the format looks specific so likely a model issue. Can be linked to swagger model which relies on jackson by default.

That said the error means a cdi bean cant be created so you should be able to fix this root cause instead of the serialization consequence.


Le 5 mai 2017 13:55, "COURTAULT Francois" <Fr...@gemalto.com> a écrit :

Hello everyone,

I have a POJO with several injections (@Inject) in it which runs fine when performing some tests using Swagger UI.

Yesterday, in this POJO, I have added a new @Inject and if I test this one with Swagger UI, I got 500 with this payload:
{ "code": 500, "messages": [ "javax.enterprise.inject.CreationException",
"java.lang.StackOverflowError", " - Caused by: null" ] }

The issue I have is that, in TomEE log files, I don't see any stacktrace :( Is there any settings to help me to find out what is the real issue ?

BTW, have you any idea what could cause this issue ? (I was thinking of circular dependency but according my source code analysis this is not the
case)

Best Regards.
________________________________
This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.
________________________________
 This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus.

Re: Issue with CDI injection: got CreationException with StackOverflowError

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi

Looks like a cyclic reference. Likely a cause of the exception. Johnzon 1
fixed it i think for stacks but here the format looks specific so likely a
model issue. Can be linked to swagger model which relies on jackson by
default.

That said the error means a cdi bean cant be created so you should be able
to fix this root cause instead of the serialization consequence.


Le 5 mai 2017 13:55, "COURTAULT Francois" <Fr...@gemalto.com>
a écrit :

Hello everyone,

I have a POJO with several injections (@Inject) in it which runs fine when
performing some tests using Swagger UI.

Yesterday, in this POJO, I have added a new @Inject and if I test this one
with Swagger UI, I got 500 with this payload:
{ "code": 500, "messages": [ "javax.enterprise.inject.CreationException",
"java.lang.StackOverflowError", " - Caused by: null" ] }

The issue I have is that, in TomEE log files, I don't see any stacktrace :(
Is there any settings to help me to find out what is the real issue ?

BTW, have you any idea what could cause this issue ? (I was thinking of
circular dependency but according my source code analysis this is not the
case)

Best Regards.
________________________________
This message and any attachments are intended solely for the addressees and
may contain confidential information. Any unauthorized use or disclosure,
either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for
the message if altered, changed or falsified. If you are not the intended
recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission
free from viruses, the sender will not be liable for damages caused by a
transmitted virus.