autowired

How do I resolve this “Could not initialize class org.apache.cxf.common.injection.ResourceInjector” error when autowiring a jaxws:client?

感情迁移 提交于 2019-12-11 21:38:54
问题 I’m using JBoss 7.1.3.Final, Spring 3.2.11.RELEASE, CXF 2.7.15 and Maven 3.0.3. I’m trying to autowire a web services client that is generated through the below JAX-WS plugin code … <plugin> <groupId>org.jvnet.jax-ws-commons</groupId> <artifactId>jaxws-maven-plugin</artifactId> <version>2.3</version> <executions> <execution> <goals> <goal>wsimport</goal> </goals> <configuration> <target>2.1</target> <wsdlDirectory>${basedir}/src/wsdl</wsdlDirectory> <sourceDestDir>${basedir}/src/main/java<

How to autowire a class with non-empty constructor?

主宰稳场 提交于 2019-12-11 21:06:21
问题 I'd like to @Autowired a class that has a non-empty constructor. Just the the following as an example, it does not necessairly have to be a view/service. Could be whatever component you like, having non-default constructor: @Component class MyViewService { //the "datasource" to show in the view private List<String> companies companies; private MyObject obj; public MyViewService(List<String> companies, MyObject obj) { this.companies = companies; this.obj = obj; } } Of course I cannot just

Autowiring beans implementing same interface - how to autowire a particular dependency bean in a JUnit Test?

我是研究僧i 提交于 2019-12-11 20:40:01
问题 I have a Spring 3.1/Java/Tomcat application. I have a service class that is as follows: public class SomeServiceImpl implements SomeService { @Autowired public AnotherService anotherService; // other code... This uses another service class AnotherService which is autowired. Both these services classes are declared in a serviceContext.xml file. I am writing junit to test SomeServiceImpl and use autowired to inject the class under test (SomeService) as well as the mock (EasyMock) dependency

Spring: autowiring DAO into a utility class not working

一个人想着一个人 提交于 2019-12-11 19:49:52
问题 I have an annotation driven spring mvc project templated after the JBoss web mvc sample. (Spring, Hibernate, JPA 2.0) I have a utility package where I want to put reusable classes for obviously utility functions. Specifically I have a LogonUtilities class where I want to query a database to get information. I autowire my DAO there but when I debug the DAO is always null and fails with that exception. I have read and tried many things - I know I've probably come across the solution already -

Autowired not working, dependency is null

痴心易碎 提交于 2019-12-11 15:23:58
问题 The project that I have is currently set up like so: Controller: package com.frclocks.district.controller; :imports: @Path("/districts") @Controller public class DistrictController { @Autowired private DistrictService districtService; @GET @Produces(MediaType.APPLICATION_JSON) public List<District> getDistricts() { return districtService.getAllDistricts(); } } Service (Impl): package com.frclocks.district.service; :imports: @Service("districtService") @Transactional public class

Getting null pointer exception while trying to call a service class method using a quartz 2.2 scheduler in a spring mvc web application with tomcat 8 [duplicate]

ぃ、小莉子 提交于 2019-12-11 13:59:05
问题 This question already has answers here : inject bean reference into a Quartz job in Spring? (20 answers) Closed 4 years ago . I have a java spring mvc web application which use Spring 3.2 and Tomcat 8 . I use quartz 2.2 to schedule a task. My controller class is: @Controller public class StatusController implements Job { @Autowired WebContentDefinitionService webContentDefinitionService; public void execute(JobExecutionContext arg0) throws JobExecutionException { System.out.println("Starting

why is autowired bean null in filter in this spring application? [duplicate]

守給你的承諾、 提交于 2019-12-11 13:18:29
问题 This question already has answers here : How can I get a Spring bean in a servlet filter? (5 answers) Closed 4 years ago . I have simplified our production application to reproduce the errors. This is a demo application to calculate the counts of incoming requests. when I debugged the project, I can see Null Pointer Exception being thrown at manager.incrementRequestCounter(url) line in CounterMetricsFilter class shown below. That is because manager I have autowired is NULL. However, the same

How to go about Spring autowiring?

跟風遠走 提交于 2019-12-11 12:05:27
问题 public class ProcessSchedulerServlet implements javax.servlet.Servlet { Timer timer=new Timer(); @Override public void init(ServletConfig arg0) throws ServletException { timer.scheduleAtFixedRate(new TimerTask() { public void run() { LogProcessorService logProcessorService=new LogProcessorServiceImpl(); logProcessorService.processPageRequestsLogs(); } }, 60*1000, 120*1000); } This is ugly and it doesn't work, anyway. The LogProcessorServiceImpl has properties with @Autowired annotation. These

Spring passsing autowired object to class constructor

亡梦爱人 提交于 2019-12-11 11:47:32
问题 I got problem with my SpringMVC application I have class annotated with @Component with 2 fields annotated with @Autowired @Component public class Crud { private final Logger logger = LoggerFactory.getLogger(Crud.class); private final Map<String, Database> dataSources = new HashMap<>(); @Autowired private DataSource clientDataSource; @Autowired private DataSource adminDataSource; public Crud(){ dataSources.put("client", new Database(clientDataSource)); dataSources.put("admin", new Database

Spring Autowire primitive boolean

我是研究僧i 提交于 2019-12-11 11:42:42
问题 My XML configuration includes these bean definitions: <bean id="abstractFormAction" class="staffing.server.action.form.AbstractFormAction" abstract="true" parent="baseAction"> <property name="volunteerSaver" ref="volunteerSaver"/> <property name="emailSender" ref="emailSender"/> <property name="closed" value="${form.closed}"/> </bean> <bean id="volunteerFormAction" class="staffing.server.action.form.VolunteerFormAction" parent="abstractFormAction"> <property name="captchaGenerator" ref=