This week's book giveaways are in the Jython/Python and Object-Oriented programming forums.
We're giving away four copies each of Machine Learning for Business: Using Amazon SageMaker and Jupyter and Object Design Style Guide and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!

harsha av

Greenhorn
+ Follow
since Sep 02, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by harsha av

there seems to be some formatting problem:in my earlier post

< !-- Bean managed Entity Beans <br /> <entity id="EntityBMPBean"><br /> <ejb-name>EntityBMPBean</ejb-name><br /> <local-home>com.test.EntityBMPLocalHome</local-home><br /> <local>com.test.EntityBMPLocal</local><br /> <ejb-class>com.test.EntityBMPBean</ejb-class><br /> <persistence-type>Bean</persistence-type><br /> <prim-key-class>com.test.EntityBMPPK</prim-key-class><br /> <reentrant>False</reentrant><br /> <ejb-local-ref id="EJBLocalRef_1121607049168"><br /> <ejb-ref-name>ejb/EntityBMPBean</ejb-ref-name><br /> <ejb-ref-type>Entity</ejb-ref-type><br /> <local-home>com.test.EntityBMPLocalHome</local-home><br /> <local>com.test.EntityBMPLocal</local><br /> <ejb-link>EntityBMPBean</ejb-link><br /> </ejb-local-ref><br /> <resource-ref><br /> <res-ref-name>jdbc/dataSource</res-ref-name><br /> <res-type>javax.sql.DataSource</res-type><br /> <res-auth>Container</res-auth><br /> </resource-ref><br /> </entity><br /> <br /> <br /> <ejbBindings xmi:id="EnterpriseBeanBinding_7" jndiName="ejb/EntityBMP"><br /> <enterpriseBean xmi:type="ejb:Entity" href="META-INF/ejb-jar.xml#EntityBMPBean"/><br /> <ejbRefBindings xmi:id="EjbRefBinding_1121607049168" jndiName="EntityBMP"><br /> <bindingEjbRef xmi:type="common:EJBLocalRef" href="META-INF/ejb-jar.xml#EJBLocalRef_1121607049168"/><br /> </ejbRefBindings><br /> </ejbBindings><br /> -->
14 years ago
This topic has been discussed in detail in many forums, but i am yet to find a solution, please help me here!!

I am trying to lookup a local entity bean from a session bean:
//jndiName = java:comp/env/ejb/EntityBMP ,
Object obj = initialContext.lookup( jndiName );
I have tried almost every combination of providing the jndi name, but i get the following exceptions.


I am getting the following exception when i try to use the jndi name directly :
First component in name ejb/EntityBMP not found.

When i try to use java:comp/env/ejb/EntityBMP, i am getting the following exception:
Name comp/env/ejb not found in context "java:"


I have declared a reference as shown :
< !-- Bean managed Entity Beans -->
<entity id="EntityBMPBean">
<ejb-name>EntityBMPBean</ejb-name>
<local-home>com.test.EntityBMPLocalHome</local-home>
<local>com.test.EntityBMPLocal</local>
<ejb-class>com.test.EntityBMPBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>com.test.EntityBMPPK</prim-key-class>
<reentrant>False</reentrant>
<ejb-local-ref id="EJBLocalRef_1121607049168">
<ejb-ref-name>ejb/EntityBMPBean</ejb-ref-name>
<ejb-ref-type>Entity</ejb-ref-type>
<local-home>com.test.EntityBMPLocalHome</local-home>
<local>com.test.EntityBMPLocal</local>
<ejb-link>EntityBMPBean</ejb-link>
</ejb-local-ref>
<resource-ref>
<res-ref-name>jdbc/dataSource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>


---------------------------------------

The binding is as shown:
<ejbBindings xmi:id="EnterpriseBeanBinding_7" jndiName="ejb/EntityBMP">
<enterpriseBean xmi:type="ejb:Entity" href="META-INF/ejb-jar.xml#EntityBMPBean"/>
<ejbRefBindings xmi:id="EjbRefBinding_1121607049168" jndiName="EntityBMP">
<bindingEjbRef xmi:type="common:EJBLocalRef" href="META-INF/ejb-jar.xml#EJBLocalRef_1121607049168"/>
</ejbRefBindings>
</ejbBindings>


Could some please tell what could be missing ??

Regards,
Harsha
14 years ago
Just to know how it works!

Regards,
Harsha
14 years ago
What type of a method is a constructor ?
A constrcutor can be called from a static/non-static method.
Does that mean that the constructor internally is considered as a static method ?

Regards,
Harsha
14 years ago
Hi,
I am trying to redirect an application to its login page on session timeout. The main page is divided into 3 frames, top ,left, and right.
The right frame contains the form that is filled by the user, and which is submitted to a servlet A.

At this point in servlet A, i am checking whether the session is valid, if not , i redirect to the Login page.
The problem is , the Login page is loading in the right frame and not in the complete window.

Any pointers to how it can be resolved is greatly appreciated.

Also, is it possible for automatically redirecting the application to the Login page without any programatic checks..ie is it possible to associate a session timeout with a particular page ?

Regards,
Harsha
14 years ago
right on target !!
marking the transaction for rollback did the trick !


But any particular reason why, an application exception does not qualify for a roll back implicitly? . Business exceptions are excpected by the client , but most of the cases , this sort of an exception ,might occur in the middle of a transaction , which should be rolled back. Could the container be told to roll back for all exceptions , any settings that could be done?


Thanks,
Harsha
14 years ago
Thanks a lot for suggesting to use the NotSupported attribute for the finder method. The code is working now

1) Strangely though, what i noticed was that, when the exception was thrown from the finder method and i made a call to the CMP bean, the call was failing at the CMP's findByPrimaryKey method ( dont know why !!)
but a call to the findByPrimaryKey method of the BMP of the same enity was working fine!!
Any pointers to why this could happen is greatly appreciated.

2) Also, I remember not associating any transaction with the finder methods before I tried using Required for the finder methods , but it seemed to give the same exception , ( I might have overlooked something at that point of time - not sure ).
Is it possible that an exception of this sort could happen even if no transaction is associated with the finder methods ??


Awaiting your response as to why this could happen.

Thanks,
Harsha
The DD has been created using WSAD, the transaction attribute is shown as Required for all the methods only once for all methods . Are you suggesting that I add the entry manually for each of the methods. I can post the code only by tommorrow.

Thanks,
Harsha
I will try marking the transaction for rollback as suggested by calling setRollbackOnly( ).

Thanks,
Harsha
14 years ago
The exception is a business exception, and I have to throw it as a business exception rather than throwing as EJBException. Could this be solved by marking the transaction for rollback in the catch block of the business exception in the session bean and rethrowing the same ??

Regards,
Harsha
14 years ago
Thanks for the reply ,

This is the deployment descriptor :

<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN' 'http://java.sun.com/dtd/ejb-jar_2_0.dtd'>
<ejb-jar id="ejb-jar_ID">
<enterprise-beans>
<!-- SessionBeans for GIRG10 -->
<session id="AllocationSB">
<ejb-name>StatusSB</ejb-name>
<home>com.test.StatusSBHome</home>
<remote>com.test.StatusSBRemote</remote>
<ejb-class>com.test.StatusSB</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>

<!-- Container Managed Entity Beans for GIRG10 -->
<entity id="StatusCMP">
<ejb-name>StatusCMP</ejb-name>
<home>com.test.StatusCMPHome</home>
<remote>com.test.StatusCMPRemote</remote>
<ejb-class>com.test.StatusCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.test.StatusPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>StatusCMPSchema</abstract-schema-name>
<cmp-field id="CMPAttribute_1119285231651">
<field-name>number</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1119285595505">
<field-name>typeCode</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1119330281097">
<field-name>updateTime</field-name>
</cmp-field>
<resource-ref>
<res-ref-name>jdbc/DataSource1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>

<entity id="EntityCMP">
<ejb-name>EntityCMP</ejb-name>
<home>com.test.EntityCMPHome</home>
<remote>com.test.EntityCMPRemote</remote>
<ejb-class>com.test.EntityCMPBean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>com.test.EntityCMPPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>EntityCMPSchema</abstract-schema-name>
<cmp-field id="CMPAttribute_1119286368017">
<field-name>typeCode</field-name>
</cmp-field>
<cmp-field id="CMPAttribute_1119286371234">
<field-name>entityValue</field-name>
</cmp-field>
<!-- <primkey-field>TypeCode</primkey-field> -->
<resource-ref>
<res-ref-name>jdbc/DataSource1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>


<!-- Bean managed Entity Beans -->
<entity id="StatusBMPBean">
<ejb-name>StatusBMPBean</ejb-name>
<home>com.test.StatusBMPHome</home>
<remote>com.test.StatusBMPRemote</remote>
<ejb-class>com.test.StatusBMPBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>com.test.StatusPK</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/DataSource1</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>

</enterprise-beans>
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>StatusSB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>updateStatus</method-name>
<method-params>
<method-param>com.test.UpdateData</method-param>
</method-params>
</method>
<method>
<ejb-name>StatusSB</ejb-name>
<method-intf>Remote</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>com.test.CreateData</method-param>
</method-params>
</method>
<method>
<method>
<ejb-name>StatusCMP</ejb-name>
<method-intf>Home</method-intf>
<method-name>create</method-name>
<method-params>
<method-param>int</method-param>
<method-param>java.lang.String</method-param>
<method-param>int</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.sql.Date</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>EntityCMP</ejb-name>
<method-intf>Remote</method-intf>
<method-name>setEntityValue</method-name>
<method-params>
<method-param>int</method-param>
</method-params>
</method>
<method>
<ejb-name>StatusBMPBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>updateToHold</method-name>
<method-params>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>StatusBMPBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>updateToValid</method-name>
<method-params>
<method-param>int</method-param>
<method-param>java.lang.String</method-param>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<method>
<ejb-name>EntityCMP</ejb-name>
<method-intf>Home</method-intf>
<method-name>findByPrimaryKey</method-name>
<method-params>
<method-param>java.lang.String</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>

</ejb-jar>


Here, StatusSB calls StatusBMP.findByStatus( ) method which throws a business exception. StatusSB then calls StatusCMP.create( ) in a loop to create the records.
If exception is not thrown , StatusBMP.updateTo<status>() method is called in a loop.
The problem is occuring when the StatusCMP's methods are invoked, specifically, from the stack trace, in the findByPrimaryKey (where probably the container is trying to get a connection).

Could this be because of some connection issue ??

Regards,
Harsha


Status
The problem occurs while using the Required transaction attribute.

Actually, the calls to EB1-BMP and EB2-CMP are sort of independent that is to say, if the specified business exception is thrown ( from EB1-BMP, finder method) then i call EB2-CMP in a loop ( creating records ), if the exception is not thrown, then i call a different business method in EB1-BMP ( updating records ).
When the exception is thrown from EB1 finder method , i am trying to call EB2-CMP , this is where is exception is being thrown.

Can it be because of some connection re-use.
what happens to the transaction or the connection at the point where the exception is thrown from EB1.

Regards,
Harsha
Hi ,

I am trying to create/update rows in a database using BMP and CMP beans.
A business method ( Method1 )in session bean calls a non-business method ( Method2) in the same session bean which inturn calls an EntityBean ( EB1-BMP) . EB1 can throw a certain business exception upon which , the Method1 in the session bean calls another EntityBean in a loop( EB2-CMP).
The problem is that , when the EB1 throws the business exception, i am getting an exception ( part of the stack trace attached below ).
Could any please explain what should be the transaction attributes to be specified for this scenario.
Using RequiresNew for the EntityBeans would not work ( or would it ?? ) because the entity bean is being called in a loop and the commit or rollback should happen for all the methods.
I feel the problem should be solved by specifying the transaction attribute for Method2 ( non business method in session bean ) as Required, but i guess this is not possible.
Could someone please suggest a solution or workaround for this problem.

Regards,
Harsha

---- Begin backtrace for nested exception
java.lang.IllegalStateException
at com.ibm.ws.Transaction.JTA.TransactionImpl.enlistResource(TransactionImpl.java:1694)
.
.
.
javax.ejb.EJBException: nested exception is: com.ibm.ws.ejbpersistence.utilpm.PersistenceManagerException: PMGR6022E: Error using adapter to create or execute an Interaction. com.ibm.ws.rsadapter.cci.WSInteractionImpl@28d16547
.
.
.
Hi,

I am trying to update a certain number of rows in the database, using container managed transaction.

The updates are happening correctly, except when i am throwing an exception from the bean , the updates to the database are not rolled back.

Any pointers to why its happening and how to specify a TxDataSource in WebSphere v5.1 is greatly appreciated .

Regards,
Harsha
14 years ago
Hi,

I am trying to call a bean (B2) in domain D2, from a bean B1, in Domain D1.
B2 accesses the database. When i try to use the container managed transaction , the records are inserted into the Database ( not comitted),
the transaction is timing out and the user id of D2 is getting locked.

The userId and password for D2 are correct as i am able to invoke B2 and also as said earlier the records are inserted (but not comitted).

Basically, the summay is that,
1) the transaction is rolling back,
2) The user id of domain D2 is getting locked (saying it has had 5 invalid attempts). I am not sure where this number 5 is popping up from.

Any help in this regard would be greatly appreciated.

Regards,
Harsha