cancel
Showing results for 
Search instead for 
Did you mean: 

Using External JARs in a Web Dynpro Project

Former Member
0 Kudos

Hi,

I'm having some difficulties building and deploying a Web Dynpro application that uses the Apache JaxMe libraries. We're using SP11 of Developer Studio and WebAS and we're using JDI Scenario 2+ for building and deployment. Thus far here's the procedure I followed:

1) Created a DC of type "External Library"

2) Added the necessary jars to the "libraries" folder of the External Library DC project (the jars that I added were jaxme2-rt.jar, jaxme2.jar, jaxmeapi.jar, jaxmejs.jar, jaxmepm.jar, jaxmexs.jar, xercesImpl.jar, xml-apis.jar all of which were pulled from the Apache JaxMe implementation download)

3) For each of the jars in the libraries folder I right-clicked, selected Develoment Component then clicked "Add to public part"

Then after reading this note:

https://websmp206.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=012006153200000038152005

I created a J2EE Library Component DC following these steps:

1) Created a new DC of type J2EE Server Component / Library

2) Added the External Library DC that I had just created as a "Used DC"

3) Edited the DC so that it is used a Build Time and Run Time

Finally I went to the Web Dynpro application and included the J2EE Library Component DC as a Used DC at build time and run time.

I was able to build all of the project successfully (doing a DC build for each) then I was able to succesfully deploy the applications to my local development WebAs (by doing a DC deploy for both the J2EE Server Component and the Web Dynpro application) The problem is that at runtime the Web Dynpro application cannot find the external libraries. For example, I receive the following error when running the application:

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

The "missing" class is included in one of the jars but for some reason these jars are not accessible to Web Dynpro at runtime.

Any help you can provide on this problem is very much appreciated.

Thanks in advance!

Jason

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

I created the <b>JAR</b> with the following class (structure):

<b>com.sap.tc.webdynpro.tests.utils.TableSorter.class</b>

I have followed the steps that was suggested in the forum:

==========================================================

1) creating an Extneral library DC

2) import the JAR "com.sap.tc.webdynpro.tests.util.jar" to the libraries folder of the External Library DC project

3) Right-click on the JAR imported to the project and add them to the public part.

This DC is now ready to be used as a build-time reference that will allow CBS to build the "main" Web Dynpro application that will use the external libraries. Next, we have to create a new Web Dynpro DC to hold the class files here are the steps:

1) Create a new Web Dynpro DC

2) Create a new public part, selecting the "Can be packaged into other build results" option

3) Rename the JARs as Zip files and extrct the full content (folders and class files) to your root folder

4) Import the folders and files to the src/packages folder

5) Expand the public part node that was created and select the "Entities" node, right-click it and choose Edit

6) In the Entity Type list select the "Folder" option then in the selected entities tree pick each of the folders that you imported in step 5 (above)

7) Now do a DC build and a DC deploy of the project

Then check-in, activate, and release any activities you have associated with creating these two projects. In the DC perspective, refresh the Active DCs and Inactive DCs to ensure that both new DCs appear in the Active list. Now we have to setup the references to these DCs in our main Web Dynpro application. To do this, follow these steps:

1) Open the Web Dynpro perspective and right click the Used DCs node then choose "Add Used DC.."

2) Pick the public part of the External Library DC that we created (first) and set it to have a Build Time dependency

3) Again, right click the Used DCs node and choose "Add Used DC.." then choose the public part of the Web Dynpro DC that we created and give it a Run Time dependecy (weak) and click finish.

4) Now, due to what I think is a bug. You must right click on the Web Dynpro "used DC" that you just added in the previous step, and set the run time dependency again (it seems to revert to the default values for some reason)

5) Now do a DC build and a DC deploy on the "main" web dynpro application.

6) Check-in, activate, and release any activities associated with adding these references and then others on your team may use the classes in the external libraries within the Web Dynpro project.

However, when I executed, the following exception occurred:

===========================================================

Error stacktrace:

java.lang.<b>NoClassDefFoundError</b>: <i>com/sap/tc/webdynpro/tests/utils/TableSorter</i>

at br.com.embraer.materiais.zdplmm001.view.Zdplmm001_0500View.wdDoModifyView(Zdplmm001_0500View.java:138)

...

...

<b>What's missing????</b>

Thanks

Robson Lima

Sao Paulo - Brazil

Former Member
0 Kudos

Pascal is correct, creating External Library DCs is the best approach for referencing external libraries. However we ran into a bug in SP11 that required external libraries to be packaged into a deployable project for their runtime dependency .

If you're running SP12 then that issue has been fixed so my recommendation would be to create an external library DC, import your JAR files into the external library DC and add each JAR to the public part, then refernece the public part of the external library DC in your Web Dynpro project. Once we upgraded to SP12 we actually changed our reference to external libraries to use this approach as it is much simpler and as Pascal pointed out that is the intended pupose of External Library DCs.

If you're running a version prior to SP11 you're probably going to have to package your JARs into a deployable project as I outlined earlier in the thread (that was the only way we were able to successfully reference and deploy external libraries.) One suggestion is to check the properies of the "Used DCs" in your main Web Dynpro project as I have noticed that sometimes the properties for build and runtime referneces must be "checked" and saved twice before the change is actually commited.

