You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by trima <ma...@gmail.com> on 2014/02/12 19:26:42 UTC

Autowiring Spring Injection not working tomEE 1.6 plus

Hi,
I have a maven spring project which has REST URLs exposed. There are some
autowired objects injected in the resource classes (HttpServletRequest obj
and other custom objects of my project). This deployement works fine in
tomcat, but now we are required to move our deployment to Tomee+ 1.6. There
is a weird behavior which is seen. The Autowiring seems to work only
sometime. So if I restart the TomEE 10 times then only 2-3 times the
autowiring seems to work otherwise I get a NullPointerException for the
auutowired object. I tried adding below options in system.properties but to
no avail. -
openejb.jaxrs.providers.auto=true
com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager = true
openejb.cxf.jax-rs.providers =
org.codehaus.jackson.jaxrs.JacksonJsonProvider,org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider.

I have also tried to add a beans.xml in WEB-INF, but it didn't helped.
The web.xml entry for jersey servlet is as below : 
<servlet>
              <servlet-name>myproject</servlet-name>
             
<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
              <init-param>
                    
<param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
                     <param-value>true</param-value>
              </init-param>
              <load-on-startup>2</load-on-startup>
</servlet>

I am not able to understand why it works for sometimes and fail the rest of
the time. It looks like some class/library loading issue by TomEE. 



--
View this message in context: http://openejb.979440.n4.nabble.com/Autowiring-Spring-Injection-not-working-tomEE-1-6-plus-tp4667748.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Autowiring Spring Injection not working tomEE 1.6 plus

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

tomee-jaxrs just allow tomee to deploy jaxrs services (from EE spec).
Removing it breaks it. jackson-jaxrs is not linked to it. The issue is
related to something else.

