Chapter 4. Building a search page with Eclipse

Table of Contents

Description
Complexity
Technologies
Time required
Ingredients
Activity Plan
Launching and configuring Eclipse workspace
Creating the Eclipse project
Creating the SOAP stubs
Creating the support class
Creating the jsp pages
Running the project

Description

Integrate focuseek searchbox with the Tomcat application server, using the Eclipse IDE

Complexity

1 2 3 4 5

Requires creating a JSP page and a small set of support classes using the Eclipse IDE and some Eclipse plugins.

Technologies

???

Time required

Less than 2 hours

Ingredients

  • A working install of focuseek searchbox

  • A working install of java jdk, version 1.4.2 or later.

  • A working install of the Eclipse 3.0.1 IDE or later

  • A working install of the Eclipse plugin "lomboz". You must install a version compatible with your Eclipse IDE

  • A working install of the Eclipse plugin "SoapClipse" version 1.1.2 or later and its accompaining AXIS library. Please note you must download and install (unpack) the AXIS library coming with the plugin. See the documentation contained in the plugin download for more details.

  • A working install of

    Jakarta Tomcat version 4.1.x or later

Activity Plan

Launching and configuring Eclipse workspace

Launch the Eclipse GUI, create a new workspace with File, Switch workspace... and then choosing a new directory. Click on the button labeled Workbench. Now you must configure Eclipse perspectives to work with Lomboz; follow the instructions detailed in the Lomboz installation guide.

The last configuration step requires adding a classpath variable to the workspace. Choose the Window menu, then the Preferences menu item. The Preferences dialog will appear. In the left treeview choose Java, Build Path, Classpath Variables. Click New... and type AXIS as the name and the choose the folder you placed the AXIS files you installed along with the SoapClipse plugin as the path. Do the same steps again to add a JDK_TOOLS variable pointing to the tools.jar file of your jdk.

Click Ok. You may need to restart Eclipse in order to use the new settings.

Creating the Eclipse project

Right click in the Package Explorer pane and choose New, Lomboz J2EE Project. Type SBSearch as project name, then click Next; then make sure that SBSearch/src is marked as the source folder and that SBSearch/bin is the default output folder.

Now select the Libraries pane to add some extra libraries to the project. Click on Add Variable... and choose AXIS, then click on Extend... and choose the following JARs: axis.jar, commons-discovery.jar, commons-logging.jar, jaxrpc.jar, log4j-1.2.8.jar[1], saaj.jar, wsdl4j.jar. Click Next.

The J2EE Creation Wizard while configuring source and
            output folders

The J2EE Creation Wizard while configuring source and output folders

In the Web Modules tab click on Add... Type searchpage as the module name. Click on the Targeted Servers tab, choose Apache Tomcat v4.1.0 (or another later version matching your server) from the Type combobox then click Add.... Finally click on Apache Tomcat v4.1.0, click on Make Default and then on Finish

The J2EE Creation Wizard while configuring the target
            server

The J2EE Creation Wizard while configuring the target server

The last step consists in informing Eclipse that the Axis libraries must be shipped along with our web application. In the Package explorer open the searchpage (WEB) folder, then the WEB-INF folder and right click on the lib folder; choose Import... from the popup menu. Choose File System as the import source, then insert in the From directory text field the folder where your Axis JARs reside (it's the same folder you set the AXIS variable a few minutes ago). Choose the following JARs for import: axis.jar, commons-discovery.jar, commons-logging.jar, jaxrpc.jar, log4j-1.2.8.jar[2], saaj.jar, wsdl4j.jar. Click on Ok.

Now you have successfully created your Eclipse project and you are ready to go on interfacing Java and searchbox.

Creating the SOAP stubs

searchbox describes its SOAP interface using the WSDL standard. WSDL information is exposed by searchbox alongside the SOAP access point. In the following we'll assume that your searchbox installation is on localhost, port 2200.

Using your browser get the file http://localhost:2200/wsdl containing the WSDL description for searchbox[3]. Save it somewhere as searchbox.wsdl, then import searchbox.wsdl into Eclipse workspace: choose the File menu, then the Import... entry. Select File system as the import source, then click Next and specify the searchbox.wsdl file you saved earlier. Import it directly in the SBSearch folder in the workspace. searchbox.wsdl should appear in the Package Explorer.

Righ-click on searchbox.wsdl and choose Axis web services, WSDL2Java... from the popup menu. A dialog will appear. In the File container field type /SBSearch/j2src, then click on the Finish button.

Creating the support class

Eclipse should now be back to the Java perspective. First we have to create a new package. Righ-click on the folder j2src in the Package Explorer and choose New, Package. Type com.focuseek.cookbook as the package name.

Again right-click on com.focuseek.cookbook and choose New, Class. Type SearchboxSearch as the class Name and click Finish. Then cut and paste the contents of the file SearchboxSearch.java from the examples/cookbook/eclipse-search-page directory found in your searchbox installation folder into the newly created class.

Creating the jsp pages

Look at the Package Explorer: two jsp pages has been created. Double click on index.jsp, remove the whole file content and replace it with the content of the file index.jsp from the examples/cookbook/eclipse-search-page directory found in your searchbox installation folder.

Package Explorer showing jsp pages

Package Explorer showing jsp pages

If the searchbox engine is not deployed on your local computer or if you changed the default administrator user or password you must specify the SOAP endpoint for the engine in the jsp. Change the

null

parameter in the initialization

SearchboxSearch src = new SearchboxSearch(null);

to a string containing the URL of the endpoint, inclusive of username and password. For example the default endpoint is

"http://admin:password@localhost:2200/soap"

Running the project

Click on Window, Show view, Other..., then choose the subitem Lomboz J2EE View in the Lomboz J2EE group. Go to the newly created view, expand the SBSearch node and the searchpage node. Right click on the searchpage node and choose deploy. Then right click on the Apache Tomcat vx.y.z item and choose Run server. Your application is now running in Tomcat.

To access it open your browser, go back to the Package Explorer, right click on searchpage (WEB) and choose Lomboz J2EE..., Show in browser.

You are done: the jsp page will show all the collections available to the user you are using in the page itself and will allow you to query the collection with the usual searchbox syntax.



[1] The version number might obviously differ.

[2] The version number might obviously differ.

[3] Depending on your searchbox settings your browser might require a password to access the wsdl file. Contact your searchbox administrator if you don't know the required username/password pair.