cancel
Showing results for 
Search instead for 
Did you mean: 

External Library DC question

Former Member
0 Kudos

Hello,

I know there are several threads here already that partly deal with this but I'm opening a new one mainly because I want to award points to whoever can help me resolve my specific issue.

I want to use the Jakarta Struts framework to build JSP applications. So far I have done the following:

1) Create a brand new Track

2) Bring in track to my local environment and add a new DC of type External Library

3) Go to Windows Explorer and copy the Struts JAR files

4) Go to Navigator tab of the Development Configurations Perspective and paste the JAR files into the libraries folder

5) Right-click firstJAR file and choose Development Component | Add to Public Part

6) Choose the "Provide an API for developing/compiling other DCs" radio button from the popup

7) Repeat step 5 to add rest of JAR files to the Public part created in step 7

😎 Verify that the libraries were added by going to the Entities branch of DC MetaData|Public Parts in the External Library DC project

9) Create a new DC in track of type J2EE | Web Module

10) Add a new Used DCs entry in the web module project pointing to the Public Part of the External Library DC

11) Verify that the new web module project has the Struts JAR files by going to the Package Explorer. All the jar files show up!!

11) Create a simple java class that extends the Struts Action class.

When I save the new class it has compile errors. The classes that are in the Struts jar files are not being found.

What else do I need to do to get my class to find the Struts classes?

FYI - The class has import statements for all the Struts packages.

Thanks in advance for any help.

David.

Accepted Solutions (1)

Accepted Solutions (1)

sid-desh
Advisor
Advisor
0 Kudos

Hi David,

When adding the used DC's did you check the build time checkbox. Please make sure that you have checked this box.

Also open the node for Used DC's and click on the used dc and in the properties view make sure that you have true againt At Build time.

Hope this is useful.

Regards

Sidharth

Former Member
0 Kudos

Sidharth,

Thanks for your quick reply.

I did two things:

1) Verified that the "At Build Time" option for the Used DC is set to true in the properties. IT WAS!

2) Retraced my steps:

a) Deleted the Used DC entry from the web project

b) Created another Public part in the External Library project. This time I checked the "Can be packaged into other build results) radio button on the "Add Public Part" popup.

c) Added all the jars to the new Public Part

d) Added the new Public Part as a Used DC in the web project.

SAME RESULT... My program still has compile errors because it cannot "find" the Struts classes.

Do I need to do anything else to make the classes from the public part available?

David

sid-desh
Advisor
Advisor
0 Kudos

Hi David,

You said that when you saved the file it gave compile time errors.

I am just giving a stupid suggestion i know but i do this some times and hence suggesting this.

Have you tried the "Organise Imports" option available in the context menu.

I am just assuming that you typed the complete class name and didnt use the auto complete facility of NDS.

Rest all looks fine as of now.

Regards

Sidharth

Former Member
0 Kudos

Sidharth,

Please don't think any suggestion is stupid. I am open to anything at this point.

I have tried doing the "Organize imports" and that just gets rid of all my import statements but the class references in the code are still in error.

FYI - I have been able to run this same class using a non-DTR environment in Netweaver w/o any problem. It's just when I start using tracks and DCs that things start falling apart.

I'm really disappointed in how hard it is to do this and/or how hard it is to find instructions. What I'm finding is that there aren't many people doing straight Java development in Netweaver. At this point we're just concerned in moving our Java apps from WebSphere onto Netweaver. We aren't interested in doing Web DynPro or Enterprise Portal yet.

Those projects are coming down the road.

David

sid-desh
Advisor
Advisor
0 Kudos

Hi David,

One more suggestion. Check-in the activity in which you have created your External Library DC. Remove it from Used DC's of the J2EE DC.

Now again add it to the Used DC's from the inactive workspace. Keep the context as "At Build Time" and "At Design Time".

Also when adding the JARS to the public part of External Library DC please select the first radiobutton.

Hope this is of some help.

Regards

Sidharth

Former Member
0 Kudos

Sidharth,

Thanks again for your suggestion. I was finally able to get everything to compile correctly yesterday afternoon. However, I'm not quite sure which step was different this time from all the other times I tried.

Today I plan on starting from scratch again so I can record all my steps and hopefully end up with a documented procedure on how to do this correctly.

David

Former Member
0 Kudos

Make sure you post your results here - while I haven't run into this particular issue yet (we haven't installed the JDI - yet), I'm sure we will.

Answers (3)

Answers (3)

Former Member
0 Kudos

The procedure I outlined in my original post works except that I found I had to check in and activate the DC that contained the public parts before I could add them as Used DCs to another DC.

When showing it to one of my co-workers she said she doesn't have to do that and sure enough she does NOT. We're not sure why but something is strange with my machine.

Anyway, I consider this resolved.

Oh, while researching this I found a lot of posts that talked about adding the jar to the class path or adding it to the Build Path or other such things in the Properties of the project that's going to use the library.

In my experience, those suggestions don't work when using DCs.

Also, we found that using External Libraries in Web Dynpro projects requires a middle step. The External Library DC has to be referred to as a Used DC in a DC of type J2EE Library and then THAT DC has to be referred to as a Used DC in the Web Dynpro DC.

Whew. Nothing's easy!

Former Member
0 Kudos

Hi David

You seem to have done a lot of research in this field...I am having the same trouble, as I would like to use the itext -library. Would you say that the following is true?

To use ANY non-sap library from the big great java community within the NWDI/DI you need to:

- Create an external library component and do the steps mentioned above to include the jar

- Create an additional helper J2EE DC that serves no other purpose than accessing the External library component

