14 Replies Latest reply: Jun 25, 2013 10:33 AM by madhatter RSS

    using email notification service in OIM 11GR2

      Hello OIM 11GR2 experts,

      can you please provide me example for using NotificationService and NotificationEvent. I just want to send sample email to a user from system account xelsysadm... I am very new to this topic. Appreciate your help.

      I have created notification event and set values as shown below :

      template : "Reset Password" -- actually I need to use existing template and do not want to create new one.

      userIDs : "My User login"
      sender : "xelsysadm" -- not sure how to set in generic way

      then I called notificationService.notify(event).

      Looks like something is missing. because I am getting :

      Exception in thread "main" java.lang.NullPointerException
           at java.util.HashMap.putAll(HashMap.java:498)
           at oracle.iam.notification.impl.NotificationServiceImpl.getMessageContent(NotificationServiceImpl.java:324)
           at oracle.iam.notification.impl.NotificationServiceImpl.notify(NotificationServiceImpl.java:537)
           at oracle.iam.notification.impl.NotificationServiceImpl.notify(NotificationServiceImpl.java:271)
           at sun.reflect.GeneratedMethodAccessor11126.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)
           at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
           at oracle.iam.platform.utils.DMSMethodInterceptor.invoke(DMSMethodInterceptor.java:25)
           at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
           at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
           at $Proxy479.notify(Unknown Source)
           at oracle.iam.notification.api.NotificationServiceEJB.notifyx(Unknown Source)
           at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
           at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
           at java.lang.reflect.Method.invoke(Method.java:597)

      I am able to see auto notification by OIM which indicates my mail server is configured correctly.

      Appreciate your help.

      Edited by: 923360 on Nov 14, 2012 10:54 AM

      Edited by: 923360 on Nov 14, 2012 12:27 PM
        • 1. Re: using email notification service in OIM 11GR2
          Kevin Pinsky
          Follow this post: http://fusionsecurity.blogspot.com/2011/07/oim-11g-notifications.html

          The only difference is how you can package the xml file now in the plugin file when you deploy.

          • 2. Re: using email notification service in OIM 11GR2
            Thank you Kevin. But I am wondering why I need to do all that configurations mentioned in the url. I just want to use existing template itself and send email. Do not know why I need to do all that homework mentioned in the url. I was thinking if we are writing new templates, new events trigging...then only we need to do these configuration.

            • 3. Re: using email notification service in OIM 11GR2
              Kevin Pinsky
              If you want to use an existing template, you will need to find the Resolver class, and find the inputs that are required within the code.

              You don't have to use the sample i posted, but you can at least see the code that is used to call a template, provide the users to send it to, and populate the map that is an input for the submission of the event.

              • 4. Re: using email notification service in OIM 11GR2
                The problem I am facing currently is, NotificationService.lookupTemplate(tempName.trim(),Locale.ENGLISH) is returning null !!

                I can see all basic templates from OIM console -- "Request Creation", "Reset Password" etc. But when I pass these template names lookupTemplate(), I am getting null.

                I do not know why lookup is not able to pull the existing templates !! Not sure any issue with API or issue with my OIM templates. However, auto notification is working.

                • 5. Re: using email notification service in OIM 11GR2
                  Kevin Pinsky
                  The template name is actually "ResetPasswordNotification". You can reference the NOTIFICATIONTEMPLATE table in the database to see the value.

                  • 6. Re: using email notification service in OIM 11GR2
                    no luck. I do not know what is going on. NotificationService.lookupTemplate("ResetPasswordNotification",Locale.ENGLISH) is returning null and exception NullPointerException.

                    I do not know what should I provide to this method to make it working.

                    • 7. Re: using email notification service in OIM 11GR2
                      Hi Kevin, I am writing custom notification now. I have named my xml file as event.xml. What is the metada location I should provide now to import ? Can I provide like this :


                      Or should I provide /metadata/iam-features-notification/EventHandlers.xml ?

                      This is not clear from the fusionsecurity blog.

                      • 8. Re: using email notification service in OIM 11GR2
                        Kevin Pinsky
                        I would suggest like this: /db/<CLIENT>/Notification/Notification.xml

                        • 9. Re: using email notification service in OIM 11GR2
                          Karthik Perath
                          Create a folder in OIM machine(for ex /apps/MDS/import)
                          Inside import folder create subfolders like metadata/iam-features-request/notification. Copy your notification xml under this folder.
                          Modify weblogic.properties to change the following properties

                          Use weblogicImportMetadata.sh to import this xml to MDS

                          To make sure your event xml is imported properly, login to OIM Admin console and create Notification, select the event created above from Available Event dropdown.
                          • 10. Re: using email notification service in OIM 11GR2
                            thank you Karthik, that worked. I am not sure whether you are able to help me about my original issue --- "Unable to lookup existing template using NotificationService ". If trace back this thread, you see the problem I am facing.

                            Since I am unable to lookup built-in templates, I decided to create my own template and initiate emailing.

                            • 11. Re: using email notification service in OIM 11GR2
                              Karthik Perath
                              Check the below snippet on how to set notification event using NotificationService.
                              private NotificationEvent getRoleGrantEvent(String userKey, String roleKey,
                                        String senderId) throws NoSuchUserException, UserLookupException,
                                        AccessDeniedException {
                                        NotificationEvent event = new NotificationEvent();
                                        //get user IDs to whom notification is to be sent and set it in the
                                        //event object being created
                                        String[] receiverUserIds= getRecipientUserIds(userKey);     
                                        //Set template name to be used to send notification for this event
                                        event.setTemplateName("RoleGrantedNotificationTemplate");//Can be existing template name
                                        //Setting senderId as null here and hence default sender ID would
                                        //get picked up

                                        //Create a map with key value pair for the parameters declared at time
                                        //of configuring notification event
                                        HashMap<String, Object> map = new HashMap<String, Object>();
                                        map.put("usr_key", userKey);
                                        map.put("role_key", roleKey);
                                        return event;

                              private void sendNotification(NotificationEvent event) throws NotificationException {
                                        try {
                                             //Call notify method of NotificationService to pass on the event
                                             //to notification engine
                                             NotificationService notificationService = Platform.getService(
                                        } catch (Exception e) {
                                             System.out.println("Error occured);
                              • 13. Re: using email notification service in OIM 11GR2
                                That's where exactly I have problem. The method setTemplate(templatename) throws me NullPointerExcpetion. Then I thought let me lookup the template using NotificationService and this is also throwing same error.

                                But I see below templates and corresponding evnts in the database table and alos on OIM admin console :

                                14     Demo Template     Demo Notification Event
                                1     PasswordExpiredNotification     PasswordExpiration
                                2     PasswordWarningNotification     PasswordWarning
                                3     RequestIdentityCreation     CreateUser
                                4     RequestStatusChange     RequestStatusChange
                                5     RequestCreation     RequestCreation
                                6     BulkRequestCreation     BulkRequestCreation
                                7     CreateUserSelfServiceNotification     CreateSelfUser
                                8     GeneratedPasswordNotification     GeneratePassword
                                9     ResetPasswordNotification     ResetPassword
                                10     UserDeletedNotificationTemplate     UserDeletedNotificationEvent
                                11     EndDateNotificationTemplate     EndDateNotificationEvent
                                12     AddProxyNotificationTemplate     AddProxy
                                13     ForgottenUsernameNotification     ForgottenUsername

                                But my lookup and setTemplate fails for everything.

                                I do not see any exception at server log but below warning :

                                ####<Nov 15, 2012 3:05:54 PM EST> <Warning> <JNDI> <[ACTIVE] ExecuteThread: '6' for queue:
                                'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <024170c1c59452c4:-60824fce:13aed99a622:-8000-0000000000006062> <1353009954243>
                                <BEA-050006> <An attempt was made to look up versioned object "ejb.stateless.ClientLoginSessionService#oracle.iam.platformservice.api.ClientLoginSessionServiceRemote"
                                from an external client or another application. This can potentially cause in-flight work of the application
                                version not being tracked properly and thus being retired prematurely.>

                                I have logged in as xelsysadm for obtaining oimclient object.


                                Edited by: 923360 on Nov 15, 2012 11:53 AM

                                Edited by: 923360 on Nov 15, 2012 11:53 AM

                                Edited by: 923360 on Nov 15, 2012 12:08 PM
                                • 14. Re: using email notification service in OIM 11GR2

                                  > NotificationService.lookupTemplate("ResetPasswordNotification",Locale.ENGLISH) is returning null

                                  Try Locale.US.