Bug 1129400 - Unable to create resource-adapter using HTTP management interface
Summary: Unable to create resource-adapter using HTTP management interface
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Domain Management
Version: 6.2.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: DR1
: EAP 6.4.0
Assignee: Brian Stansberry
QA Contact: Petr Kremensky
URL:
Whiteboard:
Depends On:
Blocks: 1116788
TreeView+ depends on / blocked
 
Reported: 2014-08-12 16:45 UTC by Libor Zoubek
Modified: 2019-08-19 12:46 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
In previous versions of JBoss EAP 6, the logic in the operation to add a resource-adapter resource required that the target address be represented as a list of elements of DMR ModelType.PROPERTY. This meant that HTTP-based management clients that used JSON could not reliably create operations using the expected format (as representing the $PROPERTY element in JSON syntax can be problematic). In this release of JBoss EAP 6, the handler for the resource-adapter `add` operation has been updated to use standard address parsing code which is more forgiving of formatting differences. As a result, operations that add a resource-adapter using the HTTP interface and JSON similar to the example above now succeed as expected.
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
JBoss Issue Tracker WFLY-3732 Major Resolved RaOperationUtil cannot handle unusual address formats 2014-09-08 14:45:21 UTC

Description Libor Zoubek 2014-08-12 16:45:37 UTC
Description of problem:

JON plugin fails to create resource-adapters using HTTP management API, it can be created only using CLI.


Version-Release number of selected component (if applicable):
EAP 6.2.4.GA

How reproducible: always


Steps to Reproduce:
1. Create resource adapter via curl
curl --digest -u admin:admin http://localhost:9990/management -H "Content-Type: application/json" -H "Accept: */*" -v -X POST --data '{"operation":"add","address":[{"subsystem":"resource-adapters"},{"resource-adapter":"my-adapter"}],"archive":"test"}'


Actual results: it fails with response: 

{"outcome" : "failed", "failure-description" : "JBAS014749: Operation handler failed: null", "rolled-back" : true}

Server stacktrace: 

18:38:41,086 ERROR [org.jboss.as.controller.management-operation] (HttpManagementService-threads - 10) JBAS014612: Operation ("add") failed - address: ([
    {"subsystem" => "resource-adapters"},
    {"resource-adapter" => "my-adapter"}
]): java.lang.IllegalArgumentException
        at org.jboss.dmr.ModelValue.getChild(ModelValue.java:120) [jboss-dmr-1.2.0.Final-redhat-1.jar:1.2.0.Final-redhat-1]
        at org.jboss.dmr.ModelNode.get(ModelNode.java:903) [jboss-dmr-1.2.0.Final-redhat-1.jar:1.2.0.Final-redhat-1]
        at org.jboss.as.connector.subsystems.resourceadapters.RaOperationUtil.buildResourceAdaptersObject(RaOperationUtil.java:145)
        at org.jboss.as.connector.subsystems.resourceadapters.RaAdd.performRuntime(RaAdd.java:76)
        at org.jboss.as.controller.AbstractAddStepHandler$1.execute(AbstractAddStepHandler.java:76) [jboss-as-controller-7.3.4.Final-redhat-1.jar:7.3.4.Final-redhat-1]


Expected results: {"outcome" => "success"}


Additional info: It's possible to create resource-adapter only via CLI
[standalone@localhost:9999 /] /subsystem=resource-adapters/resource-adapter=my2nd-adapter:add(archive=test)
{"outcome" => "success"}

Comment 1 Brian Stansberry 2014-08-12 17:12:54 UTC
Not a CLI bug, since it seems the CLI works. This is either a core Domain Management issue, in how it reads the HTTP request, or a problem in the JCA component.

Comment 2 Brian Stansberry 2014-08-13 22:56:23 UTC
The problem here is RaOperationUtil is using a very unorthodox method of reading the address of the operation:

final List<ModelNode> address = operation.get(ModelDescriptionConstants.ADDRESS).asList();
final String id = address.get(address.size()-1).get(0).asString();

The issue is the ModelNode returned by "address.get(address.size()-1)".
 
When you use the CLI, the ModelNode is of ModelType.PROPERTY.

To create a ModelNode of ModelType.PROPERTY using JSON syntax is difficult. (TBH I'm not sure how to do it.) The syntax in the curl command results in a node of ModelType.OBJECT.

That get(0) call fails on ModelType.OBJECT. It's quite the quirk that it works for ModelType.PROPERTY.

Easy fix.

Comment 3 JBoss JIRA Server 2014-08-13 23:41:31 UTC
Brian Stansberry <brian.stansberry@redhat.com> updated the status of jira WFLY-3732 to Resolved


Note You need to log in before you can comment on or make changes to this bug.