Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
WorkSite MP 4.1 Connector
peter_choe
I am trying to write create a connector that will allow the user logged in to create new trustees in the library.
So, I have set up some javaserver pages and servlet to create a new trustee. The problem I have been having is that I need to pass the WorkSite MP session to my servlet. I got the code to retrieve the session information shown below. I set the WorkSite MP session to the HttpSession to retrieve it in my servlet.
The session is being passed to the servlet, but for reasons not know to me, when I try to do a search on the library I get the exception shown below. But it is not a consistent behavior. Sometimes, I won't get the exception and sometimes the exception is thrown. Is there something that needs to be done to make the WorkSite MP session persistant or consistant?
<%@ page import="java.util.*,com.imanage.workteam.appservices.session.*,com.imanage.cms.api.workteam.*" %>
<%@ taglib uri="/tlds/c.tld" prefix="c" %>
<%@ taglib uri="/tlds/wsmp.tld" prefix="w" %>
<%AppSession appSession = (AppSession)request.getAttribute("appSession");
Session cmsSession = appSession.getCmsSession();
session = request.getSession(true);
Collection names = cmsSession.getAllLibraryNames();
Library library = cmsSession.getLibraryByName((String)names.iterator().next());
session.setAttribute("library", library);
session.setAttribute("user", cmsSession.getLoggedOnUser());
session.setAttribute("test", "test passing session to jsp");
session.setAttribute("wsmpSession", cmsSession);%>
<center>
<%=library.getName()%><p>
<iframe src="admin/dispatch?cmd=add_trustee" width="800" height="500"></iframe>
</center>
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.lang.RuntimeException: unexpected invocation exception: unexpected invocation exception: Connection is closed
at com.imanage.cms.fc.cmsconnection.VirtualMethodInvoker.invokeMethod(VirtualMethodInvoker.java:110)
at com.imanage.cms.fc.cmsconnection.ClientInterfaceVirtualProxy.invokeSingleMethod(ClientInterfaceVirtualProxy.java:150)
at com.imanage.cms.fc.cmsconnection.ClientInterfaceVirtualProxy.invoke(ClientInterfaceVirtualProxy.java:106)
at $Proxy0.trusteeSearch(Unknown Source)
at com.imanage.cms.t2.jom.impl.LibraryImpl.searchTrustees(LibraryImpl.java:619)
at com.imanage.cms.api.workteam.impl.LibraryImpl.searchTrustees(LibraryImpl.java:1371)
at com.microstrat.worksite.admin.OrganizationGroups.setOrganizationGroups(OrganizationGroups.java:69)
at com.microstrat.worksite.admin.AdminDispatcher.doGet(AdminDispatcher.java:86)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
--------------------------------------------------------------------------------
Apache Tomcat/4.1.30
Find more posts tagged with
Comments
JTNeville
I emulated what I think you were doing and ran it a few times, didn't get that error. But thinking about it looks like the system thinks the session has already been cleaned up and not kept it alive. Are you running any other code that might be cleaning up the session?
peter_choe
i don't think that i am running any code to clear up the session. here is the servlet code:
/*
* Created on Mar 2, 2005
*
* worksitemp
*
* Micro Strategies Inc.
* 104 Broadway
* Denville, NJ 07834
*/
package com.microstrat.worksite.admin;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import javax.mail.MessagingException;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.imanage.cms.api.workteam.Library;
import com.imanage.cms.api.workteam.Session;
import com.imanage.cms.api.workteam.SessionManager;
import com.imanage.cms.api.workteam.SimpleSession;
import com.imanage.cms.api.workteam.User;
import com.imanage.cms.exceptions.workteam.WorkteamException;
import com.imanage.workteam.appservices.session.AppSession;
import com.imanage.workteam.exceptions.ResourceNotAvailableException;
import edu.cuny.baruch.utility.form.FormMail;
/**
*
@author
Peter Choe
*
*/
public class AdminDispatcher extends HttpServlet {
private static Logger logger;
private OrganizationGroups organizations;
private SimpleSession s;
public void init(ServletConfig config) throws ServletException {
super.init(config);
logger = Logger.getLogger(AdminDispatcher.class);
StringBuffer logProp = new StringBuffer(getServletContext()
.getRealPath("/"));
logProp.append(getInitParameter("logging"));
PropertyConfigurator.configure(logProp.toString());
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session = request.getSession();
//AppSession appSession = (AppSession) session.getAttribute("appSession");
logger.debug((String) session.getAttribute("test"));
//User user = (User) session.getAttribute("user");
//Library library = (Library) session.getAttribute("library");
Session s = (Session) session.getAttribute("wsmpSession");
User user = null;
Library library = null;
try {
logger.debug("Is session connect? " + s.isConnected());
user = s.getLoggedOnUser();
logger.debug("User name: " + user.getName());
library = s.getLibraryByName((String)s.getAllLibraryNames().iterator().next());
if (null == organizations) {
logger.debug("library: " + library.getName());
organizations = new OrganizationGroups();
organizations.setLogger(logger);
organizations.setOrganizationGroups(s);
session.setAttribute("organizations", organizations);
}
} catch (WorkteamException e) {
throw new ServletException(e);
}
String cmd = request.getParameter("cmd");
logger.debug("cmd: " + cmd);
String target = new String("/admin/trustee.jsp");
if ("add_trustee".equals(cmd)) {
//get organizations and go the the trustee.jsp page.
try {
logger.debug("User id: " + user.getName());
} catch (WorkteamException e) {
e.printStackTrace();
throw new ServletException(e);
}
target = "/admin/trustee.jsp";
}
getServletContext().getRequestDispatcher(target).forward(request,
response);
}
}
Sometimes the session doesn't even get passed. Would you mind sharing your code that you tried out with me?
I appreciate the help.
JTNeville
I'll post my code when I get back to the office, but have you looked at the CreateTrustee.java example from the samples in the 4.1 SDK? It's what I referenced when I built the test file. I didn't actually do anything with the logged in user, just ran the remote create trustee class file from a iframe.
peter_choe
I have modeled the my code after the CreateTrustee.java example. I just can't seem to get a consistant behavior when i am passing the session information.
But, the architecture that I set up where I get the session from the content.jsp and set it in the HttpSession object to pass to my servlet should work, right? Or is there another way to pass the WorkSite MP Session object to a servlet from the connector?
Peter
Ort618
Hello Peter,
I went through this forum and have found your questions about connectors and some stuff around this. Now i see your are trying play
around WS session and so. I can not help you right now because i am new here but it seems soon I will need to do something like you did.
I want to ask you to help me with one issue. I want to understand how to do some simple user interaction portlet, like this:
1) present a simple UI of connector with <form> and fileds there like "text input" and "submit button" (this is OK, i can put it inside of connector JSP file).
2) Be able to execute my own server side code (servlet or jsp) to process this form. This is where i stuck. I don't understand what do i need to put inside of action property for form. I have played around but failed.
3) Be back to WorkSite, to the some screen (workspace) but with different content inside of my portlet. If all content always coming from content.jsp
then i have to have some switch there. In real i want to use MVC model, so to redirect to some other JSP after doing some logic.
All above are basic integration functionality and i hope it can be done here.
I will be appreciate for any code examples or just idea!
In real i am Plumtree guy and did it for last 4 years very easy there. Plumtree also support WSRP standart for integration but i dont' think Interwoven does.
Thank you!
Edited by Ort618 on 03/09/05 02:03 PM (server time).
Ort618
Because i am new here, i am trying to understand your code. So let me comment some parts just
to understand we are on the some page.
>AppSession appSession = (AppSession)request.getAttribute("appSession");
Here you pick up WorkSite session from request object. This is make sense
because you don't want create the new one (with some probably unknown credentials)
in your servlet.
Here i think good place to check it out for null and them may be for appSession.ping()
to make sure it's OK. Because may be there is some WS session timeout or something, not sure,
just guessing.
>session = request.getSession(true);
Here you get http session to use one as container to save some data, like cmsSession.
Then you will use one in servlet. It seems OK. Session timeout depends of your wepp
app server but as soon as you use "true" as getSession() parameter it means you are OK to create new http session in case it's expired.
>HttpSession session = request.getSession();
..
>Session s = (Session) session.getAttribute("wsmpSession");
It seems ok, you got http session, then pick up WS session.
For now i don't see problem. But there is kind of WS dispatcher between
jsp and servlet. I don't know how it works, may be it is responsible for problem.
Anyway try to locate exactly the code line where you get error. Log everything.
Then will see.
I will be really appreciate if you send me any MVC code as example. Because i need this functionality as well
i will be able to check it (at least, session issue) out in my env.
peter_choe
what you describe is how i am approaching the problem. within the content.jsp for the connector, i create an iframe and put the jsp file that i want to show. from there, it follows the normal flow of sending requests to another jsp or servlet. just define in the form tag the action you want to do (i.e. forward request to another jsp file or a servlet).
i found that it is pretty much the same things as accessing the jsp file directly from the browser.
hope this helps.
i don't have any code that is working correctly yet.