Topic
  • 21 replies
  • Latest Post - ‏2015-05-06T13:59:33Z by tarek.righi
SystemAdmin
SystemAdmin
648 Posts

Pinned topic Issue in implementing a custom Tool functionality. ClassNotFound Exception!

‏2011-12-22T08:24:57Z |
Hi,

I'm trying to implement a custom tool functionality in PIM Ver-9.0.0-FP005#31 but on hitting the button the action is getting read from the flow-config.xml but the class that should get called from the action doesn't exist and that's why it's throwing the Classnotfound exception. I followed the exact jar deployment process been mentioned in the below url (Infocenter) and it's getting deployed properly too.

http://publib.boulder.ibm.com/infocenter/pim/v9r1m0/index.jsp?topic=%2Fcom.ibm.pim.app.doc%2Fwebservices%2Fpim_tsk_deployinguserjar.html

Then why it's not finding the class? I'm attaching all the files which are part of this implementation. Could you please check and let me know what exactly I'm missing here?

Thanks in advance,
Abhijeet
Updated on 2012-10-01T22:44:46Z at 2012-10-01T22:44:46Z by KaranBal
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T09:10:14Z  
    Hi,

    Did you redeploy the application via install_war.sh after the jar had been added?
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T09:18:59Z  
    Hi,

    Did you redeploy the application via install_war.sh after the jar had been added?
    Yes I did and just before the process got completed it showed me the list of jar files been added and mine was there as shown below.
    /home/mdmpim/mdmpim652/jars/AppRejPOC.jar

    Thanks,
    Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T09:52:46Z  
    Yes I did and just before the process got completed it showed me the list of jar files been added and mine was there as shown below.
    /home/mdmpim/mdmpim652/jars/AppRejPOC.jar

    Thanks,
    Abhijeet
    Well,

    Check manually if there is your jar in the classpath of the application server. What an application server are you using? WAS or WebLogic. If WAS look attachment.
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T10:33:56Z  
    Well,

    Check manually if there is your jar in the classpath of the application server. What an application server are you using? WAS or WebLogic. If WAS look attachment.
    Thanks for the reply. We are using WAS as our app. server. But not sure about the WAS UI which is shown in the image attached.
    Is there any way I can check in the Linux where it's deployed.

    My WAS location is as below

    > echo $WAS_PROFILE_HOME
    > /opt/IBM/WebSphere/AppServer/profiles/AppSrv01

    I also did echo $CLASSPATH and it didn't show my jar file.

    Thanks,
    Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T10:59:55Z  
    Thanks for the reply. We are using WAS as our app. server. But not sure about the WAS UI which is shown in the image attached.
    Is there any way I can check in the Linux where it's deployed.

    My WAS location is as below

    > echo $WAS_PROFILE_HOME
    > /opt/IBM/WebSphere/AppServer/profiles/AppSrv01

    I also did echo $CLASSPATH and it didn't show my jar file.

    Thanks,
    Abhijeet
    It is Admin console of a WAS. The URL must like to https://192.168.1.36:9043/ibm/console
    Find the corresponding port number in AboutThisProfile.txt in /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/logs folder.

    If there is no your jar in the classpath so it seems you didn't run install_war.sh
  • babinag
    babinag
    91 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T11:22:17Z  
    another way:
    1. Develop your jsp's (for example one jsp named MyJSP.jsp).
    
    <%@page import=
    "com.ibm.pim.context.PIMContextFactory"%> <%@page import=
    "com.ibm.pim.context.Context"%> <%@page contentType=
    "text/html" pageEncoding=
    "UTF-8"%> <!DOCTYPE HTML PUBLIC 
    "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">   <% response.setCharacterEncoding(
    "UTF-8"); response.setContentType(
    "text/html"); Context ctx = PIMContextFactory.getCurrentContext(); String userName = ctx.getCurrentUser().getUserName(); %> <html> <center> <body> <b>My Name is:</b> <%=userName%> </body> </center> </html>
    

    2. Put your jsp's at directory /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServerName/ccd_pim.ear/ccd.war/CT/
    (you can create directory named CT for example for your jsp's). If your jsp use custom java logic developed as servlet, you are to do some more operations.
    Also if you have distributed installation, you are to make this operation on every instance of mdm4pim.
    3. Go to scripts console/custom tools, create new custom tool named MyCustomTool for example, select ASP/JSP type and put there code below
    
    <html> <center> <body> <iframe name=
    "frame1" src=
    "/CT/MyJSP.jsp" frameborder=
    "no" scrolling=
    "no" width=
    "100%" height=
    "100%"> </iframe> </body> </center> </html>
    

    You can dispatch and include custom from your's and to your's.
    4. Save, relogin, select MyCustomTool in Custom Tools menu.
    4. ?????
    5. Profit!
  • babinag
    babinag
    91 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T11:31:49Z  
    another way:
    1. Develop your jsp's (for example one jsp named MyJSP.jsp).
    
    <%@page import=
    "com.ibm.pim.context.PIMContextFactory"%> <%@page import=
    "com.ibm.pim.context.Context"%> <%@page contentType=
    "text/html" pageEncoding=
    "UTF-8"%> <!DOCTYPE HTML PUBLIC 
    "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">   <% response.setCharacterEncoding(
    "UTF-8"); response.setContentType(
    "text/html"); Context ctx = PIMContextFactory.getCurrentContext(); String userName = ctx.getCurrentUser().getUserName(); %> <html> <center> <body> <b>My Name is:</b> <%=userName%> </body> </center> </html>
    

    2. Put your jsp's at directory /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServerName/ccd_pim.ear/ccd.war/CT/
    (you can create directory named CT for example for your jsp's). If your jsp use custom java logic developed as servlet, you are to do some more operations.
    Also if you have distributed installation, you are to make this operation on every instance of mdm4pim.
    3. Go to scripts console/custom tools, create new custom tool named MyCustomTool for example, select ASP/JSP type and put there code below
    
    <html> <center> <body> <iframe name=
    "frame1" src=
    "/CT/MyJSP.jsp" frameborder=
    "no" scrolling=
    "no" width=
    "100%" height=
    "100%"> </iframe> </body> </center> </html>
    

    You can dispatch and include custom jsp from your's and to your's.
    4. Save, relogin, select MyCustomTool in Custom Tools menu.
    4. ?????
    5. Profit!
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T12:31:15Z  
    • babinag
    • ‏2011-12-22T11:31:49Z
    another way:
    1. Develop your jsp's (for example one jsp named MyJSP.jsp).
    <pre class="jive-pre"> <%@page import= "com.ibm.pim.context.PIMContextFactory"%> <%@page import= "com.ibm.pim.context.Context"%> <%@page contentType= "text/html" pageEncoding= "UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <% response.setCharacterEncoding( "UTF-8"); response.setContentType( "text/html"); Context ctx = PIMContextFactory.getCurrentContext(); String userName = ctx.getCurrentUser().getUserName(); %> <html> <center> <body> <b>My Name is:</b> <%=userName%> </body> </center> </html> </pre>
    2. Put your jsp's at directory /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServerName/ccd_pim.ear/ccd.war/CT/
    (you can create directory named CT for example for your jsp's). If your jsp use custom java logic developed as servlet, you are to do some more operations.
    Also if you have distributed installation, you are to make this operation on every instance of mdm4pim.
    3. Go to scripts console/custom tools, create new custom tool named MyCustomTool for example, select ASP/JSP type and put there code below
    <pre class="jive-pre"> <html> <center> <body> <iframe name= "frame1" src= "/CT/MyJSP.jsp" frameborder= "no" scrolling= "no" width= "100%" height= "100%"> </iframe> </body> </center> </html> </pre>
    You can dispatch and include custom jsp from your's and to your's.
    4. Save, relogin, select MyCustomTool in Custom Tools menu.
    4. ?????
    5. Profit!
    Hi,

    I couldn't bring up my WAS console. My application URL is http://192.168.73.128:7507/utils/enterLogin.jsp

    and below is what I got in the AboutThisProfile.txt file

    *Application server environment to create: Application server
    Location: /opt/IBM/WebSphere/AppServer/profiles/AppSrv01
    Disk space required: 200 MB
    Profile name: AppSrv01
    Make this profile the default: True
    Node name: mdmpimNode01
    Host name: mdmpim.ibm.com
    Enable administrative security (recommended): False
    Administrative console port: 9060
    Administrative console secure port: 9043
    HTTP transport port: 9080
    HTTPS transport port: 9443
    Bootstrap port: 2809
    SOAP connector port: 8880
    Run application server as a service: False
    Create a Web server definition: False*
    I have tried all combinations but nothing works. Please suggest.

    ~Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-22T12:36:17Z  
    Hi,

    I couldn't bring up my WAS console. My application URL is http://192.168.73.128:7507/utils/enterLogin.jsp

    and below is what I got in the AboutThisProfile.txt file

    *Application server environment to create: Application server
    Location: /opt/IBM/WebSphere/AppServer/profiles/AppSrv01
    Disk space required: 200 MB
    Profile name: AppSrv01
    Make this profile the default: True
    Node name: mdmpimNode01
    Host name: mdmpim.ibm.com
    Enable administrative security (recommended): False
    Administrative console port: 9060
    Administrative console secure port: 9043
    HTTP transport port: 9080
    HTTPS transport port: 9443
    Bootstrap port: 2809
    SOAP connector port: 8880
    Run application server as a service: False
    Create a Web server definition: False*
    I have tried all combinations but nothing works. Please suggest.

    ~Abhijeet
    Your WAS must be started to run install_war.sh and to open Admin console.

    /opt/IBM/WebSphere/AppServer/startServer.sh server1
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-28T11:15:29Z  
    Your WAS must be started to run install_war.sh and to open Admin console.

    /opt/IBM/WebSphere/AppServer/startServer.sh server1
    Not yet able to bring up the WAS console. I'm actually using a VM Dump of PIM9. Not sure if that is causing any problem. But when I'm running the install_war.sh script, I could see that my jar is getting read and is listed down in the console itself. So surely it is getting deployed. Any way I could trace the class file in the UNIX env.? What is the location where this deployed class file resides?

    Thanks,
    Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-28T12:23:12Z  
    Not yet able to bring up the WAS console. I'm actually using a VM Dump of PIM9. Not sure if that is causing any problem. But when I'm running the install_war.sh script, I could see that my jar is getting read and is listed down in the console itself. So surely it is getting deployed. Any way I could trace the class file in the UNIX env.? What is the location where this deployed class file resides?

    Thanks,
    Abhijeet
    Just to add to above, can somebody quickly take a look at the zip file been aatached in the first post? We have deployed some 5 jars and all of those got deployed properly because the export jobs been setup are internally calling these class files and thus functioning properly. The only issue we are facing is when we are trying to access the class files through custom tool, via flow-config.xml. It's reading the action from the custom tool and parsing the flow-config.xml to get the corresponding class file against the action but it's failing to find it.
    Any thing additional we need to do while deploying jars for custom tool implementation?
    Please check the files in the zip and let us know.

    Thanks in advance,
    Abhijeet
  • babinag
    babinag
    91 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-29T05:54:35Z  
    Just to add to above, can somebody quickly take a look at the zip file been aatached in the first post? We have deployed some 5 jars and all of those got deployed properly because the export jobs been setup are internally calling these class files and thus functioning properly. The only issue we are facing is when we are trying to access the class files through custom tool, via flow-config.xml. It's reading the action from the custom tool and parsing the flow-config.xml to get the corresponding class file against the action but it's failing to find it.
    Any thing additional we need to do while deploying jars for custom tool implementation?
    Please check the files in the zip and let us know.

    Thanks in advance,
    Abhijeet
    try to drop your jars at
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServerName/ccd_pim.ear/ccd.war/WEB-INF/lib or necessary for your CT classes with proper package structure at ../WEB-INF/classes
    at each installation if pim, restart start_local.sh and try custom tools again
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-30T06:41:06Z  
    • babinag
    • ‏2011-12-29T05:54:35Z
    try to drop your jars at
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServerName/ccd_pim.ear/ccd.war/WEB-INF/lib or necessary for your CT classes with proper package structure at ../WEB-INF/classes
    at each installation if pim, restart start_local.sh and try custom tools again
    It didn't work as well. Moreover I'm facing a new issue in updating the flow-config.xml file. Evertime I change something in it. It throws the below error -

    General failure (server should provide error description).
    Error code: 4
    Error message from server: Failure
    Request code: 6

    The file contents get deleted and it shrinks to 0 byte. I have cleared up a lot of space by removing logs and dumps. But still it showing the usage as 100%. I'm using the command "df -k ." on $TOP folder.

    Any idea? This is actually holding us back.

    Thanks in advance,
    Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2011-12-30T06:50:07Z  
    It didn't work as well. Moreover I'm facing a new issue in updating the flow-config.xml file. Evertime I change something in it. It throws the below error -

    General failure (server should provide error description).
    Error code: 4
    Error message from server: Failure
    Request code: 6

    The file contents get deleted and it shrinks to 0 byte. I have cleared up a lot of space by removing logs and dumps. But still it showing the usage as 100%. I'm using the command "df -k ." on $TOP folder.

    Any idea? This is actually holding us back.

    Thanks in advance,
    Abhijeet
    The space issue got resolved. I'm now able to modify the flow-config.xml file.
    Just removed some log files and core dumps from the /tmp folder.

    Deployed the jar by placing it in the jars folder and restarting the server but still getting the classnotfound exception. :(

    Thanks,
    Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2012-01-02T10:58:30Z  
    The space issue got resolved. I'm now able to modify the flow-config.xml file.
    Just removed some log files and core dumps from the /tmp folder.

    Deployed the jar by placing it in the jars folder and restarting the server but still getting the classnotfound exception. :(

    Thanks,
    Abhijeet
    Finally.. Got the solution.
    You just need to make an entry of the new custom jar been added in the server.xml of the specific profile.

    Thanks all for your replies.
    ~Abhijeet
  • SystemAdmin
    SystemAdmin
    648 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2012-01-10T04:37:28Z  
    Finally.. Got the solution.
    You just need to make an entry of the new custom jar been added in the server.xml of the specific profile.

    Thanks all for your replies.
    ~Abhijeet
    the server.xml is updated by running the install_war.sh. I think you have an issue with your environment.
  • wpc_guy
    wpc_guy
    40 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2012-09-26T14:37:27Z  
    Hi,

    We are trying to implement Custom-Tools using both JSP and Servelts. After going through this thread, the sample discussed here are useful but not sure how to configure Servlet where we are writing most of our logic.

    Hi Babinag,

    In you reply posted on "Dec 22, 2011 06:22:17 AM", you mentioned that some additional operations are required if jsp use custom java logic developed as servlet. Can you please elaborate more on this using the same example provided in the same post.
    Thanks,
    Z
  • babinag
    babinag
    91 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2012-09-27T08:00:37Z  
    • wpc_guy
    • ‏2012-09-26T14:37:27Z
    Hi,

    We are trying to implement Custom-Tools using both JSP and Servelts. After going through this thread, the sample discussed here are useful but not sure how to configure Servlet where we are writing most of our logic.

    Hi Babinag,

    In you reply posted on "Dec 22, 2011 06:22:17 AM", you mentioned that some additional operations are required if jsp use custom java logic developed as servlet. Can you please elaborate more on this using the same example provided in the same post.
    Thanks,
    Z
    Hi, wpc_guy.

    1. First, example servlet:
    
    
    
    package com.example;   
    
    import com.ibm.ccd.api.utils.LoggerImpl; 
    
    import com.ibm.ccd.common.context.AustinContext; 
    
    import com.ibm.pim.context.Context; 
    
    import com.ibm.pim.context.PIMContextFactory; 
    
    import com.ibm.pim.organization.User; 
    
    import java.io.IOException; 
    
    import javax.servlet.RequestDispatcher; 
    
    import javax.servlet.ServletException; 
    
    import javax.servlet.ServletOutputStream; 
    
    import javax.servlet.http.HttpServlet; 
    
    import javax.servlet.http.HttpServletRequest; 
    
    import javax.servlet.http.HttpServletResponse; 
    
    import javax.servlet.http.HttpSession;   
    /** * * @author BabinAG */ 
    
    public 
    
    class MDMExampleServlet 
    
    extends HttpServlet 
    {   
    /* * Here is you logger, configured in log.xml */ 
    
    private 
    
    static 
    
    final LoggerImpl logger = 
    
    new LoggerImpl(null, 
    "com.ibm.ccd.wpc_user_scripting.CustomServlet");   
    /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ 
    
    protected 
    
    void processRequest(HttpServletRequest request, HttpServletResponse response) 
    
    throws ServletException, IOException 
    { HttpSession session = request.getSession(); AustinContext ctx = (AustinContext) session.getAttribute(
    "ctx"); AustinContext.setCurrentContext(ctx); String userName = 
    ""; 
    
    try 
    { Context apiContext = PIMContextFactory.getCurrentContext(); User currentUser = apiContext.getCurrentUser(); userName = currentUser.getName(); 
    //Various exceptions may be thrown if user is not authentificated 
    } 
    
    catch (Exception e) 
    { StringBuilder err = 
    
    new StringBuilder(); 
    
    for (StackTraceElement el : e.getStackTrace()) 
    { err.append(el.toString()).append(
    "\n<br>"); 
    } logger.logDebug(
    "Error: " + e.getMessage() + 
    "\n" + err.toString()); 
    } 
    
    if (!userName.isEmpty()) 
    { request.setAttribute(
    "CurrentUser", userName); RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher(
    "/ExampleMDMView.jsp"); requestDispatcher.forward(request, response); logger.logDebug(
    "Found authentificated user: " + userName); 
    } 
    
    else 
    { response.setContentType(
    "text/html;charset=UTF-8"); ServletOutputStream out = response.getOutputStream(); out.println(
    "Not  authentificated. Please, login to MDM from main page"); 
    } 
    }   
    /** * Handles the HTTP <code>GET</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override 
    
    protected 
    
    void doGet(HttpServletRequest request, HttpServletResponse response) 
    
    throws ServletException, IOException 
    { processRequest(request, response); 
    }   
    /** * Handles the HTTP <code>POST</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override 
    
    protected 
    
    void doPost(HttpServletRequest request, HttpServletResponse response) 
    
    throws ServletException, IOException 
    { processRequest(request, response); 
    } 
    }
    


    2. You must configure this servlet in web.xml, located at
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/yourServer/applications/ccd_pim.ear/deployments/ccd_pim/ccd.war/WEB-INF
    like:
    
    <?xml version=
    "1.0" encoding=
    "UTF-8"?> <!DOCTYPE web-app PUBLIC 
    '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 
    'http://java.sun.com/dtd/web-app_2_3.dtd'>   <!-- THIS FILE IS GENERATED by genDD.pl.  DO NOT EDIT -->   <web-app>   <servlet> <description>Example</description> <servlet-name>MDMExampleServlet</servlet-name> <servlet-class>com.example.MDMExampleServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MDMExampleServlet</servlet-name> <!-- needs .jsp to fuzaorequestFileter create session --> <url-pattern>/MDMExampleServlet.jsp</url-pattern> </servlet-mapping>   <!-- *********************filter definitions********************* -->   <!-- Change to put FuzaoRequest work inside filter --> <filter> <filter-name>FuzaoRequestFilter</filter-name> <filter-class>com.ibm.ccd.ui.filters.FuzaoRequestFilter</filter-class> </filter>   <!-- ResponseHeaderFilter has the following behavior: 1) If a requested header does not exist in the response, the header is added 2) If the header exists, it is replaced Therefore, 
    
    for all URLs which match more than 1 filter mapping 
    
    for the same header, the last match will determine the header in the response. --> ... the rest of xml
    


    3. Next you need to create jsp named ExampleMDMView.jsp:
    
    <%@page contentType=
    "text/html" pageEncoding=
    "UTF-8"%> <!DOCTYPE HTML PUBLIC 
    "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">   <html> <head> <meta http-equiv=
    "Content-Type" content=
    "text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Hello World!</h1> And you, <b><%=request.getAttribute(
    "CurrentUser")%></b><br> 
    
    this call is from jsp! </body> </html>
    

    And put this jsp at location
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServer/ccd_pim.ear/ccd.war/
    This is for dispatcher path
    
    RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher(
    "/ExampleMDMView.jsp");
    


    4. Next you are to create a example custom tool with asp/jsp-like option, that tool creates iframe and calls you servlet:
    
    <HTML> <center> <body bgcolor=
    "#ffffff"> <iframe name=
    "frame1" src=
    "/MDMExampleServlet.jsp" frameborder=
    "no" scrolling=
    "no" width=
    "100%" height=
    "100%"> </iframe> </body> </center> </html>
    


    5. stop/start you server
    6. ?????
    7. Profit!!!!
  • babinag
    babinag
    91 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2012-09-27T08:03:50Z  
    • babinag
    • ‏2012-09-27T08:00:37Z
    Hi, wpc_guy.

    1. First, example servlet:
    <pre class="jive-pre"> package com.example; import com.ibm.ccd.api.utils.LoggerImpl; import com.ibm.ccd.common.context.AustinContext; import com.ibm.pim.context.Context; import com.ibm.pim.context.PIMContextFactory; import com.ibm.pim.organization.User; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; /** * * @author BabinAG */ public class MDMExampleServlet extends HttpServlet { /* * Here is you logger, configured in log.xml */ private static final LoggerImpl logger = new LoggerImpl(null, "com.ibm.ccd.wpc_user_scripting.CustomServlet"); /** * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); AustinContext ctx = (AustinContext) session.getAttribute( "ctx"); AustinContext.setCurrentContext(ctx); String userName = ""; try { Context apiContext = PIMContextFactory.getCurrentContext(); User currentUser = apiContext.getCurrentUser(); userName = currentUser.getName(); //Various exceptions may be thrown if user is not authentificated } catch (Exception e) { StringBuilder err = new StringBuilder(); for (StackTraceElement el : e.getStackTrace()) { err.append(el.toString()).append( "\n<br>"); } logger.logDebug( "Error: " + e.getMessage() + "\n" + err.toString()); } if (!userName.isEmpty()) { request.setAttribute( "CurrentUser", userName); RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher( "/ExampleMDMView.jsp"); requestDispatcher.forward(request, response); logger.logDebug( "Found authentificated user: " + userName); } else { response.setContentType( "text/html;charset=UTF-8"); ServletOutputStream out = response.getOutputStream(); out.println( "Not authentificated. Please, login to MDM from main page"); } } /** * Handles the HTTP <code>GET</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } /** * Handles the HTTP <code>POST</code> method. * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { processRequest(request, response); } } </pre>

    2. You must configure this servlet in web.xml, located at
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/config/cells/yourServer/applications/ccd_pim.ear/deployments/ccd_pim/ccd.war/WEB-INF
    like:
    <pre class="jive-pre"> <?xml version= "1.0" encoding= "UTF-8"?> <!DOCTYPE web-app PUBLIC '-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN' 'http://java.sun.com/dtd/web-app_2_3.dtd'> <!-- THIS FILE IS GENERATED by genDD.pl. DO NOT EDIT --> <web-app> <servlet> <description>Example</description> <servlet-name>MDMExampleServlet</servlet-name> <servlet-class>com.example.MDMExampleServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MDMExampleServlet</servlet-name> <!-- needs .jsp to fuzaorequestFileter create session --> <url-pattern>/MDMExampleServlet.jsp</url-pattern> </servlet-mapping> <!-- *********************filter definitions********************* --> <!-- Change to put FuzaoRequest work inside filter --> <filter> <filter-name>FuzaoRequestFilter</filter-name> <filter-class>com.ibm.ccd.ui.filters.FuzaoRequestFilter</filter-class> </filter> <!-- ResponseHeaderFilter has the following behavior: 1) If a requested header does not exist in the response, the header is added 2) If the header exists, it is replaced Therefore, for all URLs which match more than 1 filter mapping for the same header, the last match will determine the header in the response. --> ... the rest of xml </pre>

    3. Next you need to create jsp named ExampleMDMView.jsp:
    <pre class="jive-pre"> <%@page contentType= "text/html" pageEncoding= "UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <h1>Hello World!</h1> And you, <b><%=request.getAttribute( "CurrentUser")%></b><br> this call is from jsp! </body> </html> </pre>
    And put this jsp at location
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServer/ccd_pim.ear/ccd.war/
    This is for dispatcher path
    <pre class="jive-pre"> RequestDispatcher requestDispatcher = getServletContext().getRequestDispatcher( "/ExampleMDMView.jsp"); </pre>

    4. Next you are to create a example custom tool with asp/jsp-like option, that tool creates iframe and calls you servlet:
    <pre class="jive-pre"> <HTML> <center> <body bgcolor= "#ffffff"> <iframe name= "frame1" src= "/MDMExampleServlet.jsp" frameborder= "no" scrolling= "no" width= "100%" height= "100%"> </iframe> </body> </center> </html> </pre>

    5. stop/start you server
    6. ?????
    7. Profit!!!!
    addition:
    compiled servlet must be located at
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServer/ccd_pim.ear/ccd.war/WEB-INF/classes/com/example
  • KaranBal
    KaranBal
    108 Posts

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2012-10-01T22:44:46Z  
    I got lost in the avalanche of code in this topic, here are my thoughts on the discussion that I remember:
    1. Classpath:
    If all you want to do is update the classpath, then install_war.sh is not needed. Just run $TOP/bin/go/start_local.sh and the classpath will be updated in WAS console.
    2. Custom jars:
    You can either add the new jar to the $TOP/jars directory or you can add it to a custom location and then mention that in one of the files in $TOP/bin/conf/classpath directory.
    3. install_war.sh:
    Be careful when running install_war and configureEnv.sh. They overwrite a lot of the default files and hence are dangerous. wrt to custom tools, they are implemented with .jsp files in the ccd.war directory. Depending on where your jsp is, install_war.sh can overwrite it. Hence your code may be lost and you may have to copy it again. Same goes for flow-config.xml
    4. Custom Tools:
    They are deployed using .wpcs script or asp-jsp code. I assume you are using jsp code. if that is so, then you do not need any jar. Just deploy your jsp file in WAS and configure your flow-config file such that if a user clicks on the tool, that jsp is executed.
    Babinag's description and steps are accurate.
    5. WAS Admin console:
    For WAS Admin console to be up, make sure your admin server, known as server1 is running. You can start it using "$WAS_HOME/profiles/AppSvr01/bin/startServer.sh server1".
  • tarek.righi
    tarek.righi
    1 Post

    Re: Issue in implementing a custom Tool functionality. ClassNotFound Exception!

    ‏2015-05-06T13:59:33Z  
    • babinag
    • ‏2012-09-27T08:03:50Z
    addition:
    compiled servlet must be located at
    /opt/IBM/WebSphere/AppServer/profiles/AppSrv01/installedApps/yourServer/ccd_pim.ear/ccd.war/WEB-INF/classes/com/example

    hi babinag

    I followed your example and it does not work