cancel
Showing results for 
Search instead for 
Did you mean: 

How to reference an External Library (Server Side) in a DC-EJB Module ?

Former Member
0 Kudos

Hi:

I start working with hibernate in a DC component, so I create my DC project and EJB module inside. I Make an external library following this

Thanks a lot for your time on this thread.

Rocío.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Rocio,

to be able to declare and use your EJB objects in a separate project you have to add relevant JAR archive to your project, otherwise the NWDS will not be able to locate the classes you need to use during design time. But you will not use the constructors from that JAR file in runtime.

In runtime you will have to call those objects via:


			Context _context = new InitialContext(); // javax.naming.InitialContext
			Object _initialReference = _context.lookup("vendor/projectname/beanname");  
			BeanHome _home = (BeanHome)javax.rmi.PortableRemoteObject.narrow(_initialReference, BeanHome.class );

Hope it helps.

regards.

mz

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Rocío!

Umm, I don't usually use DC's... I don't know if this will work... you can make an EAR (New Proyect -> J2EE -> Enterpise Application Module), add your EJB Module to the EAR (right click on EJB Project and choose Add to EAR proyect), and you'll find a j2ee-engine file on it, and you can add the reference there.Then deploy the EAR.

I normally do something similar to your issue, I make a EJB calling XI via Java Proxys, and the reference to the XI libs are allocated on the EAR, not on the EJB. This is only for runtime, for compilation you must reference the hibernate jar with an external jar file, as always.

A dirty solution could be this one: open your generated EAR with de-compressor, and copy your hibernate jar on it (at root). This way you'll load hibernate classes at runtime (I know this is an horrible solution, this is only for testing).

As I said before, I'm not used to DCs, so this could be wrong, and be a waste of time... I don't know further...

Good luck

Eneko.

Former Member
0 Kudos

Hi Rocío!

I don't know if I understood what do you want to say, but this maybe helps you:

In Developer Studio (Eclipse), J2EE Perspective, select your EJB Project, and double click Application-J2EE-Engine.xml. There, in General section, click on 'References' (look for a folder icon), and click Add. Then you can select an application, or a DC. Normally the best general-purpose reference-type is 'weak'.

You can also do it directly in the Source section:

Hope this helps you.

Eneko.

Former Member
0 Kudos

Hi Eneko:

Something like that is what I want to do but my project don't have the Application-J2EE-Engine.xml....I'm working with NWDS 7.0.12 and I do:

1- New project -> Development Component Project

2- Selected "My Components" at local development

3- J2ee ->EJBModule and finish

Now, I have Hibernate External Library (the steps are <a href="https://answers.sap.com/people/valery.silaev/blog/2005/09/14/a-bit-of-impractical-scripting-for-web-dynpro, please see it) and I have to make the reference to it in my project, and i can't find the way to do it.

Thanks a lot for your time.

Rocío.