cancel
Showing results for 
Search instead for 
Did you mean: 

Defining cmp-relation to EB contained in different ejb module project

Former Member
0 Kudos

Hello,

I have to migrate an existing J2EE Application to SAP NetWeaver and WebAS. My task is to keep the structure as similar as possible to increase the recognition factor although using Developer Studio as IDE.

In this application there are cmp relations defined that reference EntityBeans from other sub projects (that I tried to create in different ejb module projects).

References in the same ejb module project seem to work fine but I cannot select referenced EntityBeans of other projects as relation target.

Another remark:

In the given application the ejb-jar.xml-file of the referencing component contains entries of the referenced one. The Developer Studio allows to Add EJBs to ejb-jar.xml, even referenced Beans. But when I select to add referenced EJBs only the Beans of the current project can be chosen. (I did not forget to enter an ejb-local-ref from the referencing to the referenced Bean in ejb-jar.xml as well)

Can anyone give me a hint on how to solve this task? Or where I have forgotten to add a reference?

Thanks

Daniel

Accepted Solutions (0)

Answers (1)

Answers (1)

viliana
Advisor
Advisor
0 Kudos

Hi,

When you create and use cmp-relationships your beans must be included in one and the same JAR file (that's according to the EJB specification). Therefore, in the Developer Studio, your beans must be included in one and the same EJB Module project.

You do not need to declare EJB references between the beans by using the ejb-ref or ejb-local-ref elements. Instead, you have to declare the relationship in the ejb-relation element and create the corresponding cmr-fileds.

For more information, see <a href="http://help.sap.com/saphelp_nw04/helpdata/en/9e/a3e23e93c33d67e10000000a114084/frameset.htm">Container-Manager Relationships</a> and the corresponding links from there.

Best regards,

Viliana

Former Member
0 Kudos

Hello,

thanks for your help but that does not solve my problem at last. The referenced component is used by multiple other EntityBeans belonging to different sub applications. That's why it is not intended to create one "giant" ejb module containing all sub applications.

In the original application (Sun's Pet Store) it is solved using the build script to copy the class files and to include all referenced EJBs in the ejb-jar.xml of the referencing component.

Is there any way to include those external ejb module projects in the referencing project to fulfill the need of having all EJBs in the same JAR file?

Best regards,

Daniel

viliana
Advisor
Advisor
0 Kudos

Hi Daniel,

I guess then that you want to declare EJB references between CMP beans, not cmp-relationships. This should be possible. Just one thing, that could probably solve your problem: you might need to set references between the different EJB module projects. To do so, right-click on the EJB module project from which you want to refer to another EJB module project and choose Properties -> Java Build Path -> Projects. Then select the projects to which you refer.

Please, let me know if this solved your problem.

Best regards,

Viliana

Former Member
0 Kudos

Hello,

Sorry, but (unfortunately) I want to declare cmp-relationships.

It is okay to deploy them in one JAR-file but it is necessary to develop them in different modules.

I want / have to reuse the referenced bean in different projects / sub applications. So "just copy" the sources would be no appropriate solution.

I think: What I need is the possibility to define some kind of "import mechanism" during development, so that the referencing ejb-module project can see the referenced bean and add this bean to its ejb-jar.xml file and the resulting JAR-File.

I'm still optimistic

Thanks again

Daniel

viliana
Advisor
Advisor
0 Kudos

Hi Daniel,

I am afraid, I'll have to disappoint you, but this is not currently possible with the Developer Studio. The different EJB module projects produce different JARs with different deployment descriptors and there is no such option as to combine several EJB module projects in one JAR afterwards. As according to the EJB specification CMP beans participating in a cmp relationship must belong to one JAR, this is the reason why this is not allowed in the Developer Studio.

Best regards,

Viliana

Former Member
0 Kudos

Hello Viliana,

there actually is a way to solve this. Although it does not seem not be intended that way.

In Eclipse projects in general and that's why it is also possible in ejb module projects it is possible to define source folder.

As an advanced option these folders can be linked to other folders in the file system. That's the way you are able to "see the source of other projects" in your project, i.e. to define cmp-relationships.

When an ejb-module-project is able to see the sources of an EJB the developer can choose to add this EJB to the ejb-jar.xml-file and afterwards define cmp-relationships because all available sources will be in the resulting JAR-file.

Thanks again

Best regards

Daniel

viliana
Advisor
Advisor
0 Kudos

Hi Daniel,

Great solution, indeed! Although, not intended to work that way, it turns out that this is possible. The so developed JAR files are deployable and everything seems to really work fine. Well done!

Best regards,

Viliana

Former Member
0 Kudos

Hello Viliana,

Hello everybody else!

I'm currently writing the corresponding masterthesis to my project. That's why I have to deal with this "problem" again.

I tried to look up the part of the spec Viliana's hint ("When you create and use cmp-relationships your beans must be included in one and the same JAR file (that's according to the EJB specification)") bases on.

But the only thing I found addressing this issue tells something else:

"[...]Container-managed relationships can exist only among entity beans within the same local relationship

scope,[...]" (EJBSpec2.1, section 10.3.2)

In my opinion this does not necessarily mean that they have to be in the same JAR but in the same EAR file...

This would mean, that the chosen cmp-relationships strategy with ejb-module-projects is too restrictive.

Can anyone help me with this... Does anyone know further hints on how Entity Beans have to be deployed when belonging to cmp-relationships?

Thanks a lot for any hint on this

Best regards,

Daniel

Former Member
0 Kudos

Hello Viliana,

Hello everybody else!

I'm currently writing the corresponding masterthesis to my project. That's why I have to deal with this "problem" again.

I tried to look up the part of the spec Viliana's hint ("When you create and use cmp-relationships your beans must be included in one and the same JAR file (that's according to the EJB specification)") bases on.

But the only thing I found addressing this issue tells something else:

"[...]Container-managed relationships can exist only among entity beans within the same local relationship

scope,[...]" (EJBSpec2.1, section 10.3.2)

In my opinion this does not necessarily mean that they have to be in the same JAR but in the same EAR file...

This would mean, that the chosen cmp-relationships strategy with ejb-module-projects is too restrictive.

Can anyone help me with this... Does anyone know further hints on how Entity Beans have to be deployed when belonging to cmp-relationships?

Thanks a lot for any hint on this

Best regards,

Daniel