2
votes

I have a problem with beans in mule 4. There is an error when trying to invoke java:

Element 'springService' is not defined in the Mule Registry

Error occures in run time.

I have created configuration.xml and declared spring config:

<spring:config name="springConfig" doc:name="springConfig" files="beans.xml" />

Then created beans.xml in /src/main/resources:

<beans ...>
  <context:component-scan base-package="com.services" />
</beans>

com.services is an external service that has a class:

@Service
public class SpringService {
...
}

EDIT1: The way I am trying to invoke java method:

<java:invoke doc:name="Get data" doc:id="id" class="com.services.SpringService" method="#[getData(String)]" instance="springService">
          <java:args><![CDATA[#[{name: vars.name}]]]></java:args>
</java:invoke>

Stack trace:

Message : Element 'springService' is not defined in the Mule Registry

Element : test-flow/processors/2 @ test-service:test.xml:14 (Get Data)

Element DSL : <java:invoke doc:name="Get data" doc:id="id" class="com.services.SpringService" method="#[getData(String)]" instance="springService"> java:args#[{name: vars.name}]</java:args> </java:invoke> Error type : MULE:UNKNOWN

FlowStack : at test-flow(test-flow/processors/2 @ test-service:test.xml:14 (Get Data)) at get:\getData(name):test-api-config(get:\getData(name):test-api-config/processors/0 @ test-service:test-api.xml:125 (Get Data)) at test-api-main(test-api-main/processors/0 @ test-service:test-api.xml:15)

1
How are you trying to invoke the bean? Please add the XML configuration to the question. Also add the complete error, not just the description.aled
@aled I have edited my post. Could you look at it?Mateusz

1 Answers

0
votes

The documentation of the Java Module doesn't say it can invoke a Spring bean instance. The examples always mention using the new operation of the module to create instances.At the least if possiblle it is not documented how. Probably unsupported by the current version of the Java module.