All utility projects in an EAR project are automatically compiled into JARs that are copied into the APP-INF/lib directory of the deployed EAR.
As an alternative, you may specify that the utility project should be compiled into the WEB-INF/lib folder of a web project where it will be available only to that project.
A utility project can be added to more than one EAR project and available to more than one web project.
Option 1: Making Utility Projects Available to Web Projects at Project Creation
When creating a web services project or dynamic web project, if you choose Add project to an EAR on the first screen of the wizard, then one of the screens of the project creation wizard has the following default settings:
Customizing Project Dependencies
Note that if you did not choose Add project to an EAR on the first screen of the creation wizard, then the Add a
dependency from this project to all Web projects in the EAR option will not be displayed and you must add the
project to an EAR manually.
The default setting Add a dependency from this project to all Web projects in the EAR specifies that ALL of the utility and EJB projects will be available to this project when it is built. To make selective dependencies to specific
projects, uncheck the Add a dependency from this project to all Web projects in the EAR option. You must
then make any needed utility or EJB projects available explicitly.
Option 2: Adding a Utility Project to a Specific Web Project
When a utility project is already added to the EAR, you can add that utility project to a web project:
1. Right click on the web services or dynamic web project name in the Package Explorer view and choose
Properties from the popup menu. Click on J2EE Module Dependencies in the bar at the left. Be sure that the
J2EE Modules tab is selected.
Customizing Project Dependencies
2. Check the box beside the name of the utility project. Click Apply to save the change.
After the utility project is added, it will appear on the build path for this web project and the utility project types will be available in the IDE. Note that the Java Build Path option on the Properties dialog does not set up project dependencies correctly for Workshop for WebLogic projects. Adding a utility project to a web project means that the web project will access the shared copy of the utility module in the EAR. No files will be copied to the web project.
Note that the References to EJB JARs with EJB Client JARs box and the Use EJB JARs, Use EJB client JARs
and Allow both buttons are not used by Workshop for WebLogic. Note also that EJB projects do not appear on the
Web Libraries tab because EJBs are not libraries.
Option 3: Moving a Utility Project from an EAR Project to a Web Project
To add a utility project to a web project:
1. Right click on the web services or dynamic web project name in the Package Explorer view and choose
Properties from the popup menu. Click on J2EE Module Dependencies in the bar at the left. Be sure that the
J2EE Modules tab is selected.
Customizing Project Dependencies
Uncheck the box beside the name of the utility project. Click Apply to save the change.
Note that the References to EJB JARs with EJB Client JARs box and the Use EJB JARs, Use EJB client
JARs and Allow both buttons are not used by Workshop for WebLogic. Note also that EJB projects do not
appear on the Web Libraries tab because EJBs are not libraries.
2. Now click the Web Libraries tab. In the sample below, there is a new utility project which is not added to the current project.
Customizing Project Dependencies
3. Click in the box beside the project name and click OK to add the new utility project to the existing project and make a virtual copy of its JAR file in the WEB-INF/lib folder of this project so that it will be available for build/ deployment.
The J2EE Module Dependencies option is the recommended option for creating project dependencies in Workshop for WebLogic. Do not use the Java Build Path option to set project dependencies because it does not create all dependencies correctly.
Now you must stop the utility project from compiling into the EAR's APP-INF/lib directory by: 1. Select the EAR project by clicking on the EAR project name in the Package Explorer view.
2. Click Project > Properties and from the Properties dialog, click on J2EE Module Dependencies in the bar at the left.
3. Click in the box beside the project name to REMOVE the check mark and click OK to remove the utility project from the EAR project.
Option 4: Adding A Utility Project from Outside the EAR
Customizing Project Dependencies
A utility project can also be added to a web project in an EAR even though the utility project is not added to the EAR itself. To do that:
1. Right click on the web services or dynamic web project name in the Package Explorer view and choose
Properties from the popup menu. Click on J2EE Module Dependencies in the bar at the left. Click the Web
Libraries tab. In the sample below, there is a new utility project which is not added to the current project.
2. Click in the box beside the project name and click OK to add the new utility project to the existing project and copy its JAR file to the WEB-INF/lib folder of this project on deployment.
Utility projects that are not added to the EAR can ONLY be added through the WEB-INF\lib folder of individual web projects.