Philip Rowley

Greenhorn
+ Follow
since Jul 18, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Philip Rowley

I have been following Floyd Marinescu's EJB Design Patters pdf from theserverside.com

I have been trying out his Sequence design pattern, the only problem I seem to have is that the transaction times out for my Sequence Entity bean.

If I remove the container-transaction(s) below it works, but is not clustersafe.

RequiresNew - Sequence Entity
Required - Sequence Session

Excerp



Full



Is there more I need to set in ejb-jar.xml?

I am using

IDE - IBM RAD 7
AS - WebSphere 6.1
DB - Derby 10.1

Thanks

Phil
When calling a local lookup from a Session or Entity bean, and it's looking for its self it works.

But when calling a local lookup from Session or Entity bean, and it's looking for a different Entity or Session bean it fails.

However, when I create a refence from an entity bean to a sessoin bean etc.. it works (thanks Roger).

ie using <ejb-local-ref> tag.

Why does this exist? It seems like an overhead with no real use? Can anyone suggest some reading, I have not come across this in my books, or understood it when I have read it.

Any reply welcome.

Thanks Phil
Hi

I tried to implement your xml but still cannot find namespace ejb. I also noticed you referenced the StockList session bean instead of the Stock entity bean in <local-home> and <local>.

I tried with your xml which referenced the entity and session bean. This failed with java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".

-BEGIN--------

JNDI Call Used = "java:comp/env/ejb/StockCMPBean";
Error Msg = java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".

<entity id="StockCMP">
<ejb-name>StockCMP</ejb-name>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
<ejb-class>ejbs.StockCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StockCMP</abstract-schema-name>
<cmp-field id="CMPAttribute_1184702097046">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1184702097047">
<field-name>sname</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/StockCMPBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>ejbs.StockListHome</local-home>
<local>ejbs.StockList</local>
</ejb-local-ref>
</entity>
-END------------

I then tried with it modified to only reference the Stock entity bean, which also failed with the same error msg.

-BEGIN----------

JNDI Call Used = "java:comp/env/ejb/StockCMPBean";
Error Msg = java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".

<entity id="StockCMP">
<ejb-name>StockCMP</ejb-name>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
<ejb-class>ejbs.StockCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StockCMP</abstract-schema-name>
<cmp-field id="CMPAttribute_1184702097046">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1184702097047">
<field-name>sname</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
<ejb-local-ref>
<ejb-ref-name>ejb/StockCMPBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
</ejb-local-ref>
</entity>
-END--------

Looking at the error msg, it seems to me that it cannot get past the EJB namespace see msg again below

java:comp/env/ejb/StockCMPBean Err=Name comp/env/ejb not found in context "java:".


Thanks

Phil
Hi, I seem to of been on this problem for weeks.

Trying to find a Stock CMP Entity beans local interface from a session bean.

Using Rational Application Developer 7, from the Universal Test Client I can find the StockCMPLocalHome interface. However with the following jndi code variations from the session bean I cannot find it.

-BEGIN CODE----------------------------
try {
jndiname = "java:comp/env/ejb/Stock";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("ONE FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/ejb/StockCMPLocal";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("TWO FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/Stock";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("THREE FAILED "+jndiname+" Err="+ne1.getMessage());
}


try {
jndiname = "java:comp/env/ejb/StockCMP";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("FOUR FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/ejbs.StockCMPLocalHome";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("FIVE FAILED "+jndiname+" Err="+ne1.getMessage());
}

try {
jndiname = "java:comp/env/ejbs.StockCMP";
o = context.lookup(jndiname);
} catch (NamingException ne1) {
System.out.println("SIX FAILED "+jndiname+" Err="+ne1.getMessage());
}
-END CODE----------------------------

I have provided the output below, note it cannot even find the ejb namespace in some.

-BEGIN ERR----------------------------
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O ONE FAILED java:comp/env/ejb/Stock Err=Name comp/env/ejb not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O TWO FAILED java:comp/env/ejb/StockCMPLocal Err=Name comp/env/ejb not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O THREE FAILED java:comp/env/Stock Err=Name "comp/env/Stock" not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O FOUR FAILED java:comp/env/ejb/StockCMP Err=Name comp/env/ejb not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O FIVE FAILED java:comp/env/ejbs.StockCMPLocalHome Err=Name "comp/env/ejbs.StockCMPLocalHome" not found in context "java:".
[18/07/07 21:13:45:781 CEST] 00000023 SystemOut O SIX FAILED java:comp/env/ejbs.StockCMP Err=Name "comp/env/ejbs.StockCMP" not found in context "java:".
-END ERR----------------------------

I have also included the ejb-jar.xml file below.

-BEGIN ejb-jar.xml------------------
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar_ID" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>
StockEJB</display-name>
<enterprise-beans>
<entity id="StockCMP">
<ejb-name>StockCMP</ejb-name>
<local-home>ejbs.StockCMPLocalHome</local-home>
<local>ejbs.StockCMPLocal</local>
<ejb-class>ejbs.StockCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>java.lang.Integer</prim-key-class>
<reentrant>false</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StockCMP</abstract-schema-name>
<cmp-field id="CMPAttribute_1184702097046">
<field-name>id</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1184702097047">
<field-name>sname</field-name>
</cmp-field>
<primkey-field>id</primkey-field>
</entity>
<session id="StockList">
<ejb-name>StockList</ejb-name>
<home>ejbs.StockListHome</home>
<remote>ejbs.StockList</remote>
<ejb-class>ejbs.StockListBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
</ejb-jar>

-END ejb-jar.xml--------------------

Thanks Phil