[jboss-jira] [JBoss JIRA] (WFLY-5941) IllegalArgumentException when injecting dependencies for SAR

John Farrelly (JIRA) issues at jboss.org
Fri Jan 8 06:41:00 EST 2016


     [ https://issues.jboss.org/browse/WFLY-5941?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

John Farrelly closed WFLY-5941.
-------------------------------
    Resolution: Rejected


[As answered on the jboss forum|https://developer.jboss.org/thread/267180] removing {{optional-attribute-name}} attributes injected the values as expected.

> IllegalArgumentException when injecting dependencies for SAR
> ------------------------------------------------------------
>
>                 Key: WFLY-5941
>                 URL: https://issues.jboss.org/browse/WFLY-5941
>             Project: WildFly
>          Issue Type: Bug
>          Components: JMX
>    Affects Versions: 10.0.0.CR4
>         Environment: Red Hat Enterprise Linux Server release 7.1 (Maipo)
> Linux 3.10.0-229.4.2.el7.x86_64 #1 SMP Wed May 13 10:06:09 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
> java version "1.8.0_60"
> Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
> Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
>            Reporter: John Farrelly
>            Assignee: Stuart Douglas
>         Attachments: my-test.sar
>
>
> I created a service archive based on the code in {{wildfly/sar/src/test/_java}}.  I have the following files in my {{standalone/deployment}} directory:
> {noformat}
> .
> |-- my-test.sar
> |   |-- META-INF
> |   |   `-- jboss-service.xml
> |   `-- org
> |       `-- jboss
> |           `-- as
> |               `-- service
> |                   |-- LegacyService.class
> |                   `-- LegacyServiceMBean.class
> `-- my-test.sar.dodeploy
> {noformat}
> I get the following error when WildFly tries to deploy the sar:
> {noformat}
> 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
> {noformat}
> 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:
> {code:xml}
> <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>
> {code}
> The code for {{LegacyService}} is as follows:
> {code:java}
> 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");
>     }
> }
> {code}
> The code for {{LegacyServiceMBean.java}} is:
> {code:java}
> package org.jboss.as.service;
> /**
>  * @author John Bailey
>  */
> public interface LegacyServiceMBean {
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.11#64026)


More information about the jboss-jira mailing list