cancel
Showing results for 
Search instead for 
Did you mean: 

Using external JARs in Web Dynpro Dev.Component

Former Member
0 Kudos

Hi,

I wonder how to use external JARu00B4s (e.g. the <b>commons-lang.jar</b> of the jakarta commons project) in a Web Dynpro Development Component.

I copied the JAR file into the lib directory of my Dev.component project, added it to the build path and built the project.

At runtime I get a "<b>java.lang.NoClassDefFoundError: org/apache/commons/lang/WordUtils</b>"

When inspecting the generated EAR resp. WDA file I can see that the JAR file is located in /PORTAL-INF/classes directory of the WDA file. It is also extracted to the folder

\usr\sap\...\server0\apps\<vendor>\<compname>\webdynpro\public\classes

This folder is displayed as classes directory in the classloader service of Visual Administrator.

So, why is the class not found at runtime?

Additionally I recognized another curious effect. When using the "development component - build" command from context menu of my dev. component the JAR file is deleted from the build path of my project whereas rebuilding the project works fine.

This is no problem as long as I donu00B4t define public parts for my dev. component. But when defining them they will only be generated and packed into the EAR file if I choose "development component - build" and this is not possible because the external JAR file is not found anymore at the build path.

Thx in advance

Helmut

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You can't really use the lib directory since it is intended for local projects.

I described our workaround here

You have 2 options:

1. Add that jar to a library project. Deploy separatedly.

2. Create a DC component-like structure for the new jar by unzipping the jar file and creating an 'Assembly' public part that includes the folder tree of this jar.

Option 1 works best if you have many jars that you want to deploy. But you lose integration into the DTR.

Option 2 archieves the same effect as the lib directory, as you only need to compile your jar once and it gets added into the generated wda correctly.

htammen
Active Contributor
0 Kudos

Thank you Tomas,

I already knew the solution with the library project but this is not sufficient if you want to use an external library in just one project.

The second suggested solution was new to me and it seems to be a good workaround.

regards

Helmut

Former Member
0 Kudos

Thank you tomas.

I will try both of your described solutions.

Regards,

Claus

Former Member
0 Kudos

Hi tomas,

how can i add a extern JAR to a library project ? I only can add JARs that are within the existing Workspace.

Greetings,

Claus

Former Member
0 Kudos

You can import the jar files into your file system in the Navigator perspective. IIRC, the library approach only worked if you create it as a local project, not a DTR DC project.

I personally prefer the second approach as the whole idea of JAR files goes away, I just look at a jar file as another DC project.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Helmut,

did you find out a workaround ? I have the same problem with external JARs.

Regards,

Claus