whereas just adding the external jar to build path does NOT work when you work with NWDI/DTR etc.???

What an impressive overhead for such a basic thing like using a library!

Still hoping there might be another soultion.

Best regards

Bettina

Former Member
0 Kudos

Bettina,

You can also skip the creation of an additional J2EE Library/EAR DC and directly reference the External Library DC from your own project. You must make sure though that the jar becomes part of you own DC's deployment. The disadvantage of this way of working is that you will be copying/deploying this jar for every different DC that uses it. This will give you extra overhead when you want to update this jar: Every using DC will be rebuilt and needs to be redeployed.

If you use a J2EE Library DC, all your other DCs can reference this and you would only need to rebuild and redeploy the J2EE Library DC when you want to update the jar. This way all using DCs get to use the updated jar without the need to rebuild and redeploy them.

Kind regards,

Pascal

Former Member
0 Kudos

Hi Pascal,

thanks for your help! Having done a lot of searching in this field I am now a little bit confused about how to get this stuff to work. There are numerous propositions and workarounds with external library components and without, with extra scriptes that should fix problems in special versions etc.

(

/people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro

)

There seem to be at least one solution for EVERY SPS. Being not able to try them all, I would appreciate it a lot if somebody could give me a hint as to what helps when you are working with Netweaver 2004s/SPS 13.

I was trying the External DC-Version you mentioned, but this didn't help.

Thank you very much for your help!

Bettina

Former Member
0 Kudos

Bettina,

Your initial approach mentioned a few posts ago is correct (using a J2EE DC to wrap an Ext.Lib DC). The whole idea behind NWDI is to put something in the DTR that builds on <b>any</b> system. Therefore just adding an external library to the build path does not work: In that case that library would be local to your system and there would be no guarantee that another developer has that library on his/her system. To enforce this a DC build always reconstructs the build path based on the list of Used DCs and their exposed jars (so your manual build path modification gets lost).

If you are still experiencing problems with this scenario, let us know what issues you are facing exactly.

Kind regards,

Pascal

Former Member
0 Kudos

Hi there,

Iu2019m a new on NWDI environment and Iu2019m trying to modify the SAP-UCES DC. This is a web application consist on two J2EE DC: a war and an ear. The war is related to a java package. We need to add new jars to convert jsp to pdf file. Iu2019ve added the jars using an External DC Library but NoClassDefFoundError its shown when the functionality its executed. The steps Iu2019ve followed are:

1. Create new External Library DC

2. Copying the jars files into libraries folder

3. Create two Public Parts on External Library DC

a. Assembly Public Part (using the option u201CCan be packaged into other build results (e.g. SDA)u201D)

b. Compiling Public Part (using the option u201CProvides an API for developing/compiling other DCsu201D)

4. Add jars to the two Public Part

5. Build the External Library DC

6. Check-in the External Library DC to the Server

7. Add two Public Part as used DC on java package

8. Build the java package

After executing all listed steps, on build time, java classes recognise the jars added, but the jars are not found on runtime.

Could you help me with this error? Itu2019s necessary any other action to use this jars on runtime on the Server? How can I trace or validate that the External Library DC is correctly uploaded to the server?

Thank you in advance,

Best regards,

Former Member
0 Kudos

Hi David,

Ive seen some posts that said External Library DC is giving problems in some SPs. You can go through the following procedure as a workaround.

Regards,

Rajit

former_member190046
Discoverer
0 Kudos

Hello David,

I think you missed a step in the build config for the project. As for building the library, I was a little uncertain if you added the .jars to the library project correctly, but we'll leave that aside for now (the standard way one adds .jars to library projects is from "Jars" tab on the "server/provider.xml" that is opened from J2EE perspective. Only libraries in the workspace can be included).

Here are a few options for compile-time resolution of the libraries:

You can simply add the Struts .jar files as "External Jars" under "Java Build" settings in the project properties... that's the simplest way to include them for builds.

If you want to use a DC to be sure you've built against what will ultimately be deployed on the J2EE side, and the project is defined as a J2EE Library, you point the project to the Library DC by doing the following:

Open the Library project

In Package Explorer, bring up the context menu for your project and select "Set Additional Libraries..."

Scroll to the top of the window, and select the open Lib DC that you created. The downside of this is that you must have the lib project you've selected open for builds of other projects that reference it.

The other option is to export the Lib DC as a .jar file, and place it in the "External JAR" settings under the project properties.

Lastly, in principle, the Struts run-time could be deployed/installed with the other system/run-time libraries for the J2EE server, but DO NOT deploy ANY servlet libraries. The SAP J2EE already includes support for Servlets (2.3) and JSPs. The local struts .jars are then simply used for development. Just an FYI and a word of caution: because of what I mentioned about existing support for servlets and JSPs, there could be (could be) conflict between your Ext. Lib DC and core SAP J2EE runtime libs

Regards,

Marc Liesner

SAP Custom Development Americas

Message was edited by: Marc Liesner

Hello everyone: my suggestions/resolution for solving this problem was incorrect based on the type of project mentioned in the original post.

External Library DCs are used to make .jars available to/referencable by JDI (NWDI) based projects. This is not the same as J2EE Server component/lib, nor adding additional .jars to a local project's list of "External .jars" for local project builds.

In general, for NWDI based projects, references to other "components" (library DCs that contain .jars, or other Java DCs) must be maintained in the DC's metadata, under "Used DCs". Naturally, the DCs referenced must have declared (exposed) "Public Parts" to use.

My apologies for any inconvenience this may have caused.

Former Member
0 Kudos

Hi there,

I have got the same problem.

Do you have any ideas to solve this?

Best regards,

Thomas