cancel
Showing results for 
Search instead for 
Did you mean: 

Using JDO in a portal component.

Former Member
0 Kudos

Hi!

I've tried using JDO in a portal component (DynPage), but it just won't work for me (WAS 6.40).

What I've tried is this:

- Looking up a PersistenceManagerFactory using the name "java:comp/env/jdo/defaultPMF"

This does not work ... I get a NameNotFoundException: Path to object does not exist at java:comp, the whole lookup name is java:comp/env/jdo/defaultPMF

- After reading this forum I tried with the name "deployedAdapters/jdo/defaultPMF/shareable/jdo/defaultPMF" although this is probably not the correct way

This did return a PersistenceManagerFactory object, however I wasn't able to cast to the PersistenceManagerFactory interface that I had. It must have been different versions of the interface - I tried downloading the jdo.jar from Sun and compiling the portal component against that, but still the ClassCastException occured. I used the reflection API to determine that the object returned did in fact implement the interface named javax.jdo.PersistenceManagerFactory. I even tried using the jdo.jar libraries from the server, but to no luck.

So ... my question is: Is JDO not available from a portal component? Must I develop a J2EE application to make it work? If so, I'd rather use Hibernate in my portal components, but it seems stupid when JDO is available?

Thanks,

Thomas

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Vladimir:

Thank you, I managed to get a PersistenceManagerFactory after adding this to my portalapp.xml:

<property name="PrivateSharingReference" value="SAPJ2EE::sap.com/com.sap.jdo"/>

Brandelik:

I don't understand your answer. After adding the entry above to my portalapp.xml, I'm still only able to get a PersistenceManagerFactory through the name "deployedAdapters/jdo/defaultPMF/shareable/jdo/defaultPMF".

Could you elaborate on how I should get it through "java:comp/env/jdo/defaultPMF", as this seems to be the right way to do it?

Thanks,

Thomas

Vlado
Advisor
Advisor
0 Kudos

Hi Thomas,

"java:comp/env/" is the standard JNDI environment context only for J2EE components. There's no such context in Portal components and the root lookup (i.e. what you did with "deployedAdapters/jdo/defaultPMF/shareable/jdo/defaultPMF") is the right and only way to do it. If you can cast the looked up object to PersistenceManagerFactory and work with it, then you're done

Hope that helps!

Vladimir

Former Member
0 Kudos

Hi Vladimir.

Okay, great! I'm no JNDI expert so I didn't quite understand the lookup string. Guess it confuses me that portal components don't have access to the "java:comp/env" context when servlets does (I haven't tried but theres an example in the docs). I thought the two were essentially the same but obviously I'm wrong.

Thanks for your help,

Thomas

Answers (2)

Answers (2)

Vlado
Advisor
Advisor
0 Kudos

Hi Thomas,

In order to be able to use JDO in a Portal component, you have to add a Private Sharing Reference to the application sap.com/com.sap.jdo. This is a standard application provided with the SAP WebAS Java installation.

For more info on how to do that, please refer to <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/ep/g-i/how%20to%20access%20an%20ejb%20from%20a%20portal%20component.mht">this</a> tutorial -> Accessing the EJB -> New Portal Component -> scroll to the section "Add PrivateSharingReference".

Hope that helps!

Vladimir

Former Member
0 Kudos

The standard reference in your jndi is not

java:comp/env/....

You need to look at your app and create an environment reference like

env ref name= mypermgrfac

jndi name = defaultPMF

and then you can look it up with

"java:comp/env/mypermgrfac" but only within the declaring appl. scope.

Enjoy