VMware Cloud Community
eservent
Enthusiast
Enthusiast

DynamicTypes ClassCastException problem

Hello,

I just upgraded from vRO 7.2 to 7.4. I didn't change DynamicTypes plugin version (it was already version 1.3.0 before upgrade).

And now, I have a very strange error that I couldn't succeed to manage.

My DynamicsTypes use a type parent (type folder), a type children (relation between them) and actions binding.

I'm quite sure there are no probems with the types configuration as every thing worked fine before upgrade with same plugin version...

And there were no problems at all, when I removed all types and reinstalled them from scratch after upgrade.

The workflow is very simple. I have only one input of type my children DynamicType.

And one single script that log the id of the object input.

After running the workflow and selected one object, there is the following exception :

Scriptable task (item5) : java.lang.ClassCastException: ch.dunes.model.type.TypeConverter$NullObject cannot be cast to com.vmware.o11n.plugin.dynamictypes.model.DynamicObject

I searched on the forum and outside and didn't find any answer.

Do you have an idea of the cause and maybe a solution, please ?

Thank you,

Emmanuel.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Emmanuel.
Tags (1)
Reply
0 Kudos
6 Replies
iiliev
VMware Employee
VMware Employee

Hi,

Could you provide the full error stack trace? It should be available in the vRO log file(s) (the main one is /var/log/vco/app-server/server.log). This should show the sequence of calls when error happened.

The error message suggests some problem with the registration of the dynamic types, but you said you were able to select your input object and run the workflow, so it looks like the problem may not be with the registration.

When you said you removed the types and reinstalled them from scratch do you mean you removed them using the DT configuration workflows and defined the types again manually? Or you had an exported DT configuration package containing your types and you imported them again?

Also, I assume that after the above operation all is working now, and the problem is only that it didn't work out of the box after 7.2 > 7.4 upgrade and you had to manually fix it, is that correct?

Reply
0 Kudos
eservent
Enthusiast
Enthusiast

Hi Ilian,

Thank you for your reply.

Here is the log attached.

The first line is :

Action 'findObjectById' in module 'helpers.dynamictypes' failed : Server error : ch.dunes.model.sdk.SDKFinderException: Unable to execute 'fetchAll' for type : VCACHost : 'ch.dunes.model.sdk.SDKFinderException: Unable to perform operation 'fetchAll' on finder 'VCACHost' reason : null'

I try to understand why there is a problem with an other object "VCACHost".

I found out that I call a vCACCAFE:VCACHost in my findObjectById action (next sample is simplified but bug occured).

var objectProps = new Properties();

var hostname = id;

objectProps.put("id", id);

objectProps.put("name", id);

objectProps.put("hostname", hostname);

var vcaccafeHost = Server.findAllForType("vCACCAFE:VCACHost")[0];

var typeArr = type.split(".");

var namespace = typeArr[0];

var typeName = typeArr[1];

var objectId = id;

var objectName = vcaccafeHost.name + " " + hostname;

resultObj = DynamicTypesManager.makeObject(namespace, typeName, objectId, objectName, new Array());

return resultObj;

If I remove the line Server.findAllForType, it's working perfectly ! When I call it, it's always failed with the ClassCastException.

But I need it...

I checked my VCACCAFE host, and I was surprised to see 2 hosts, and not only one as I configured VRO before.

I tried to remove the "Default" host, but it always comes back after running the line (Server.findAllForType("vCACCAFE:VCACHost")). Maybe, it's because I use VRA auth for VRO?

Even if I force to use the one I created (not the Default one: var vcaccafeHost = Server.findForType("vCACCAFE:VCACHost", "81106e9d-a4c2-4e4d-9da7-29f0de680962");), the error still occured...but for an other reason :

Action 'findObjectById' in module 'helpers.dynamictypes' failed : Server error : ch.dunes.model.sdk.SDKFinderException: Unable to perform operation 'find('VCACHost', '81106e9d-a4c2-4e4d-9da7-29f0de680962')' on plugin 'vCACCAFE' reason : 'null'

