Problem using Java HealthVault Library from IBM Lotus Domino

Jun 18, 2012 at 7:45 PM

Hello,

 

Just wondering if there is anyone in this community that has any experience connecting to MS Health Vault using HealthVault Library Java and IBM Lotus Domino. 

I'm not having much luck getting any sample code I write to run either as Domino Agent Code or Xpage bean code. 

If any one could give me some pointers of which jar files should be imported into domino database, just in case I'm missing any and if there are any customizations necessary, I would greatly appreciate that.

Thank you in advance.

Coordinator
Jun 18, 2012 at 7:47 PM

Hi,

What kind of errors are you getting?

--Rob

Jun 18, 2012 at 8:08 PM

In the Domino Agent Code, I have the following sample code.  This does not even compile when run as a domino agent:

import lotus.domino.*;

import com.microsoft.hsg.methods.jaxb.createconnectrequest.request.CreateConnectRequestRequest;
import com.microsoft.hsg.methods.jaxb.createconnectrequest.response.CreateConnectRequestResponse;
import com.microsoft.hsg.methods.jaxb.SimpleRequestTemplate;
import com.microsoft.hsg.Connection;

public class HelloWorld extends AgentBase {

    public void NotesMain() {

        try {
            Session session = getSession();
            AgentContext agentContext = session.getAgentContext();

            // (Your code goes here)
            System.out.println( "Phish:  Creating connection request" );
            CreateConnectRequestRequest request = new CreateConnectRequestRequest();
           
            System.out.println("Phish:  Poulating request with user data");
            request.setExternalId( "test" );
            request.setQuestion( "Test Question?" );
            request.setAnswer( "Test Answer?" );
            request.setFriendlyName ( "John Smith" );
           
            System.out.println("Phish:  Create a connection" );
            Connection con = new Connection();
            System.out.println( con.toString());
           
            System.out.println("Phish:  send the request /get the response" );
            SimpleRequestTemplate srt= new SimpleRequestTemplate(con);
           
           
            /*
            System.out.println("Phish:  Try something");
            CreateConnectRequestResponse response;
             srt.makeRequest(request);
            response= srt.makeRequest(request);  */
           
           

        } catch(Exception e) {
            e.printStackTrace();
        }
    }
}

 

I get the following error in Domino Designer when I try to save this:

HelloWorld.java:31:  cannot access Connection

class file for Connection not found

                        SampleRequestTemplate srt= new SimpleRequestTemplate(con);

1 error

 

I have imported the following JARs imported under "Edit Project":

commons-codec-1.3.jar

hv-sdk-1.3.1.jar

log4j-1.2.14.jar

hv-jaxb-1.3.1.jar

propertiescert.jar  <-- contains my properties file and keystore

 

Am I missing JAR files here?  When I remove the line "SimpleRequestTemplate srt= new SimpleRequestTemplate(con);" from the sample code, the agent runs.

 

<<Aside>>  I have decided to temporarily abandon the Xpages version of this, since the call to create a Connection object by the Java bean, resulted in a web server error.  I was not getting a stack trace for this error despite my effort, but through some trial and error debugs with print statements, it looks like that error was being caused by log4j not being able to properly initialize.  For the time being I would like to focus on getting the Domino Agent version to run.

I have the following JARs imported

Jun 18, 2012 at 8:10 PM

*Edit:  To avoid confusion "I have the following JARs imported" line should not appear at the bottom of the above post.  I forgot to delete when crafting my post.

Coordinator
Jun 21, 2012 at 11:00 PM

Hi,

I don't know your environment so I'm not sure I can help debug your class not found issue.  The class "Connection" is in the hv-sdk-1.3.1.jar.  The class SimpleRequestTemplate" is in the hv-jaxb-1.3.1.jar.

You will need to create a connection from the ConnectionFactory, however.  You can build one up yourself, but the Factory sets up many of the necessary parts to make it work.

--Rob

Jun 22, 2012 at 8:28 PM

Thank you Rob,  I realized that I was missing the ConnectionFactory after I made this post.  Regardless, that was not the cause of this error.  I have not yet solved this problem using a Domino Agent approach and decided to invoke my code by using XPages from Domino.  Looks like I got a bit further, but I ran into an issue with this approach.  I'm hoping you can point me in the right direction.   This is the code I'm using:

/**
 *
 */
package ca.on.argi.asthmacdr.control;

import java.io.Serializable;
import com.microsoft.hsg.Connection;
import com.microsoft.hsg.ConnectionFactory;
import com.microsoft.hsg.methods.jaxb.createconnectrequest.request.CreateConnectRequestRequest;
import com.microsoft.hsg.methods.jaxb.createconnectrequest.response.CreateConnectRequestResponse;
import com.microsoft.hsg.methods.jaxb.SimpleRequestTemplate;




/**
 * @author
 *
 */

public class InformationServiceTest implements Serializable {
    private Patient patient;
    private Connection connection;
   
   
   
    public static void main(String[] args) {
        System.out.println("Main method");
    }

    /**
     *
     */
    private static final long serialVersionUID = 1L;
   
    public void testMethod(int a){
        System.out.println("Starting the method " + a + " time(s)");
       
        setPatientTestData();
       
        createConnection();
   
    }
   
    public void setPatientTestData(){
        this.patient = new Patient();
        patient.setFirstName("John");
        patient.setLastName("Smith");
        patient.setUserQuestion("Question?");
        patient.setUserAnswer("Answer");
        patient.setExternalID("test@test.com");
   
    }
   
