cancel
Showing results for 
Search instead for 
Did you mean: 

Using Java Utility Classes as DC in NWDI

0 Kudos

Hello,

we are developing (mostly WD) with NWDI and would like to have a SC for all utiliy-classes and external libraries.

For the part concerning external libraries we are fine: We created an utilities-SC, an ExternalLibrary-DC (containing all Libraries and providing PublicParts for compilation) and a J2EE-ServerComponentLibrary-DC that uses this DC for build- and runtime, makes it deployable and provides a PublicPart "defLib" for usage by WD-DC's with LibraryReference to the lib's name (check in VA under "libraries" -> library XY).

<a href="/people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro this Blog</a>

But how can we have a DC for Java-Classes (sources that can be extended or other classes being added) that will be compiled and deployed one time to the server and that can be referenced/used by other DC's (eg. Webdynpro)?

We were able to deploy the JavaClasses on the J2EE (principle as above: JavaDC used by J2EEServerComponentLibrary-DC) and have tried several things, but either the using WD-DC redeployed the jar again or it could not find it at runtime (NoClassDefFoundException), but did not like Library- or SharingReference in WD..

Does anybody know how to do this?

Best regards,

Manuel

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Manuel,

I'd go for the same way as with the external libraries:

  • Create a "compilation" and an "assembly" public part for your Java DC

  • Use both from the J2EE Library DC.

Seen from the consumer side, both Java DCs and External Library DCs simply expose Jar files in public parts with some purpose.

If the WD-DC redeploys the Jar again you probably have a dependency on the "assembly" public part of the Java DC. You don't want that.

On the other hand you cannot have a Library or SharingReference to a Java DC since that DC type does not create a deployable archive on its own (i.e. it doesn't exist in the runtime environment)

Regards,

Marc

0 Kudos

Hello Marc,

your solution sounds compelling bt I'm not sure on how to do it exactly:

-JavaDC with assembly/compilation PublicPart (to Package or ClassFile)

-J2EE-LibraryDC uses both PublicParts for BuildTime or also RunTime?

-J2EE-LibraryDC has EntityReference to compilation PublicPart of JavaDC?

-J2EE-LibraryDC has compilation PublicPart for usage by eg. WD

-WD uses J2EE-LibraryDC PublicPart for BuildTime and has no Sharing/Library-References?

Best regards,

Manuel

Former Member
0 Kudos

Hello Manuel,

> JavaDC with assembly/compilation PublicPart (to Package or ClassFile)

Yes.

> J2EE-LibraryDC uses both PublicParts for BuildTime or also RunTime?

Build time is sufficient. The Jars from the public parts are assembled/used during buildtime. A J2EE Library and a Java DC have no common runtime environment. If you have a runtime dependency it should be ignored, there may be a warning in the build log.

> J2EE-LibraryDC has EntityReference to compilation PublicPart of JavaDC?

Should not be necessary. J2EE Library DCs have a default compilation public part with a strange "SERVER_COMPONENT" entity that cannot be editied in the NWDS. That entity automatically forwards/references used compilation public parts.

> J2EE-LibraryDC has compilation PublicPart for usage by eg. WD

Yes.

> WD uses J2EE-LibraryDC PublicPart for BuildTime and has no Sharing/Library-References?

No, you need both. You need the build time dependency for compilation and the LibraryReference for classloading at runtime. I would also set a runtime dependency in the DC metadata, but in NW04 and NW04s this dependency is basically irrelevant. (Future versions should really use the runtime dependency instead of requiring the LibraryReference. SharingReferences should be used to reference Applications, not libraries, but maybe the engine is a bit tolerant there.)

Regards,

Marc

Former Member
0 Kudos

Hi,

If we have 2 applications (ear's) and there is a dependency between them. Do we put it through used DC with a run time checkbox selected or through application references or both. Can anyone explain the difference in detail.It sounds so confusing

Shashank

Former Member
0 Kudos

WD uses J2EE-LibraryDC PublicPart for BuildTime and has no Sharing/Library-References?

No, you need both. You need the build time dependency for compilation and the LibraryReference for classloading at runtime. I would also set a runtime dependency in the DC metadata, but in NW04 and NW04s this dependency is basically irrelevant. (Future versions should really use the runtime dependency instead of requiring the LibraryReference

Marc,

Does this mean that if we have two EAR's say A (web app )and B(ejb app) and A needs B so adding a reference for B in A's application-j2ee-engine.xml will do the job and B should not be included in A's used DC's list. Since A's web module already has required A's file as an assembly in its used DC so including B in A's used DC list is not needed i guess. Your thoughts

Regards

Shashank

Former Member
0 Kudos

At least for 6.40 and 7.00: The "at-runtime" checkbox has more documentation character. It is not really relevant for runtime. The application-j2ee-engine.xml (or provider.xml for J2EE Libraries) is really evaluated at runtime.

Build plugins for newer codelines do generate the entry in the XML file if the "at-runtime" checkbox is set. (This behaviour can also be enabled for newer 7.00 SPs by setting a build-option "com.sap.archive-packaging.default.update-descriptors" to true in the development configuration).

If I understand your question correctly I'd say that B should be included in A's used DC's list as runtime-dependency, even if it only for documentation. There should be no negative effect.

Regards,

Marc

0 Kudos

Hello Marc,

thank you for the inputs. I've tried this...

-JavaDC with java-utility-classes (having PublicParts for assembly and compilation)

-J2EE-LibraryDC using both PublicParts at buildtime (having PublicPart "deflib" for compliation)

-WebDynpro using this PublicPart at buildtime and runtime and a LibraryReference to the J2EE-LibraryDC

...and found the following build-waring:

No reference entry for runtime dependency on component "bc/utils/llibs" (vendor "ch.admin")

...and error at runtime:

java.lang.NoClassDefFoundError: com/sap/tc/webdynpro/progmodel/api/IWDMessage

Do you have any idea how to remedy that?

Best regards,

Manuel

Former Member
0 Kudos

Hello Manuel,

the warning means that you hve checked the "at-runtime" checkbox, but that the (generated) application-j2ee-engine.xml does not really contain the reference. For Web Dynpro DCs you need to define the library reference in the Web Dynpro properties.

(Or if you're using a newer 7.00SP you could create a build.properties file in the cfg folder of your WD-DC and define a property "com.sap.archive-packaging.default.update-descriptors=true". Then the runtime-dependency from the DC Metadata should be added automatically to the app-j2ee-engine.xml.)

Regards,

Marc

0 Kudos

Hello Marc,

I've already added the LibraryReference to the J2EE-LibraryDC. I also tried to add a SharingReference (instead and in parallel), but this did not help.

When I deselect the "at-runtime" flag in the UsedDC, the warning disappears, but the runtime-error is still there.

Best regards,

Manuel

Former Member
0 Kudos

Hello Manuel,

I'd check the references in the generated application-j2ee-engine.xml in the EAR file.

What strikes me as odd when re-reading your mail above: "java.lang.NoClassDefFoundError: com/sap/tc/webdynpro/progmodel/api/IWDMessage"

That is not one of your classes, it almost looks as if WebDynpro itself is not referenced correctly, but as far as I know references to WD are hardcoded into the generator. Do you have other WD applications working where you could compare the two app-j2ee-engine.xml files?

Regards,

Marc

ashish_shah
Contributor
0 Kudos

Hi Manuel,

Could you resolve this error?

I am also encountering the same error.

java.lang.NoClassDefFoundError: pg/com/apt/help/cls/TargetMarket at pg.com.atos.WebModuleProject.FetchSDCDataBean

I have added the library reference in webDynpro DC as

pg.comaptscdc_aptjl ( vendor nameSC name ~DC name)

I followed Vilery's webLog Link:[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2361] [original link is broken] [original link is broken] [original link is broken];

And checked in my visual admin as well. this library is present in Visual admin also.

But still unable to resove this error.

Can you help?

Ashish Shah

Answers (0)