cancel
Showing results for 
Search instead for 
Did you mean: 

UME 4.0 Initializing the UMFactory

Former Member
0 Kudos

I've been trying to write a servlet to access the UME. When I try

UMFactory umf = UMFactory.getInstance();

IUserAccountFactory _userAccountFactory = UMFactory.getUserAccountFactory();

I get an exception java.lang.IllegalStateException. I know I have to initialize the UMFactory but the documentation states that UMFactory.getInstance takes care of the Initialization if not done prior to calling. Further, all the files in ume directory that contain the sapum.properties and other property files are appended with a .bak. So I am unsure as to how to go about initializing the UMFactory. Help is appreciated.

Thanks,

Ravi...

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

It still complains that:

java.lang.IllegalStateException: Could not initialize UMFactory! Please set property 'ume.cfg.path' or call UMFactory.initialize() first

and I don't know how to do this...

Thanks

Dov

Former Member
0 Kudos

I don't know how to set ume.cfg.path either Dov... does anyone?

Oliver, it is impractical for most webapps to "run in the irj context"... would have to merge web & ejb descriptors etc., right? I mean, it is useful strategy for debugging, troubleshooting and so on.

So, the exception is telling me to set the ume.cfg.path or call UMFactory.initialize(), and the parameters to the latter are sort of obscure in the javadoc. So, what would one set ume.cfg.path to? If someone can help, thanks.

Hugh

oliver_nocon
Participant
0 Kudos

Hi,

I agree that it is impractical for most webapps to run in the irj context but it is a good starting point to get it running. We are talking about 6.20, right? Otherwise different story...

The UME on 6.20 comes with the portal. This means even if you succeed to initialize the UMFactory you might run into different additional problems in case you run outside the irj context. This depends on what you use from the API. Functionality with regard to portal roles will not work since this functionality is not available outside the irj context.

But now what the error means

If you run outside the irj the UME cannot initialize because the configuration is stored in the PCD (and it uses the PCD API in the portal for accessing it).

As alternative you can retrieve the UME configuration for example from the PCD (sapum.properties, datasourceconfiguration_xxx.xml, ...) manually. You put all these files into one directory and set the java environment variable -ume.cfg.path to the directory path.

If you are running the portal in the same VM you might run into additional problems but I never tried this.

What I just tried is copying the JSP code from above into a file, putting it into the directory ...cluster\server\services\servlet_jsp\work\jspTemp\irj\root and calling it via .../irj/test.jsp.

As I mentioned above not perfect but a good starting point ...

If it does not work for you, make sure that the portal is up and running (The UME needs to initialize correctly in the portal first).

Best regards,

Oliver

Former Member
0 Kudos

I found the missing secret sauce.

Just to review, I have an EAR I have gotten to deploy successfully in the WAS 6.40. Now I want to add SSO capability and following some recipes I have found here on SDN, I am calling UMFactory.getAuthenticator().forceLoggedInUser() within a Filter. Until now I had been getting the above mentioned exceptions (call UMFactory.initialize() or set ume.cfg.path).

Adding the following three hard references to application-j2ee-engine permits the call to succeed:

<reference

reference-type="hard">

<reference-target

provider-name="sap.com"

target-type="interface">keystore_api</reference-target>

</reference>

<reference

reference-type="hard">

<reference-target

provider-name="sap.com"

target-type="library">security.class</reference-target>

</reference>

<reference

reference-type="hard">

<reference-target

provider-name="sap.com"

target-type="library">com.sap.security.api.sda</reference-target>

</reference>

Additionaly, I no longer add the com.sap.security.api.jar to my deploy, although it is of course needed for my compile.

Hope this helps

Hugh

oliver_nocon
Participant
0 Kudos

okay, that's the 6.40 story ...

Oliver

Former Member
0 Kudos

Hi,

Did any of you succeed?

Thanks

Dov

oliver_nocon
Participant
0 Kudos

Hi,

did you run your servlet in the irj context?

If you don't try to put it into the irj context for now. Then you do not need to take care of initializing the UMFactory. you can just go ahead like mentioned above with e.g. UMFactory.getUserAccountFactory().

Best regards,

Oliver

PS: Here a sample jsp I found. Just copy the jsp into the irj folder ...

<%@ page language = "java" contentType = "text/html" %>

<%@ page import = "com.sap.security.api.*" %>

<html>

<head>

<title>Display all users</title>

</head>

<body>

<h1>Display all users</h1>

<table border="1">

<%! String userUniqueId; %>

<%

IUserAccountFactory userAccountFactory = UMFactory.getUserAccountFactory();

IUserAccountSearchFilter filter = userAccountFactory.getUserAccountSearchFilter();

ISearchResult result = userAccountFactory.search(filter);

while (result.hasNext()) {

userUniqueId = (String) result.next();

%>

<tr><td><%=userUniqueId%></td></td>

<%

}

%>

</table>

</body>

</html>

Former Member
0 Kudos

Hello all,

Well, i am fairly new to this environment. I have got a few tasks to finish and one of them is to expose the UME API as a WebService for updates.

I also did get hit by the same exceptions when i try to us UMFactory. I am here not just because this is one of my problems but i being fairly new to J2EE environment am struggling a bit with some basic functions here as well. I hope you will be able to give me some tips and directions.

I am using WAS 640 with Portals. Having read through all the responses in relation to this particular problem, i did use the JSP provided by Oliver above and it works beautifully which confirms that the UME api works fine when i place JSP in the portal root directory. It also works fine if i place it in the WAS examples root directory,

which is

....\cluster\server0\apps\sap.com\com.sap.engine.docs.examples\servlet_jsp\

_default\root

Now, when you say we need to run servlet in Portal context then what exactly do you mean here? do you mean that if we dont have portal installed then we wont have UME service, i.e its not delivered as standard on WAS 640 installation?

Anyway, the important question i have here is i am trying to use NW Dev. Studio to write a simple app to test UME API first and then hopefully progress with writing a Web Service for the same.

When i try to do this, I can create a new java project and make references to com.sap.security.api lib etc withourt a problem, syntax checks are all good but when i run it it fails with the exceptions mentioned above every single time.

So can someone throw some more light on how do go about writing apps which are using libraries on J2ee via NetWeaver Dev. Studio or any other ide for that matter, what else needs to be done for them to compile and run. I can only guess here that i am again missing the Portal context, which probably means this application of mine must be able to add references to portal libraries and then i must login to Portal using the portal api first whcih should then give me a portal interface handle, i should then be able to use that portal context to trigger anything on UME API. Does this mean that i try and create a portal applicaiton project as opposed to a java project, which hopefully should provide me with the portal libraries automatically? I will give that a try next....how would someone use the UME API outside portal?

I would really appreciate any help here.

My appologies for lack of knowledge in this area.

Thanks,

Former Member
0 Kudos

Did you try

IUserAccountFactory _userAccountFactory = UMFactory.getUserAccountFactory();

statement alone? without initializing UMFactory.

Former Member
0 Kudos

Hi,

i get the same exception

java.lang.IllegalStateException: Could not initialize UMFactory! Please set property 'ume.cfg.path' or call UMFactory.initialize() first

even after removing UMfactory.getInstance().

do i need to make any other changes.

Regards

srini

Oliver_S
Advisor
Advisor
0 Kudos

Well, seems to be a bug.

Use a workaround or open an OSS message please.