Configuring GEP to publish POJO projects as shared library is illustrated using a web application and adding a POJO project as a dependency. In order to create a new web project and publish its dependency on a POJO project as shareld library, follow the steps given below:
- Create a HelloWorld Dynamic Web project as given in Web applications.
- Create a POJO project as given below:
- Click File -> New -> Project.
- Select Java Project and click Next.
- Enter CurrencyConverterPojo as the project name and click Finish. (If asked to switch to Java perspective, you may select No).
- In Project Explorer view, right-click on CurrencyConverterPojo, select New -> Class.
- Enter myPackage as package name, CurrencyConverter as class name and click Finish.
- Replace the content of CurrencyConverjer.java with the contents from CurrencyConverter.java.
- Press Ctrl + S to save changes.
- Add POJO project into web-app's Java Build Path as given below:
- In Project Explorer view, right-click on HelloWorld, and click Properties.
- Click Java Build Path and then switch to Projects tab.
- Click Add. Select CurrencyConverterPojo as the project to be added and click OK. Click OK again.
- To use POJO inside web-app's index.jsp:
- Double click on HelloWorld -> WebContent -> index.jsp to open it in JSP editor.
- Add the following code before the </body> tag.
- Press Ctrl + S to save the changes.
- Enable in-place shared library support in Server editor as given below:
- In Servers view, double click on Apache Geronimo v2.1 Server at localhost to open the server editor.
- In the server editor, under Test Environment, select Enable in-place shared library support.
- Press Ctrl + S to save the changes.
- To add a dependency on org.apache.geronimo.configs/sharedlib//car in geronimo-web.xml:
- Double click on HelloWorld -> Web Content -> WEB-INF -> *geronimo-web.xml" to open it in Geronimo Deployment Plan Editor.
- In General tab, select Add a run time dependency to Geronimo's shared library.
- Press "Ctrl+S" to save the file.
- To run the HelloWorld application:
- Right click on HelloWorld, click Run As -> Run on Server.
- Select Apache Geronimo v2.1 Server at localhost and click Finish. This will run the application and the welcome page will open in a browser inside eclipse.
Use the steps below to verify that the dependency on POJO project is indeed added as a shared library:
- Verify that a file HelloWorld.eclipse.jar is created under <geronimo_home>/var/shared/lib.
- Verify that the Manifest.mf file in HelloWorld.eclipse.jar contains the following: