There are a lot of messages on SDN forums regarding using third-party libraries in SAP J2EE applications. Also there is a complete section available at http://help.sap.com, many developers either find it incomplete or cannot find it at all (I bet majority even don’t try to search, but this is different topic).
Step 0. Preparation
First download latest Rhino build from mozilla.org and extract
file from Zip archive. Mozilla download page contains broken links, here is direct link to Rhino 1.6 R2 / RC2 .
Next, activate “Development Configurations” perpective in NetWeaver IDE (use menu path: “Window -> Open Perpective -> Other…”). We will create all necessary development components (DC for short) in Local Development / My Components branch.
Activate “Development Configurations” view.
Step 1. Create and build “External Library”
Switch to “Development Configurations” perpective if you are not already there, drill down to “Local Development -> My Components”, right-click and select “Create New DC…” command
Running “Create New DC…” dialog.
Now fill in all necessary fields as shown below and click finish.
Create “External Library” DC.
IDE will create and open automatically necessary project. In root project directory find a folder
(in my environment NetWeaver shows it in project tree, but does not create it on disk – just create it manually). Now copy
from Rhino distribution here. Next, select
folder in IDE, right-click on it and call “Refresh” command.
After IDE synchronized changes with file system, right-click on jar file in tree and select “Development Component -> Add To Public Part”
Adding Aarchive (js.jar) to public part
public part for this type of projects, so simply select it in appeared dialog and click “OK”. Afterwards right-click on project itself and run command “Development Component -> Build”. Step complete.
Step 2. Create, build, deploy “J2EE Server / Library”
After we have created and built
DC we need to deploy it to SAP J2EE server somehow. So next create “J2EE Server Component / Library” DC:
Create “J2EE Server Component / Library” DC
Note that during project createion NetWeaver IDE may prompt you to open
JEE Development Perspective
. Just agree with it. Along this it will open
J2EE DC Explorer
view (switch to this view yourself if this doesn’t happen). Now expand project structure to “DC Metadata -> DC Definition -> Used DCs”. Activate contextual menu on last node and invoke “Add Used DC…”. Add reference to the public part of previously created
here. Note, that you have to specify both build time and run-time dependency here. Otherwise created SDA file will not contain js.jar from external library.
Add used DC (External Library) to J2EE library
It is time to build the project and analyze results. First of all you have to check generated SDA file in
folder. Verify that it contains
. Now something interesting. Go to
folder. You should find here
folder. Yes, NetWeaver IDE again created public part, this time it is
. And if you drill down to
then you meet
From now you may refere this (defLib) public part in the rest of SAP J2EE projects. But before we have to deploy it!. So, context menu on SAP J2EE Component / Library project, “Development Component -> Deploy”. Everything should go smoothly, let us verify results and run Visual Administrator:
Scroll to Libraries node
Step 3. Create WebDynpro Development Component
So, two initial tasks should be known for you: we will create WebDynpro Development Component and add
public part of
DC to it (the only difference is that here build-time dependency is enough):
Create “WebDynpro” DC.
Add used DC (defLib) to WebDynpro DC
to aforementioned library to let class loader find necessary classes at run-time. Run contextual menu on project root in IDE and select “Properties”, then switch to “WebDynpro References ->
Library references” and add “mozilla.orgjslib” (you may see the name in Visual Administrator):
Heck, we “invent” tool before task 😉 If anyone has ideas how scripting could be applied in WebDynpro you are welcome to share your thoughts in comments!</p>