I don't understand what's happen. The problem seems to be in the VCACCAFE plugin, but the error occured only when I try to use it with DynamicTypes. If I uses the lines Server.findAllForType of Server.findForType in a simple script, there is no problem at all.

Do you have an idea?

Thank you very much for your help.

Emmanuel.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Emmanuel.
Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

Thanks for the sample code, I'll try to reproduce the error in my 7.4 environment.

Could you add an extra System.log() statements in your action to log what exactly is returned by Server.findAllForType(...) call? I suppose it may return a null or an empty array thus causing issues when trying to access its first element. BTW, there are some differences in the way actions and workflows are handled/invoked, so it is possible for this code to work if your findObjectById is implemented as a workflow instead as an action (although this could problematic as workflows are executed much slower than actions).

There seems to be some problem with the attached log file. It appears to be empty (0 bytes length) when I download it.

Also, could you check the exact build number of DT plug-in, just to make sure that the upgrade was OK? This can be done by opening the URL https://vroaddress:port/vco/api/plugins in a browser (replace vroaddress and port with the actual values for your environment; port is 8281 or 443 depending on whether vRO is a standalone appliance or embedded in vRA). In the returned output, search for dynamictypes string and check the buildNumber attribute; for DT plug-in in vRO 7.4 it should be 7052852

Reply
0 Kudos
eservent
Enthusiast
Enthusiast

Thank you again for your help.

Here is the plugin version : <buildNumber>7052852</buildNumber>.

It's the same as you.

I put a System.log() of the size of Server.findAllForType and, the size was 0, as you expected.

[2018-12-17 15:23:07.285] [I] (helpers.dynamictypes/findObjectById) Size Of VCACCAFE Hosts : 0

[2018-12-17 15:23:07.286] [I] (helpers.dynamictypes/findObjectById) First Of VCACCAFE Host : undefined

[2018-12-17 15:23:07.310] [E] Workflow execution stack:

***

item: 'Delete VM Resource/item2', state: 'failed', business state: 'null', exception: 'ch.dunes.model.type.TypeConverter$NullObject cannot be cast to com.vmware.o11n.plugin.dynamictypes.model.DynamicObject'

workflow: 'Delete VM Resource'

This is the workflow log. But the server.log is different. We can see that for one thread (https-jsse-nio-0.0.0.0-8281-exec-8), it's ok, and for an other one (WorkflowExecutorPool-Thread-5), it's failed.

New action script :

var objectProps = new Properties();

var hostname = id;

objectProps.put("id", id);

objectProps.put("name", id);

objectProps.put("hostname", hostname);

objectProps.put("isDeleted", true);

var hosts = Server.findAllForType("vCACCAFE:VCACHost");

System.log("Size Of VCACCAFE Hosts : " + hosts.length);

System.log("First Of VCACCAFE Host : " + hosts[0]);

var vcaccafeHost = hosts[0];

var typeArr = type.split(".");

var namespace = typeArr[0];

var typeName = typeArr[1];

var objectId = id;

var objectName = hostname;

resultObj = DynamicTypesManager.makeObject(namespace, typeName, objectId, objectName, new Array());

I try again to attach the new log.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Emmanuel.
Reply
0 Kudos
iiliev
VMware Employee
VMware Employee

Thanks, the attachment is fine now.

In the log, I see a NullPointerException thrown inside CAFE plug-in when trying to register a host using information from vRA Component Registry. What is your setup exactly? a vRO server embedded in vRA appliance? Or an external vRO appliance with vRO configured to use vRA as an authentication provider?

Reply
0 Kudos
eservent
Enthusiast
Enthusiast

Hello Ilian,

This is an external VRO with VRA Authentification provider.

Instead of using Server.findAllForType, I try to use the built-in action System.getModule("com.vmware.vra").getDefaultHostForTenant(<|>tenantId), to get a vcaccafehost.

But the problem is the same :

ReferenceError: "vCACCAFEHostManager" is not defined.

Thank you again for your help,

Emmanuel.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Emmanuel.
Reply
0 Kudos