WildFly
  1. WildFly
  2. WFLY-1189

java:properties element in SAR deployments are no longer supported

    Details

    • Type: Feature Request Feature Request
    • Status: Open Open (View Workflow)
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: JMX
    • Security Level: Public (Everyone can see)
    • Labels:
    • Similar Issues:
      Show 10 results 

      Description

      I have a SAR deployment that works in AS 4.2.3. It no longer deploys in AS 7.1.1.Final. The problem is due to the fact that the java:properties element is no longer supported in AS 7 whereas it was supported in AS 4.2.3.

      Here's what my jboss-service.xml looks like that FAILS to parse in AS 7 (this works in AS 4.2.3):

      <?xml version="1.0" encoding="UTF-8"?>
      <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 code="org.rhq.enterprise.server.core.comm.ServerCommunicationsService"
      name="rhq:service=ServerCommunications">

      <attribute name="ConfigurationOverrides" serialDataType="jbxb">
      <java:properties xmlns:java="urn:jboss:java-properties"
      xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
      xs:schemaLocation="urn:jboss:java-properties resource:java-properties_1_0.xsd">
      <java:property>
      <java:key>foo</java:key>
      <java:value>bar</java:value>
      </java:property>
      </java:properties>
      </attribute>

      </mbean>
      </server>

      Notice the <attribute> has a child "java:properties" because the MBean uses Properties as the attribute type.

      Here's the AS7 error I see in the log when that SAR attempts to be deployed:

      22:30:31,921 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-7) MSC00001: Failed to start service jboss.deployment.unit."rhq-enterprise-server-services.sar".PARSE: org.jboss.msc.service.StartException in service jboss.deployment.unit."rhq-enterprise-server-services.sar".PARSE: Failed to process phase PARSE of deployment "rhq-enterprise-server-services.sar"
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:119) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1811) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
      at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1746) [jboss-msc-1.0.2.GA.jar:1.0.2.GA]
      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [rt.jar:1.6.0_29]
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [rt.jar:1.6.0_29]
      at java.lang.Thread.run(Thread.java:662) [rt.jar:1.6.0_29]
      Caused by: org.jboss.as.server.deployment.DeploymentUnitProcessingException: JBAS017224: Failed to parse service xml ["/home/mazz/source/rhq/dev-container/jbossas/standalone/deployments/rhq-enterprise-server-services.sar/META-INF/jboss-service.xml"]
      at org.jboss.as.service.ServiceDeploymentParsingProcessor.deploy(ServiceDeploymentParsingProcessor.java:95)
      at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:113) [jboss-as-server-7.1.1.Final.jar:7.1.1.Final]
      ... 5 more
      Caused by: java.lang.IllegalStateException: Not a textual event (START_ELEMENT)
      at com.ctc.wstx.sr.BasicStreamReader.throwNotTextual(BasicStreamReader.java:5444)
      at com.ctc.wstx.sr.BasicStreamReader.getText(BasicStreamReader.java:833)
      at org.jboss.staxmapper.XMLExtendedStreamReaderImpl.getText(XMLExtendedStreamReaderImpl.java:275) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
      at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.unexpectedContent(JBossServiceXmlDescriptorParser.java:622)
      at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.parseAttribute(JBossServiceXmlDescriptorParser.java:346)
      at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.parseMBean(JBossServiceXmlDescriptorParser.java:257)
      at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.readElement(JBossServiceXmlDescriptorParser.java:183)
      at org.jboss.as.service.descriptor.JBossServiceXmlDescriptorParser.readElement(JBossServiceXmlDescriptorParser.java:46)
      at org.jboss.staxmapper.XMLMapperImpl.processNested(XMLMapperImpl.java:110) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
      at org.jboss.staxmapper.XMLMapperImpl.parseDocument(XMLMapperImpl.java:69) [staxmapper-1.1.0.Final.jar:1.1.0.Final]
      at org.jboss.as.service.ServiceDeploymentParsingProcessor.deploy(ServiceDeploymentParsingProcessor.java:88)
      ... 6 more

      If I were to completely remove the <attribute> XML and the child elements, this SAR deploys in AS7 without that error. I can only assume the source of the problem is because <java:properties> type is no longer supported.

      I don't know if this means anything but I looked in <as7-install-dir>/docs/schema and I do not see any java-properties_1_0.xsd (this file that is hosted on jboss.org: http://www.jboss.org/j2ee/schema/java-properties_1_0.xsd )

        Activity

        Hide
        John Mazzitelli
        added a comment -

        I am going to look to see if the simpler format for Properties is still supported - if it is, I can just use that and not rely on java:properties (see this other JIRA's comment for what I'm talking about: https://issues.jboss.org/browse/JBAS-4448?focusedCommentId=12419651&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12419651 )

        Show
        John Mazzitelli
        added a comment - I am going to look to see if the simpler format for Properties is still supported - if it is, I can just use that and not rely on java:properties (see this other JIRA's comment for what I'm talking about: https://issues.jboss.org/browse/JBAS-4448?focusedCommentId=12419651&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-12419651 )
        Hide
        John Mazzitelli
        added a comment -

        The simple format for java.util.Properties attributes is also no longer supported in AS7. I created a simple MBean with a java.util.Properties attribute and put this as my <attribute> XML in my SAR jboss-service.xml:

        <attribute name="Props">
        foo=bar
        vari=$

        {jboss.home.dir}

        /docs
        </attribute>

        As a test, I just printed out to stdout the value of the Properties object AS7 passes into my setter:

        public void setProps(java.util.Properties p)

        { System.out.println("SET-->" + p); props = p; }

        When I ran the server, I got this error in the log file and my setter was passed in a null:

        22:56:23,051 WARN [org.jboss.as.deployment.service] (MSC service thread 1-2) JBAS017201: Unable to find PropertyEditor for type class java.util.Properties
        22:56:23,084 INFO [stdout] (MSC service thread 1-2) SET-->null

        So right now, I do not see a way to pass in java.util.Properties as an attribute to an MBean via a SAR in AS 7.1.1.Final.

        Show
        John Mazzitelli
        added a comment - The simple format for java.util.Properties attributes is also no longer supported in AS7. I created a simple MBean with a java.util.Properties attribute and put this as my <attribute> XML in my SAR jboss-service.xml: <attribute name="Props"> foo=bar vari=$ {jboss.home.dir} /docs </attribute> As a test, I just printed out to stdout the value of the Properties object AS7 passes into my setter: public void setProps(java.util.Properties p) { System.out.println("SET-->" + p); props = p; } When I ran the server, I got this error in the log file and my setter was passed in a null: 22:56:23,051 WARN [org.jboss.as.deployment.service] (MSC service thread 1-2) JBAS017201: Unable to find PropertyEditor for type class java.util.Properties 22:56:23,084 INFO [stdout] (MSC service thread 1-2) SET-->null So right now, I do not see a way to pass in java.util.Properties as an attribute to an MBean via a SAR in AS 7.1.1.Final.
        Hide
        John Mazzitelli
        added a comment -

        As a hack/workaround, the following gets me almost all (but not all) of what I need.

        In my MBean impl class (for lack of a better place to put it), I added this static block:

        static

        { java.beans.PropertyEditorManager.registerEditor(java.util.Properties.class, org.rhq.PropertiesPropertyEditor.class); }

        And this org.rhq.PropertiesPropertyEditor class looks like:

        public class PropertiesPropertyEditor extends java.beans.PropertyEditorSupport {
        private String asText;
        public String getAsText()

        { return asText; }

        public void setAsText( String props ) {
        Properties p = new Properties();
        ByteArrayInputStream is;
        try

        { is = new ByteArrayInputStream( props.getBytes() ); p.load(is); this.setValue(p); asText = props; }

        catch (IOException e1)

        { throw new IllegalArgumentException(e1.getMessage()); }

        }
        }

        My XML looks like:

        <attribute name="Props">
        foo=bar
        vari=$

        {jboss.home.dir}/docs
        </attribute>


        And the Properties gets passed into my MBean OK, but with these values (this is the toString of the properties object):

        {vari=${jboss.home.dir}

        /docs, foo=bar}

        The problem is that the $

        {x} variable is not replaced. We need replacement of the ${x}

        sysprop variables performed as well.

        Suffice it to say, it would be better if AS7 just supported this out of box.

        Show
        John Mazzitelli
        added a comment - As a hack/workaround, the following gets me almost all (but not all) of what I need. In my MBean impl class (for lack of a better place to put it), I added this static block: static { java.beans.PropertyEditorManager.registerEditor(java.util.Properties.class, org.rhq.PropertiesPropertyEditor.class); } And this org.rhq.PropertiesPropertyEditor class looks like: public class PropertiesPropertyEditor extends java.beans.PropertyEditorSupport { private String asText; public String getAsText() { return asText; } public void setAsText( String props ) { Properties p = new Properties(); ByteArrayInputStream is; try { is = new ByteArrayInputStream( props.getBytes() ); p.load(is); this.setValue(p); asText = props; } catch (IOException e1) { throw new IllegalArgumentException(e1.getMessage()); } } } My XML looks like: <attribute name="Props"> foo=bar vari=$ {jboss.home.dir}/docs </attribute> And the Properties gets passed into my MBean OK, but with these values (this is the toString of the properties object): {vari=${jboss.home.dir} /docs, foo=bar} The problem is that the $ {x} variable is not replaced. We need replacement of the ${x} sysprop variables performed as well. Suffice it to say, it would be better if AS7 just supported this out of box.
        Hide
        John Mazzitelli
        added a comment -

        Here's a better workaround for this bug. You can reuse the JBoss properties editor rather than impl another one. In the MBean impl class:

        static

        { java.beans.PropertyEditorManager.registerEditor(java.util.Properties.class, org.jboss.util.propertyeditor.PropertiesEditor.class); }

        in the SAR MANIFEST.MF, put "org.jboss.common-core" in the Dependencies.

        This has the added bonus of doing the sysprop replacement too.

        Show
        John Mazzitelli
        added a comment - Here's a better workaround for this bug. You can reuse the JBoss properties editor rather than impl another one. In the MBean impl class: static { java.beans.PropertyEditorManager.registerEditor(java.util.Properties.class, org.jboss.util.propertyeditor.PropertiesEditor.class); } in the SAR MANIFEST.MF, put "org.jboss.common-core" in the Dependencies. This has the added bonus of doing the sysprop replacement too.
        Hide
        John Mazzitelli
        added a comment -

        FYI: after I worked around this problem as per the previous comments, I then hit this: AS7-5342

        Show
        John Mazzitelli
        added a comment - FYI: after I worked around this problem as per the previous comments, I then hit this: AS7-5342
        Hide
        John Mazzitelli
        added a comment -

        FYI: after I worked around this problem and ignored AS7-5342, I hit this problem: AS7-5343

        Note that all three can use the "test.sar" attachment found in AS7-5343 to replicate the bugs.

        Show
        John Mazzitelli
        added a comment - FYI: after I worked around this problem and ignored AS7-5342, I hit this problem: AS7-5343 Note that all three can use the "test.sar" attachment found in AS7-5343 to replicate the bugs.
        Hide
        RH Bugzilla Integration
        added a comment -

        John Mazzitelli <mazz@redhat.com> made a comment on bug 851268

        I've got some notes on this port work found here on the wiki:

        https://docs.jboss.org/author/display/RHQ/Hosting+RHQ+Server+in+AS7

        Show
        RH Bugzilla Integration
        added a comment - John Mazzitelli <mazz@redhat.com> made a comment on bug 851268 I've got some notes on this port work found here on the wiki: https://docs.jboss.org/author/display/RHQ/Hosting+RHQ+Server+in+AS7
        Hide
        RH Bugzilla Integration
        added a comment -

        John Mazzitelli <mazz@redhat.com> made a comment on bug 851268

        removing all the external bug tracking links - the bugzilla integration to jira is not good:

        I will add "see also" links from this BZ to these:

        https://issues.jboss.org/browse/AS7-5342
        https://issues.jboss.org/browse/AS7-5336
        https://issues.jboss.org/browse/AS7-5321
        https://issues.jboss.org/browse/AS7-5177
        https://issues.jboss.org/browse/AS7-887
        https://issues.jboss.org/browse/AS7-3199

        Show
        RH Bugzilla Integration
        added a comment - John Mazzitelli <mazz@redhat.com> made a comment on bug 851268 removing all the external bug tracking links - the bugzilla integration to jira is not good: I will add "see also" links from this BZ to these: https://issues.jboss.org/browse/AS7-5342 https://issues.jboss.org/browse/AS7-5336 https://issues.jboss.org/browse/AS7-5321 https://issues.jboss.org/browse/AS7-5177 https://issues.jboss.org/browse/AS7-887 https://issues.jboss.org/browse/AS7-3199

          People

          • Assignee:
            Unassigned
            Reporter:
            John Mazzitelli
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated: