[WildFly 10 CR4] IllegalArgumentException when injecting dependencies for SAR
johnatopenet Jan 7, 2016 9:44 AMI created a service archive based on the code in wildfly/sar/src/test/_java. I have the following files in my standalone/deployment directory:
. |
|-- my-test.sar |
| |-- META-INF |
| | `-- jboss-service.xml |
| `-- org |
| `-- jboss |
| `-- as |
| `-- service |
| |-- LegacyService.class |
| `-- LegacyServiceMBean.class |
`-- my-test.sar.dodeploy |
I get the following error when WildFly tries to deploy the sar:
10:47:01,472 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC000001: Failed to start service jboss.mbean.service.jboss:name=testTwo,type=service.create: org.jboss.msc.service.StartException in service jboss.mbean.service.jboss:name=testTwo,type=service.create: Failed to start service |
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_60] |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_60] |
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_60] |
Caused by: org.jboss.msc.inject.InjectionException: Injection failed |
at org.jboss.msc.inject.MethodInjector.inject(MethodInjector.java:102) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
at org.jboss.msc.service.ServiceControllerImpl.doInject(ServiceControllerImpl.java:1672) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
at org.jboss.msc.service.ServiceControllerImpl.access$2000(ServiceControllerImpl.java:51) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
at org.jboss.msc.service.ServiceControllerImpl$StartTask.performInjections(ServiceControllerImpl.java:1917) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1876) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
... 3 more |
Caused by: java.lang.IllegalArgumentException: argument type mismatch |
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.8.0_60] |
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) [rt.jar:1.8.0_60] |
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.8.0_60] |
at java.lang.reflect.Method.invoke(Method.java:497) [rt.jar:1.8.0_60] |
at org.jboss.msc.inject.MethodInjector.inject(MethodInjector.java:92) [jboss-msc-1.2.6.Final.jar:1.2.6.Final] |
... 7 more |
Debugging through the JBoss code, I can see that it is trying to call setOther with an ObjectName instead of the actual LegacyService that the objectname points to.
Attached is the sar file that I tried to deploy. The META-INF/jboss-service.xml file has the following content:
<server xmlns="urn:jboss:service:7.0" |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd"> |
<mbean name="jboss:name=test,type=service" code="org.jboss.as.service.LegacyService"> |
<constructor> |
<arg value="Test Value" type="java.lang.String"/> |
</constructor> |
</mbean> |
<mbean name="jboss:name=testTwo,type=service" code="org.jboss.as.service.LegacyService"> |
<depends optional-attribute-name="other">jboss:name=test,type=service</depends> |
<attribute name="somethingElse"> |
<value-factory bean="jboss:name=test,type=service" method="appendSomethingElse"> |
<parameter class="java.lang.String">more value</parameter> |
</value-factory> |
</attribute> |
</mbean> |
<mbean name="jboss:name=testThree,type=service" code="org.jboss.as.service.LegacyService"> |
<attribute name="other"> |
<inject bean="jboss:name=testTwo,type=service" property="other"/> |
</attribute> |
<attribute name="somethingElse">Another test value</attribute> |
</mbean> |
</server> |
The code for LegacyService is as follows:
package org.jboss.as.service; |
import org.jboss.logging.Logger; |
/** |
* @author John E. Bailey |
*/ |
public class LegacyService implements LegacyServiceMBean { |
private static final Logger logger = Logger.getLogger(LegacyService.class); |
private LegacyService other; |
private String somethingElse; |
public LegacyService() { |
} |
public LegacyService(String somethingElse) { |
this.somethingElse = somethingElse; |
} |
public void setOther(LegacyService other) { |
this.other = other; |
} |
public LegacyService getOther() { |
return other; |
} |
public String getSomethingElse() { |
return somethingElse; |
} |
public String appendSomethingElse(String more) { |
return somethingElse + " - " + more; |
} |
public void setSomethingElse(String somethingElse) { |
this.somethingElse = somethingElse; |
} |
public void start() { |
logger.info("Started"); |
} |
public void stop() { |
logger.info("Stopped"); |
} |
} |
The code for LegacyServiceMBean.java is:
package org.jboss.as.service; |
/** |
* @author John Bailey |
*/ |
public interface LegacyServiceMBean { |
} |
Has anyone seen this error before, or any ideas on what the solution to the issue may be?
Thanks,
John.