Return-Path: X-Original-To: apmail-cxf-users-archive@www.apache.org Delivered-To: apmail-cxf-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3E24790B7 for ; Mon, 21 May 2012 20:21:49 +0000 (UTC) Received: (qmail 25390 invoked by uid 500); 21 May 2012 20:21:48 -0000 Delivered-To: apmail-cxf-users-archive@cxf.apache.org Received: (qmail 25332 invoked by uid 500); 21 May 2012 20:21:48 -0000 Mailing-List: contact users-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@cxf.apache.org Delivered-To: mailing list users@cxf.apache.org Received: (qmail 25324 invoked by uid 99); 21 May 2012 20:21:48 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 May 2012 20:21:48 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [163.231.6.26] (HELO mailout2-trp.thomsonreuters.com) (163.231.6.26) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 21 May 2012 20:21:42 +0000 Received: from trpusmneagrly02.int.westgroup.com (relay2 [163.231.22.113]) by mailout2-trp.thomsonreuters.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4LKLJWp013237 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Mon, 21 May 2012 20:21:20 GMT Received: from EAGF-ERFPHUB13.ERF.thomson.com (xch3 [163.231.31.4]) by trpusmneagrly02.int.westgroup.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q4LKLA0k024828 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=FAIL) for ; Mon, 21 May 2012 20:21:19 GMT Received: from C111WHRPMBX28.ERF.thomson.com ([fe80::9cf9:d751:cced:5839]) by EAGF-ERFPHUB13.ERF.thomson.com ([fe80::c833:49ed:82c8:5c0b%17]) with mapi id 14.01.0355.002; Mon, 21 May 2012 15:20:53 -0500 From: To: Subject: RE: @Inject annotation not working with Spring service Thread-Topic: @Inject annotation not working with Spring service Thread-Index: Ac00i4lM1viWJGs1RnOJo6tWrgYncQALE/SAAApvHcD//627AIAAU5oQ//+t8YD/+lU2AA== Date: Mon, 21 May 2012 20:20:52 +0000 Message-ID: <85EA8C7D851A1F40A3C279990CF1C18623439D28@C111WHRPMBX28.ERF.thomson.com> References: <85EA8C7D851A1F40A3C279990CF1C186234372FB@C111WHRPMBX28.ERF.thomson.com> <85EA8C7D851A1F40A3C279990CF1C18623437315@C111WHRPMBX28.ERF.thomson.com> <85EA8C7D851A1F40A3C279990CF1C1862343732A@C111WHRPMBX28.ERF.thomson.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.206.30.9] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org I figured out my issue. =20 I have two bean definition files, one for a 'core' module and one for a 'we= b' module. Both do a component scan, but the web module's scan was not for= the entire package: Core -=20 Web -=20 Both bean definition files are loaded via the contextConfiguration param, s= o I expected that both would take effect. When I changed the Web file to l= oad 'com.thomsonreuters' my injection via annotations issue went away. I'm not sure if this is expected behavior of a Spring container, I haven't = done the research at this point. I did want to follow up with the group in= case some pour sole ran into this type of situation. -----Original Message----- From: Ted [mailto:r6squeegee@gmail.com]=20 Sent: Thursday, May 17, 2012 5:44 PM To: users@cxf.apache.org Subject: Re: @Inject annotation not working with Spring service not sure off hand, you'll have to make sure the component scan is loading t= hat bean of yours and it's matching either the name or the type properly. This is a spring problem though not a CXF problem, in terms of CXF it shoul= d work as normal as it's just a bean loaded by spring (I'm assuming the web= service itself is loaded as a spring bean in the same context). You should just need to debug your spring contexts to find out what's up. On Fri, May 18, 2012 at 10:40 AM, wrote= : > Componentscan: > > xmlns=3D"http://www.springframework.org/schema/beans" > xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance" > xmlns:context=3D"http://www.springframework.org/schema/context" > xmlns:tx=3D"http://www.springframework.org/schema/tx" > xsi:schemaLocation=3D"http://www.springframework.org/schema/beans > http://www.springframework.org/schema/beans/spring-beans-3.1.xsd > > http://www.springframework.org/schema/context > http://www.springframework.org/schema/context/spring-context-3.1.xsd > > http://www.springframework.org/schema/tx > http://www.springframework.org/schema/tx/spring-tx-3.1.xsd"> > > > > > > class=3D"org.springframework.orm.jpa.support.PersistenceAnnotationBeanPos= tProcessor" > /> > . > . > . > > -----Original Message----- > From: Ted [mailto:r6squeegee@gmail.com] > Sent: Thursday, May 17, 2012 5:38 PM > To: users@cxf.apache.org > Subject: Re: @Inject annotation not working with Spring service > > yeah but how have you put it in the spring context? i.e. componentscan? > xml? or??? > > On Fri, May 18, 2012 at 10:36 AM, > wrote: > > > I'm using the @Repository annotation for the DAO: > > > > @Repository("userDAO") > > public class UserDAO { > > @PersistenceContext > > private EntityManager entityManager; > > > > @Transactional > > public void persist(User user) { > > entityManager.persist(user); > > } > > . > > . > > . > > > > > > -----Original Message----- > > From: Ted [mailto:r6squeegee@gmail.com] > > Sent: Thursday, May 17, 2012 5:34 PM > > To: users@cxf.apache.org > > Subject: Re: @Inject annotation not working with Spring service > > > > It shouldn't make any difference at all. > > > > I do the same thing but with the annotation @Component instead of=20 > > @service and @autowired instead of @Inject. > > > > The only reason I can think of that it would be null is if you don't=20 > > have a matching UserDao that's in the spring context... are you sure=20 > > you have that object in the spring context? > > > > > > > > On Fri, May 18, 2012 at 10:22 AM,=20 > > > > wrote: > > > > > I have a service that I've created using the Spring @Service > annotation. > > > I am injecting Spring dependencies into the service using the=20 > > > @Inject annotation. When I invoke my service I get a=20 > > > NullPointerException when referencing the injected dependency (in=20 > > > this > case a DAO). > > > > > > @Service("userServiceImpl-2012-02-01") > > > @WebService(serviceName =3D "UserService", name =3D "UserServicePort"= ,=20 > > > portName =3D "UserServicePort", targetNamespace =3D " > > > http://www.thomsonreuters.com/services/userservice/2012-02-01") > > > public class UserServiceImpl implements UserService { > > > > > > @Inject > > > private UserDAO userDAO; > > > > > > public UserCollectionResponse findUserByName(String userName) { > > > Collection > > > userEntityCollection =3D userDAO.findByName(userName); > > > > > > UserCollectionResponse userCollectionResponse =3D new=20 > > > UserCollectionResponse(); > > > userCollectionResponse.userCollection =3D=20 > > > userConverter.convertToServiceObject(userEntityCollection); > > > > > > return userCollectionResponse; > > > } > > > } > > > > > > When I do the same via bean definition files, so services defined=20 > > > as bean in file and dependencies injected via the bean definition=20 > > > in the file, all works okay. > > > > > > > > > > class=3D"com.thomsonreuters.services.userservice._2012_02_01.UserServi > > ce > > Impl"> > > > > > > > > > > > > > > > > > > implementor=3D"#userServiceImpl-2012-02-01" > > > > > > address=3D"/userservice/2012-02-01/userservice" > > > wsdlLocation=3D"UserService.wsdl"> > > > > > > value=3D"true"/> > > > > > > > > > > > > Anyone run into something like this? I'm not sure how using the=20 > > > annotations instead of the file definitions would cause any issues. > > > Tom > > > > > > > > > > > > -- > > Ted. > > > > > > -- > Ted. > -- Ted.