It can be a cxf issue but we need a project reproducing it to
investigate further.
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-02-13 9:55 GMT+01:00 trima <ma...@gmail.com>:
> Hi Romain,
>               Thanks for your reply. It seemed like a JAX-RS issue. My
> webapp had its own jaxrs dependency (jackson-jaxrs.jar). I removed the
> tomee-jaxrs-1.6.0.jar and tested. After that it seems to be working fine.
> the autowiring is working perfectly. Any idea why this may be happening and
> what can be the possible effects of removing tomee-jaxrs jar from its lib.
> (P.S. : I tried doing the other way round too i.e. remove jackson-jaxrs from
> webapps lib, but after that I started getting json parsing error, so it
> seems i have to work with removing tomee's jar only).
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Autowiring-Spring-Injection-not-working-tomEE-1-6-plus-tp4667748p4667758.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Autowiring Spring Injection not working tomEE 1.6 plus

Posted by trima <ma...@gmail.com>.
Hi Romain,
              Thanks for your reply. It seemed like a JAX-RS issue. My
webapp had its own jaxrs dependency (jackson-jaxrs.jar). I removed the
tomee-jaxrs-1.6.0.jar and tested. After that it seems to be working fine.
the autowiring is working perfectly. Any idea why this may be happening and
what can be the possible effects of removing tomee-jaxrs jar from its lib.
(P.S. : I tried doing the other way round too i.e. remove jackson-jaxrs from
webapps lib, but after that I started getting json parsing error, so it
seems i have to work with removing tomee's jar only). 



--
View this message in context: http://openejb.979440.n4.nabble.com/Autowiring-Spring-Injection-not-working-tomEE-1-6-plus-tp4667748p4667758.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Re: Autowiring Spring Injection not working tomEE 1.6 plus

Posted by Thiago Veronezi <th...@veronezi.org>.
Recently, I've posted a blog entry about Spring and TomEE.
It has a demo project with rest controllers and autowiring. I guess you can
check the code to see whats different.

https://github.com/tveronezi/springchat
http://buildnplay.blogspot.ca/2014/02/two-implementations-of-same-websocket.html

[]s,
Thiago.



On Wed, Feb 12, 2014 at 1:38 PM, Romain Manni-Bucau
<rm...@gmail.com>wrote:

> Hi
>
> I don't get all parts of your mail, cxf.jaxrs and provider auto are
> cxf stuff totally ignored by jersey and spring.
>
> Is tomee deploying your jaxrs endpoints? if so maybe skip the jars
> containing the endpoints (see exclusion.list)
> Romain Manni-Bucau
> Twitter: @rmannibucau
> Blog: http://rmannibucau.wordpress.com/
> LinkedIn: http://fr.linkedin.com/in/rmannibucau
> Github: https://github.com/rmannibucau
>
>
>
> 2014-02-12 19:26 GMT+01:00 trima <ma...@gmail.com>:
> > Hi,
> > I have a maven spring project which has REST URLs exposed. There are some
> > autowired objects injected in the resource classes (HttpServletRequest
> obj
> > and other custom objects of my project). This deployement works fine in
> > tomcat, but now we are required to move our deployment to Tomee+ 1.6.
> There
> > is a weird behavior which is seen. The Autowiring seems to work only
> > sometime. So if I restart the TomEE 10 times then only 2-3 times the
> > autowiring seems to work otherwise I get a NullPointerException for the
> > auutowired object. I tried adding below options in system.properties but
> to
> > no avail. -
> > openejb.jaxrs.providers.auto=true
> > com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager = true
> > openejb.cxf.jax-rs.providers =
> >
> org.codehaus.jackson.jaxrs.JacksonJsonProvider,org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider.
> >
> > I have also tried to add a beans.xml in WEB-INF, but it didn't helped.
> > The web.xml entry for jersey servlet is as below :
> > <servlet>
> >               <servlet-name>myproject</servlet-name>
> >
> >
> <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
> >               <init-param>
> >
> > <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
> >                      <param-value>true</param-value>
> >               </init-param>
> >               <load-on-startup>2</load-on-startup>
> > </servlet>
> >
> > I am not able to understand why it works for sometimes and fail the rest
> of
> > the time. It looks like some class/library loading issue by TomEE.
> >
> >
> >
> > --
> > View this message in context:
> http://openejb.979440.n4.nabble.com/Autowiring-Spring-Injection-not-working-tomEE-1-6-plus-tp4667748.html
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Re: Autowiring Spring Injection not working tomEE 1.6 plus

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

I don't get all parts of your mail, cxf.jaxrs and provider auto are
cxf stuff totally ignored by jersey and spring.

Is tomee deploying your jaxrs endpoints? if so maybe skip the jars
containing the endpoints (see exclusion.list)
Romain Manni-Bucau
Twitter: @rmannibucau
Blog: http://rmannibucau.wordpress.com/
LinkedIn: http://fr.linkedin.com/in/rmannibucau
Github: https://github.com/rmannibucau



2014-02-12 19:26 GMT+01:00 trima <ma...@gmail.com>:
> Hi,
> I have a maven spring project which has REST URLs exposed. There are some
> autowired objects injected in the resource classes (HttpServletRequest obj
> and other custom objects of my project). This deployement works fine in
> tomcat, but now we are required to move our deployment to Tomee+ 1.6. There
> is a weird behavior which is seen. The Autowiring seems to work only
> sometime. So if I restart the TomEE 10 times then only 2-3 times the
> autowiring seems to work otherwise I get a NullPointerException for the
> auutowired object. I tried adding below options in system.properties but to
> no avail. -
> openejb.jaxrs.providers.auto=true
> com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager = true
> openejb.cxf.jax-rs.providers =
> org.codehaus.jackson.jaxrs.JacksonJsonProvider,org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider.
>
> I have also tried to add a beans.xml in WEB-INF, but it didn't helped.
> The web.xml entry for jersey servlet is as below :
> <servlet>
>               <servlet-name>myproject</servlet-name>
>
> <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class>
>               <init-param>
>
> <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
>                      <param-value>true</param-value>
>               </init-param>
>               <load-on-startup>2</load-on-startup>
> </servlet>
>
> I am not able to understand why it works for sometimes and fail the rest of
> the time. It looks like some class/library loading issue by TomEE.
>
>
>
> --
> View this message in context: http://openejb.979440.n4.nabble.com/Autowiring-Spring-Injection-not-working-tomEE-1-6-plus-tp4667748.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.