[GLASSFISH-18184] Win 2008. "delete-local-instance <instance_name>" created an error: com.sun.enterprise.config.serverbeans.Server : wrong number of arguments Created: 13/Jan/12  Updated: 31/Jan/12  Resolved: 31/Jan/12

Status: Resolved
Project: glassfish
Component/s: other
Affects Version/s: 3.1.2_b17
Fix Version/s: 3.1.2_b20

Type: Bug Priority: Critical
Reporter: easarina Assignee: Mahesh Kannan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File setup_cl.pl     File unsetup_cl.pl    
Tags: 3_1_2-review, 3_1_2_qa

 Description   

Win 2008 GF 3.1.2 b17. Created a cluster with two instances, started instances, then stopped a cluster and executed

delete-local-instance <instance_name>

That command returned the follow error:

remote failure: Exception while deleting the configuration com.sun.enterprise.config.serverbeans.Server : wrong number of arguments
Command delete-local-instance failed.

This problem happened sometimes, but if it happened, all such commands return this error, until DAS will be restarted.

I did not see this issue for previous GF 3.1.2 builds, but constantly see this issue for b17 on the different Win 2008 machines. In all cases was used JDK 1.7.0_02.

To reproduce the issue, I've run many times these two attached scripts: setup_cl.pl, unsetup_cl.pl.

In server.log I saw only the same error message. See bellow the debug output:

==================================================================================
C:\hudson\workspace\Cluster>glassfish3\glassfish\bin\asadmin delete-local-instance my-in1
CLASSPATH= C:\hudson\workspace\Cluster\glassfish3\glassfish\bin\..\modules\admin-cli.jar
Commands: [delete-local-instance, my-in1]
asadmin extension directory: C:\hudson\workspace\Cluster\glassfish3\glassfish\lib\asadmin
Prepare
Process program options
Parsing program options
Parse command options
params: {}
operands: [my-in1]
Prevalidate command options
Inject command options
Validate command options
nodeDirChild: C:\hudson\workspace\Cluster\glassfish3\glassfish\nodes\localhost-domain1
instanceDir: C:\hudson\workspace\Cluster\glassfish3\glassfish\nodes\localhost-domain1\my-in1
asadmin --host localhost --port 4848 --interactive=true --echo=false --terse=false delete-local-instance my-in1
Execute command
Prepare
Parsing program options
URI: /__asadmin/uptime?Xhelp=true
URL: com.sun.enterprise.admin.util.HttpConnectorAddress@21f4c81c
URL: http://localhost:4848/__asadmin/uptime?Xhelp=true
Password options: null
Using auth info: User: null, Password: <null>
Response Content-Type: text/xml
------- RAW METADATA RESPONSE ---------
<?xml version="1.0" encoding="UTF-8" standalone="no"?><action-report description="uptime help" exit-code="SUCCESS"><message-part message=""><property name="Gene
ratedHelp" value="true"/><command name="uptime"><option default="false" name="milliseconds" optional="true" type="BOOLEAN"/></command></message-part></action-re
port>
------- RAW METADATA RESPONSE ---------
fetchCommandModel: got command opts: com.sun.enterprise.admin.util.CommandModelData@caad9a
doHttpCommand succeeds
Process program options
Parsing program options
Parse command options
params: {milliseconds: [true]
}
operands: []
Prevalidate command options
Inject command options
Validate command options
asadmin --host localhost --port 4848 --interactive=true --echo=false --terse=false uptime --milliseconds=true
Execute command
doUpload set to false
URI: /__asadmin/uptime?milliseconds=true
URL: com.sun.enterprise.admin.util.HttpConnectorAddress@6a13a848
URL: http://localhost:4848/__asadmin/uptime?milliseconds=true
Password options: null
Using auth info: User: null, Password: <null>
------- RAW RESPONSE ---------
Signature-Version: 1.0
message: 318834
milliseconds_value: 318834
keys: milliseconds
milliseconds_name: milliseconds
use-main-children-attribute: false
exit-code: SUCCESS

------- RAW RESPONSE ---------
PROCESSING MANIFEST...
doHttpCommand succeeds
server uptime: 318834
Prepare
Parsing program options
URI: /__asadmin/get?Xhelp=true
URL: com.sun.enterprise.admin.util.HttpConnectorAddress@2d14a694
URL: http://localhost:4848/__asadmin/get?Xhelp=true
Password options: null
Using auth info: User: null, Password: <null>
Response Content-Type: text/xml
------- RAW METADATA RESPONSE ---------
<?xml version="1.0" encoding="UTF-8" standalone="no"?><action-report description="get help" exit-code="SUCCESS"><message-part message=""><property name="Generat
edHelp" value="true"/><command name="get"><option default="false" name="monitor" optional="true" short="m" type="BOOLEAN"/><operand max="1" min="1" name="patter
n" type="STRING"/></command></message-part></action-report>
------- RAW METADATA RESPONSE ---------
fetchCommandModel: got command opts: com.sun.enterprise.admin.util.CommandModelData@26c455ab
doHttpCommand succeeds
Process program options
Parsing program options
Parse command options
params: {}
operands: [servers.server.my-in1]
Prevalidate command options
Inject command options
Validate command options
asadmin --host localhost --port 4848 --interactive=true --echo=false --terse=false get --monitor=false servers.server.my-in1
Execute command
doUpload set to false
URI: /__asadmin/get?DEFAULT=servers.server.my-in1
URL: com.sun.enterprise.admin.util.HttpConnectorAddress@23d4616f
URL: http://localhost:4848/__asadmin/get?DEFAULT=servers.server.my-in1
Password options: null
Using auth info: User: null, Password: <null>
------- RAW RESPONSE ---------
Signature-Version: 1.0
message:
children: servers.server.my-in1.config-ref=my-c1-config;servers.server
.my-in1.lb-weight=100;servers.server.my-in1.name=my-in1;servers.serve
r.my-in1.node-ref=localhost-domain1
use-main-children-attribute: true
children-type: null
exit-code: SUCCESS

Name: servers.server.my-in1.node-ref=localhost-domain1
message:

Name: servers.server.my-in1.name=my-in1
message:

Name: servers.server.my-in1.lb-weight=100
message:

Name: servers.server.my-in1.config-ref=my-c1-config
message:

------- RAW RESPONSE ---------
PROCESSING MANIFEST...
doHttpCommand succeeds
Prepare
Parsing program options
URI: /__asadmin/_unregister-instance?Xhelp=true
URL: com.sun.enterprise.admin.util.HttpConnectorAddress@4c48d0c9
URL: http://localhost:4848/__asadmin/_unregister-instance?Xhelp=true
Password options: null
Using auth info: User: null, Password: <null>
Response Content-Type: text/xml
------- RAW METADATA RESPONSE ---------
<?xml version="1.0" encoding="UTF-8" standalone="no"?><action-report description="_unregister-instance help" exit-code="SUCCESS"><message-part message=""><prope
rty name="GeneratedHelp" value="true"/><command name="_unregister-instance"><option name="node" optional="true" type="STRING"/><option name="target" optional="t
rue" type="STRING"/><operand max="1" min="1" name="name" type="STRING"/></command></message-part></action-report>
------- RAW METADATA RESPONSE ---------
fetchCommandModel: got command opts: com.sun.enterprise.admin.util.CommandModelData@4083633f
doHttpCommand succeeds
Process program options
Parsing program options
Parse command options
params: {node: [localhost-domain1]
}
operands: [my-in1]
Prevalidate command options
Inject command options
Validate command options
asadmin --host localhost --port 4848 --interactive=true --echo=false --terse=false _unregister-instance --node localhost-domain1 my-in1
Execute command
doUpload set to false
URI: /__asadmin/_unregister-instance?node=localhost-domain1&DEFAULT=my-in1
URL: com.sun.enterprise.admin.util.HttpConnectorAddress@71e8de2f
URL: http://localhost:4848/__asadmin/_unregister-instance?node=localhost-domain1&DEFAULT=my-in1
Password options: null
Using auth info: User: null, Password: <null>
------- RAW RESPONSE ---------
Signature-Version: 1.0
message: Exception while deleting the configuration com.sun.enterprise
.config.serverbeans.Server : wrong number of arguments
use-main-children-attribute: false
exit-code: FAILURE

------- RAW RESPONSE ---------
PROCESSING MANIFEST...
remote failure: Exception while deleting the configuration com.sun.enterprise.config.serverbeans.Server : wrong number of arguments
Command delete-local-instance failed.



 Comments   
Comment by easarina [ 13/Jan/12 ]

If between instance creation and instance deleting many other commands were executed, then, with a big probability, this problem will be seen. At least, when I've executed an automated test, the problem was seen in 4 executions from 5 executions totally. And I did not see this issue for the previous builds.

Comment by Tom Mueller [ 13/Jan/12 ]

What other commands?

Comment by easarina [ 13/Jan/12 ]

There were a lot of the different commands. But I was able to reproduce the issue just using create and delete instance commands, see the attached scripts.

Comment by Tom Mueller [ 13/Jan/12 ]

The root cause of this issue is in the HK2 ConfigSupport._deleteChild method.

This method has the following code:

     for (Method m : parentProxyType.getMethods()) {
         final Class returnType = m.getReturnType();
         if (Collection.class.isAssignableFrom(returnType)) {
              // this could be it...
              if (!(m.getGenericReturnType() instanceof ParameterizedType))
                     throw new IllegalArgumentException("List needs to be parameterized");
              final Class itemType = Types.erasure(Types.getTypeArgument(m.getGenericReturnType(), 0));
              if (itemType.isAssignableFrom(childType)) {

Given a childType such as Server, this code is looking for a method such as:

    List<Server> getServer()

However, the Servers config bean, which is being operated on in this case, has more than one method that returns List<Server>

interface Servers ... {
    public List<Server> getServer();
    public List<Server> getServersOnNode(Node node);
}

If the loop encounters the 2nd method first, an "IllegalArgumentException: wrong number of arguments" is thrown because the code try to invoke the method with no arguments but getServersOnNode takes one argument. If the loop encounters the 1st method first, then it works fine.

Suggested fix: add a check to the loop to make sure the found method takes the expected number of parameters (0).

Comment by Tom Mueller [ 13/Jan/12 ]

Assigning to Mahesh since this is an HK2 problem.

The bug is in the HK2 config module, in the ConfigSupport.java file at about line 792. To fix the bug, a check has to be added to see if m.getParameterTypes().length == 0.

To reproduce the problem, you have to run the script about 10-20 times.

Comment by Mahesh Kannan [ 31/Jan/12 ]

svn diff
Index: config/src/main/java/org/jvnet/hk2/config/ConfigSupport.java
===================================================================
— config/src/main/java/org/jvnet/hk2/config/ConfigSupport.java (revision 2533)
+++ config/src/main/java/org/jvnet/hk2/config/ConfigSupport.java (working copy)
@@ -787,7 +787,7 @@
// type will not work.
for (Method m : parentProxyType.getMethods()) {
final Class returnType = m.getReturnType();

  • if (Collection.class.isAssignableFrom(returnType)) {
    + if (Collection.class.isAssignableFrom(returnType) && (m.getParameterTypes().length == 0)) {
    // this could be it...
    if (!(m.getGenericReturnType() instanceof ParameterizedType))
    throw new IllegalArgumentException("List needs to be parameterized");

svn commit -m "Fix for 18184. Admin/cli tests passed. Approved by Joe Di Pol, Reviewed by Tom Muller"
Sending config/src/main/java/org/jvnet/hk2/config/ConfigSupport.java
Transmitting file data .
Committed revision 2539.

Approved by: Joe Di Pol

What is the impact on the customer of the bug?
This problem happened sometimes, but if it happened, all such commands return this error, until DAS will be restarted.

What is the cost/risk of fixing the bug?
Not much. Touched one file and one line

Is there an impact on documentation or message strings?
Not for documentation.

Which tests should QA (re)run to verify the fix did not destabilize GlassFish?
The one listed in the bug report itself

Which is the targeted build of 3.1.2 for this fix?
3_1_2_b20

Comment by Mahesh Kannan [ 31/Jan/12 ]

Integrated new HK2 version

svn commit -m "Integrate new hk2 version (fix for 18184). Approved by Joe. QL Passed"
Sending pom.xml
Transmitting file data .
Committed revision 52356.

Generated at Wed Mar 04 23:13:13 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.