    public void createConnection(){
        CreateConnectRequestRequest request = new CreateConnectRequestRequest();
        request.setQuestion(this.patient.getUserQuestion());
        request.setAnswer(this.patient.getUserAnswer());
        request.setFriendlyName((this.patient.getFirstName() + " " + this.patient.getLastName()));
        this.connection = getConnection();
        SimpleRequestTemplate srt;
        srt = new SimpleRequestTemplate( this.connection );
       
        CreateConnectRequestResponse response;
        try{
           
            response = (CreateConnectRequestResponse) srt.makeRequest(request);
        } catch (Exception e){
            e.printStackTrace();
        }
       
       
   
    }
   
    public Connection getConnection(){
       
        Connection connection = null;
               
        try{
            if(connection == null){
       
                connection = ConnectionFactory.getConnection();
             
            }   
        } catch (Exception e){
            e.printStackTrace();
        }
       
        return connection;
    }

      
}

 


    The entry point which is called by my test XPage is  public void testMethod(int a).

 

However, it appears that when the line   response = (CreateConnectRequestResponse) srt.makeRequest(request); is executed, I get the following exception in the server console:

 

06/22/2012 12:41:53 PM  HTTP JVM: javax.xml.bind.JAXBException: java.io.IOException: Unable to open NSF URL xspnsf://server:0/AdamTest.nsf/com/microsoft/hsg/methods/jaxb/createconnectrequest/request/jaxb.properties
06/22/2012 12:41:53 PM  HTTP JVM:  - with linked exception:
06/22/2012 12:41:53 PM  HTTP JVM: [java.io.IOException: Unable to open NSF URL xspnsf://server:0/AdamTest.nsf/com/microsoft/hsg/methods/jaxb/createconnectrequest/request/jaxb.properties]
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.xml.bind.ContextFinder.loadJAXBProperties(ContextFinder.java:424)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.xml.bind.ContextFinder.find(ContextFinder.java:267)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:385)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:350)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.microsoft.hsg.oxm.jaxb.JaxbContextFactory.getContext(JaxbContextFactory.java:18)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.microsoft.hsg.methods.jaxb.SimpleRequestTemplate.makeRequest(SimpleRequestTemplate.java:57)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.microsoft.hsg.methods.jaxb.SimpleRequestTemplate.makeRequest(SimpleRequestTemplate.java:38)
06/22/2012 12:41:53 PM  HTTP JVM:       at ca.on.argi.asthmacdr.control.InformationServiceTest.createConnection(InformationServiceTest.java:122)
06/22/2012 12:41:53 PM  HTTP JVM:       at ca.on.argi.asthmacdr.control.InformationServiceTest.testMethod(InformationServiceTest.java:90)
06/22/2012 12:41:53 PM  HTTP JVM:       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06/22/2012 12:41:53 PM  HTTP JVM:       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:59)
06/22/2012 12:41:53 PM  HTTP JVM:       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:39)
06/22/2012 12:41:53 PM  HTTP JVM:       at java.lang.reflect.Method.invoke(Method.java:612)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.types.JavaAccessObject.call(JavaAccessObject.java:260)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.types.FBSObject.call(FBSObject.java:142)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.ASTTree.ASTCall.interpret(ASTCall.java:146)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.ASTTree.ASTProgram.interpretEx(ASTProgram.java:100)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.JSExpression.interpretExpression(JSExpression.java:396)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:247)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.jscript.JSExpression.evaluateValue(JSExpression.java:234)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.javascript.JavaScriptInterpreter.interpret(JavaScriptInterpreter.java:193)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.binding.javascript.JavaScriptMethodBinding.invoke(JavaScriptMethodBinding.java:102)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.application.ActionListenerImpl.processAction(ActionListenerImpl.java:59)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.faces.component.UICommand.broadcast(UICommand.java:324)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.UIEventHandler.broadcast(UIEventHandler.java:333)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.FacesEventWrapper.broadcast(FacesEventWrapper.java:69)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.UIDataPanelBase.broadcast(UIDataPanelBase.java:323)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.FacesEventWrapper.broadcast(FacesEventWrapper.java:69)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.UIFormEx.broadcast(UIFormEx.java:239)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.FacesEventWrapper.broadcast(FacesEventWrapper.java:69)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.component.UIViewRootEx.broadcast(UIViewRootEx.java:817)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:289)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:409)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:94)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:226)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:183)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:151)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:148)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:128)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:113)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:354)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:414)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:508)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:451)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:343)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:398)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:143)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:221)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:183)
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:222)
06/22/2012 12:41:53 PM  HTTP JVM: Caused by:
06/22/2012 12:41:53 PM  HTTP JVM: java.io.IOException: Unable to open NSF URL xspnsf://server:0/AdamTest.nsf/com/microsoft/hsg/methods/jaxb/createconnectrequest/request/jaxb.properties
06/22/2012 12:41:53 PM  HTTP JVM:       at com.ibm.domino.xsp.module.nsf.NotesURL$NSFURLConnection.getInputStream(NotesURL.java:163)
06/22/2012 12:41:53 PM  HTTP JVM:       at java.net.URL.openStream(URL.java:1022)
06/22/2012 12:41:53 PM  HTTP JVM:       at javax.xml.bind.ContextFinder.loadJAXBProperties(ContextFinder.java:418)
06/22/2012 12:41:53 PM  HTTP JVM:       ... 51 more

 

Should the jaxb.properties file be requested from the com/microsoft/hsg/methods/jaxb/createconnectrequest/request/ path, or is there something else that could be causing this exception?  Something in SimpleRequestTemplate?

 

Any help on this is greatly appreciated.