Adding a Custom Exception
| |
|
|
| |
Table of Contents |
|
| |
|
|
Adding the Exception
- In Introduce with the Modify Service Interface window open for the tutorial service, click the Operations tab.
- Select the findGenesSharePathways method in the Operations table.
- Click the Modify button.
- When the Build/Modify Operation dialog appears select the Faults tab.
- At the bottom of the panel there is a text box for creating a new fault type. Enter the fault name NoSharedPathwayGenesFound
- Click the Add New Fault. You will see the new fault was created and added to the table in the upper right.
- Click the Done button.
- Click the Save button. (this make take a few minutes in order to modify and regenerate the service skeleton)
Edit the Service to Throw the Exception
- Open for editing the file C:\CaGridTutorialService\src\gov\nih\nci\cagrid\tutorial\service\CaGridTutorialServiceImpl.java. You should see in the findGenesSharePathway method that it now throws the new exception NoSharedPathwayGenesFound. We will now modify the service to use the exception.
After the line
java.util.List rList = appService.query( new gov.nih.nci.common.util.HQLCriteria(hql), gov.nih.nci.cabio.domain.Gene.class.getName());
Add
if (rList == null || rList.size() <= 0) {
throw new gov.nih.nci.cagrid.tutorial.stubs.types.NoSharedPathwayGenesFound();
}
- Save the modified class file.
Edit the Client to Cause the Exception
- Open for editing the file C:\CaGridTutorialService\src\gov\nih\nci\cagrid\tutorial\client\CaGridTutorialServiceClient.java
- In the main method replace the "BRCA1" text with "I Love CaGrid". This will cause our service to throw the new exception because no gene exists with that symbol.
- Save the modified file.
Re-Deploy
- Click the Deploy Service button at the top of the Introduce portal. Using the file selection dialog, browse to the root directory of your newly created data service ( C:\CaGridTutorialService ). When the service deployment dialog appears, set the Deployment Location to GLOBUS_LOCATION using the drop down provided.
Re-Start the Service Container
- Using a new command prompt, change to the Globus location directory and start up Globus. (If globus is already running, be sure to terminate it before you proceed with starting another one.)

%> cd %GLOBUS_LOCATION%\bin
%> globus-start-container.bat -containerDesc ..\..\certificates\security-descriptor.xml
Invoke
- At the command prompt, change to the data service root directory and run the ant task to launch the client.

%> cd C:\CaGridTutorialService\
%> ant runClient -Dservice.url=https://localhost:8443/wsrf/services/cagrid/CaGridTutorialService
- The client should throw an exception of the type gov.nih.nci.cagrid.tutorial.stubs.types.NoSharedPathwayGenesFound






