So I have this spring integration project. That use a gateway as a trigger to spring batch jobs. I made this interface for the gateway:
public interface TestGateway {
void trigger(String pass);
}
Then a java class that triggers the interface:
public class Trigger implements Runnable {
@Autowired
TestGateway testGateWay;
public void triggerMethod() {
testGateWay.trigger("pass");
}
@Override
public void run() {
try {
triggerMethod();
} catch (Exception e) {
e.printStackTrace();
}
}
}
every time I tried to run it an exception appear:
java.lang.NullPointerException
at com.irsis.integration.endpoint.Trigger.triggerMethod(Trigger.java:12)
at com.irsis.integration.endpoint.Trigger.run(Trigger.java:18)
at org.springframework.scheduling.support.DelegatingErrorHandling
line 22 is: testGateWay.trigger("pass");
my integration-context.xml
<context:component-scan base-package="com.irsis.integration.endpoint" />
<int:logging-channel-adapter id="logger"
log-full-message="true" level="INFO" />
<!-- gateway -->
<int:channel id="testInput" />
<int:gateway id="testGateway"
service-interface="com.irsis.integration.endpoint.TestGateway">
<int:method name="trigger" request-channel="testInput" />
</int:gateway>
<int:channel id="activate" />
<import resource="classpath*:/spring/batch/jobs/testJob.xml" />
<int:transformer input-channel="testInput"
output-channel="activate">
<bean class="com.irsis.integration.util.TriggerToJobRequest">
<property name="job" ref="testJob" />
</bean>
</int:transformer>
<int:service-activator method="launch"
input-channel="activate">
<bean id="messageHandler"
class="org.springframework.batch.integration.launch.JobLaunchingMessageHandler">
<constructor-arg ref="jobLauncher" />
</bean>
</int:service-activator>
Start of my application-context.xml
<context:annotation-config />
<context:spring-configured />
<import resource="classpath*:/spring/integration/si-batch-config.xml" />
<import resource="classpath*:/spring/integration/si-test2.xml" />
<context:component-scan base-package="com.irsis" />
Any ideas why?
Thanks,
Jet