|
Home > Archive > WebSphere Portal Server > September 2006 > Accessing WPS objects from a servlet
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Accessing WPS objects from a servlet
|
|
|
| Hello again.
I have another question for you WPS wizzes out there.
Is it possible to call WPS objects (PumaHome and PumaLocator to be more specific) from a "classic" servlet mapped to the WebSphere_Portal instance ?
Apparently the JNDI lookup fails, it cannot find the required context :
javax.naming.ConfigurationException: NamingManager.getURLContext cannot find the factory for this scheme: portal
Is there anything that can be done to solve this, maybe by configuration ?
Here is the code for my servlet :
import java.io.IOException;
import javax.servlet.Servlet;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ibm.portal.um.*;
import com.ibm.portal.um.exceptions.*;
//import com.ibm.wps.puma.*;
import javax.naming.*;
public class ServletUserManager extends HttpServlet implements Servlet {
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public ServletUserManager() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest arg0, HttpServletResponse arg1)
*/
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
// TODO Auto-generated method stub
PumaHome myHome = null;
String userIdentifier = req.getParameter("UID");
//Lookup the PumaHome Instance
try {
Context ctx = new InitialContext();
Name myjndiname = new CompositeName(PumaHome.JNDI_NAME);
myHome = (PumaHome) ctx.lookup(myjndiname);
}
catch (InvalidNameException e) {
System.out.println("InvalidNameException : "+e.getMessage());
}
catch (NamingException e) {
System.out.println("NamingException : "+e.getMessage());
}
//Obtain the PumaLocator
PumaLocator myLocator = myHome.getLocator(req);
//Lookup member
try {
User myUser = myLocator.findUserByIdentifier(userIdentifier);
System.out.println("User found !");
}
catch (PumaSystemException e) {
System.out.println("PumaSystemException : "+e.getMessage());
}
catch (PumaModelException e) {
System.out.println("PumaModelException : "+e.getMessage());
}
catch (PumaMissingAccessRightsException e) {
System.out.println("PumaissingAccessRightsException : "+e.getMessage());
}
}
| |
|
| Apparently the JNDI lookup is correct, but the servlet cannot find the correct IntialContext, and thus cannot lookup portal:service/usermanagement/Puma.
Does anybody know which WPS Context needs to be used by the servlet for this lookup to work ?
If similar code is used in a JSP in a Theme, it works, which confirms that the problem is linked to obtaining the correct WPS-related context.
| |
|
| try this:
env.put(Context.PROVIDER_URL, "iiop://<server>:<port>/NameService");
Context ctx = new InitialContext(env);
Name myjndiname = new CompositeName(PumaHome.JNDI_NAME);
This is not working for me yet -- still getting a problem with the implfactory.properties -- but I believe it's closer since this will open the InitialContext to the portal's RMI listener.
|
|
|
|
|