Former Member
0 Kudos

Thanks to everyone for your replies.

The way I finally was able to get the external libraries to work was by

1) creating an Extneral library DC

2) import the JARs to the libraries folder of the External Library DC project

3) Right-click on each of the JARs imported to the project and add them to the public part.

This DC is now ready to be used as a build-time reference that will allow CBS to build the "main" Web Dynpro application that will use the external libraries. Next, we have to create a new Web Dynpro DC to hold the class files here are the steps:

1) Create a new Web Dynpro DC

2) Create a new public part, selecting the "Can be packaged into other build results" option

3) Rename the JARs as Zip files and extrct the full content (folders and class files) to your root folder

4) Import the folders and files to the src/packages folder

5) Expand the public part node that was created and select the "Entities" node, right-click it and choose Edit

6) In the Entity Type list select the "Folder" option then in the selected entities tree pick each of the folders that you imported in step 5 (above)

7) Now do a DC build and a DC deploy of the project

Then check-in, activate, and release any activities you have associated with creating these two projects. In the DC perspective, refresh the Active DCs and Inactive DCs to ensure that both new DCs appear in the Active list. Now we have to setup the references to these DCs in our main Web Dynpro application. To do this, follow these steps:

1) Open the Web Dynpro perspective and right click the Used DCs node then choose "Add Used DC.."

2) Pick the public part of the External Library DC that we created (first) and set it to have a Build Time dependency

3) Again, right click the Used DCs node and choose "Add Used DC.." then choose the public part of the Web Dynpro DC that we created and give it a Run Time dependecy (weak) and click finish.

4) Now, due to what I think is a bug. You must right click on the Web Dynpro "used DC" that you just added in the previous step, and set the run time dependency again (it seems to revert to the default values for some reason)

5) Now do a DC build and a DC deploy on the "main" web dynpro application.

6) Check-in, activate, and release any activities associated with adding these references and then others on your team may use the classes in the external libraries within the Web Dynpro project.

-Jason

Former Member
0 Kudos

Excellent summary!

Thank you very much.

Armin

Former Member
0 Kudos

I am having the exact same problem (using external JARs). I have tried following what Jason wrote here, but get stuck in the first part:

1) creating an Extneral library DC

2) import the JARs to the libraries folder of the External Library DC project

3) Right-click on each of the JARs imported to the project and add them to the public part.

Exactly what is the procedure (click-by-click) for doing steps 2 and 3 above?

Walter

Former Member
0 Kudos

2: Just view the project in the Java perspective and then drag your jar files from Windows Explorer onto the libraries folder.

3: Right-click the added jars -> Development Component -> Add to public part

Former Member
0 Kudos

2. copy all jars in Windows Explorer, open ur External Library DC in java perspective. In the tree hierarchy locate src/package, right click and paste..

3. expand src/package node, right click each node and choose Add to public part

Former Member
0 Kudos

You must put them in the "libraries" folder, not the "src/packages" folder for an External Library DC!

Former Member
0 Kudos

When I go to build I get errors that the package doesn't exist. This is the specific error.

...\src\packages\jaxb-xjc\com\sun\tools\xjc\runtime\AbstractUnmarshallingEventHandlerImpl.java:5: package javax.xml.bind does not exist

import javax.xml.bind.Element;

When I imported the jars that I renamed to zips I kept the file names so that my folder structure is contains the name of the jar and then begins the structure. This is because some of the packages have a similar structure.

Former Member
0 Kudos

I think the compiler/classloader only loads files with a .jar extension, not files with a .zip extension...

And you don't need to create a folder structure in an External Library DC. Just put all jars you need in the "libraries" folder.

Former Member
0 Kudos

I was following Jason's walk throug above. Where I am having the errors is on the second part. Do I not need to wrap the external JARs in WD? TIA

This DC is now ready to be used as a build-time reference that will allow CBS to build the "main" Web Dynpro application that will use the external libraries. Next, we have to create a new Web Dynpro DC to hold the class files here are the steps:

1) Create a new Web Dynpro DC

2) Create a new public part, selecting the "Can be packaged into other build results" option

3) Rename the JARs as Zip files and extrct the full content (folders and class files) to your root folder

4) Import the folders and files to the src/packages folder

5) Expand the public part node that was created and select the "Entities" node, right-click it and choose Edit

6) In the Entity Type list select the "Folder" option then in the selected entities tree pick each of the folders that you imported in step 5 (above)

7) Now do a DC build and a DC deploy of the project

Former Member
0 Kudos

I think it's better to use an External Library DC for external libraries (it's not called like that for nothing!). See also my last reply to this topic: /thread/47565 [original link is broken]

Former Member
0 Kudos

Hi Jason,

Try the following

1. Open the config tool (c:\usr\sap\J2E\JC00\j2ee\configtool\configtool.bat)

2. Expand and Select Server_ID<<Some number>> (cluster-data>instance_ID<<some number>>>Server_ID<<Some number>>)

3. In the "classpath" input field add the external jar file to be added (Give the full path of the jar file)

4. Restart your J2EE engine and run your application.

Hope this solves your problem.

Regards,

Santhosh.C

Former Member
0 Kudos

Check this: