8 Replies Latest reply on Mar 23, 2018 8:46 AM by yangot

    Custom events not formatting correctly with WSSDK 5.1

    SergioBonilla Lurker



      I'm registering an extension using the VMware vSphere Web Services SDK. The custom tasks and faults I've defined are displayed correctly on the VMware vSphere Client, as well as the vSphere Web Client. The events I defined used to be displayed correctly in both, but when I converted my code from the 5.0 release to 5.1, they are no longer being shown correctly.


      Instead of seeing something like, "Type: info" and "Description: This is the full format message", the event now looks something like, "Type: XXX Company.Product.CustomEvent.category not found XXX" and "Description: event.Company.Product.CustomEvent.fullFormat (Company.Product.CustomEvent)".


      The code to register the extension is similar to the following, with some parts omitted, since the tasks and faults are working OK:


      import com.vmware.vim25.*;


      public static final String EXTENSION_KEY = "Company.Product";
      public static final String CUSTOM_EVENT = EXTENSION_KEY + ".CustomEvent";


      Extension extension = new Extension();


      ExtensionEventTypeInfo customEventInfo = new ExtensionEventTypeInfo();


      ExtensionResourceInfo customEventResourceInfo = new ExtensionResourceInfo();


      KeyValue customEventCategory = new KeyValue();
      customEventCategory.setKey(CUSTOM_EVENT + ".category");


      KeyValue customEventLabel = new KeyValue();
      customEventLabel.setKey(CUSTOM_EVENT + ".label");
      customEventLabel.setValue("This is the label");


      KeyValue customEventSummary = new KeyValue();
      customEventSummary.setKey(CUSTOM_EVENT + ".summary");
      customEventSummary.setValue("This is the summary");


      KeyValue customEventFormat = new KeyValue();
      customEventFormat.setKey(CUSTOM_EVENT + ".fullFormat");
      customEventFormat.setValue("This is the full format message");


      The main difference between this and my previous version of the extension is the change to Lists that I need to retrieve before adding objects, instead of adding array of objects.


      The code I use to create the events looks similar to:


      ExtendedEvent event = new ExtendedEvent();
      event.setMessage("This is a non-localized message");


      vimPort.postEvent(eventManagerMOR, event, taskInfo);


      This part of the code has also changed a little from the 5.0 version of the SDK to the 5.1 version, such as the use of XMLGregorianCalendar for the created time.


      I've tried prefixing the keys for the resource information with "event." but this didn't fix the problem. I didn't have to change much to get the custom tasks and faults to work with 5.1, but that doesn't seem to be the case with events. Does anyone know what other changes need to be made for events to be displayed correctly?



        • 1. Re: Custom events not formatting correctly with WSSDK 5.1
          CathyBr Enthusiast



          I'm very happy to have found this diskussion!  We've been pulling out our hair trying to find the way to define custom events for a few months now. (We're almost bald!).

          There seems to be no docu on how to do this, so by trial an error, we've now reached the point where

          you where when you asked the question.


          Unfortunately ... there was never a reply to this discussion.


          Can someone tell what needs to be done, so that we see a real text in the Description area (instead of only the EventID String?  And how we can define texts for "Event Type Description" and "Possible Causes"?

          I assume these definitions must be made when the Extension is registered - like adding them to the

          ExtensionResourceInfo like stated above, it doesn't seem to work as expected.


          Does anyone have any info?



          • 2. Re: Custom events not formatting correctly with WSSDK 5.1
            rdey Enthusiast
            VMware Employees

            Here is the code snippet for creating custom events in 5.1 and up ..


            GregorianCalendar gregorianCalendar = new GregorianCalendar(); 

            XMLGregorianCalendar xmlValue = null;

            try {

                    xmlValue = DatatypeFactory.newInstance().newXMLGregorianCalendar(gregorianCalendar);  

            } catch (DatatypeConfigurationException e) {

                System.out.printf("newXMLGregorianCalendar Failed\n");



            KeyAnyValue kav1 = new KeyAnyValue();




            KeyAnyValue kav2 = new KeyAnyValue();


            kav2.setValue("VMware- Performing: Task HEALTH of NAS controller ctrl is unavailable");



            KeyAnyValue kav3 = new KeyAnyValue();


            kav3.setValue("VMware - Performing: Task HEALTH of NAS controller ctrl is unavailable");



            EventEx vcEvent = new EventEx();









            • 3. Re: Custom events not formatting correctly with WSSDK 5.1
              CathyBr Enthusiast

              Many thanks rdey,

              this got me a little closer..

              My code still was not working correctly, so I copied and pasted your snipplet to mine and sent your event.

              No I see (both for yours and mine) a text  in the "Description" part of the EventManager View (webClient),

              but not what I expected.


              So I modified the snipplet -  so that the kav3(.description) value is "VMware - Performing:description".


              In the EventManagerView I see your event, but the

              Description Column shows the text you defined for "fullFormat" (instead of description)

              Type Column shows "error" (instead of "information")


              I am working with vSphere Client V5.5ga.  Could it be that I am using an old version of the vim25?

              Something just does not seem to match here.


              And if I can bother you with some more questions.  The arguments you added to your event seem like

              attributes which are defined in the class "EventDescriptionEventDetail" - am I correct?


              I was thinking of defining my event details by creating an instance of that class, filling out the values and somehow add it to the EventManager.eventInfo list - is that possible? Or am I completely on the wrong track??

              I don't understand the relationship between my custom event (EventEx) as you described above, and the ExtensionEventTypeInfo which I define when registering the extension. It has an eventId and an eventScheme.  So I thought that if I did the following:

              1) Register my extension with


              ExtensionEventTypeInfo.eventTypeSchema = <EventType><eventTypeID>myplugin.event.1234</eventTypeID><description>my description</description><arguments><argument><name>var1</name><type>string</type></argument></arguments></EventType>



              send a custom event as you did above


              my event has 1 argument,

              KeyAnyValue key4 = new KeyAnyValue();




              and then I set my fullFormat string to "This is a custom {var1} event".


              I expected to see an event with the Type of "info", the Description Column to show "my Event", and

              the long description (in the detail area) to show

              This is a custom abcd event.


              But either I'm completely confused, or am just missing one or two things I haven't found yet.


              Also after registering the event as show above (I can see it in the mob), I would have thought that when the user defines an Event Trigger alarm, he would see it in the list of defined events. But that doesn't seem to work either.


              Lots of questions, I know, but thanks for any directions you could give me.


              • 4. Re: Custom events not formatting correctly with WSSDK 5.1
                CathyBr Enthusiast



                I'm still trying to add definitions for our custom event.  I choose a predefined Event from the mob, and modeled my

                Event Definition to match it.  For Example I choose the Login Succeeded Event from com.vmware.vim.eam.

                Here's how its defined (as seen in the mob)

                eventID = "com.vmware.vim.eam.login.succeded"

                eventTypeSchema = "<EventType>


                                                        <description>A user logged successfully into vSphere ESX Agent Manager</description>









                So I registered my plugin defining the following Event

                eventID = "com.acme.model.events.MyEvent"

                eventTypeSchema = "<EventType>


                                                        <description> MyEvent </description>









                Then using the vim25, I found the EventDescriptionEventDetail definitions in the EventManager for the two events seen above.

                1) The predefined Login Succeeded Event looks like this:

                EventDescriptionEventDetail.category = "info"

                EventDescriptionEventDetail.description = "Successful login to vSphere ESX Agent Manager"

                EventDescriptionEventDetail.fullFormat = "com.vmware.vim.eam.login.succeeded|Successful login by  {user} into vSphere ESX Agent Manager"

                EventDescriptionEventDetail.key = "EventEx"



                2) My Event looks like this:

                EventDescriptionEventDetail.category = event.com.acme.model.events.MyEvent.category

                EventDescriptionEventDetail.description = com.acme.model.events.MyEvent

                EventDescriptionEventDetail.fulFormat = com.acme.model.events.MyEvent|event.com.acme.model.events.MyEvent.fullFormat

                EventDescriptionEventDetail.key = "ExtendedEvent"


                It seems to me (just a speculation) that the EventManager was not able to resolve the information I defined.

                I created an event class in my DataProvider

                com.acme.model.events.MyEvent - and it extends the EventEx class - but it seems that the EventManager can't map

                my class to the Extension information.

                Using the MOB I viewed all the other things which were defined in the EAM Extension, but could not

                find anything which would help me further..

                Can someone please tell me how these things fit together?



                • 5. Re: Custom events not formatting correctly with WSSDK 5.1
                  VaibhavJain Enthusiast


                  Were you able to solve this problem? I can see this issue as well with 5.1 WSSDK.



                  • 6. Re: Custom events not formatting correctly with WSSDK 5.1
                    CathyBr Enthusiast

                    No, unfortuately, my question was never answered

                    • 7. Re: Custom events not formatting correctly with WSSDK 5.1
                      HarshaG Lurker


                      try - customEventResourceInfo.setLocale("en_US");




                      • 8. Re: Custom events not formatting correctly with WSSDK 5.1
                        yangot Lurker

                        hi, Cathy

                        Did you fix your problem?


                        - tigey