Choosing session vs. entity bean
I am working on a web application that (among other things) needs to occasionally persist data in a database. I am using a DBUtil class that actually gets the DB connection and makes the update - all i do is pass it a string that represents the SQL statement. I want to create an EJB that can store a queue of statements (passed from the web classes) and periodically send them off to another EJB that will use the DBUtil class to do batch updates on the database.
I need to determine which types of EJBs to use for the 2 beans. If the first bean (the one that queues up the SQL statements and periodically sends them along) is only going to be accessed by one client, should I just use a session bean? Or do I need to use an entity bean because the bean needs to 'sleep' between its periodic call to the other bean?
The second bean simply waits to receive the set of SQL statements from the first bean and then passed them along to the DBUtil class for insertion into the DB. I was going to make this a session bean, but it seemed odd to have an entity bean calling a session bean (if the first bean should indeed be a entity bean). Are there any reasons why the second bean should be an entity bean instead of a session bean.
Thanks.
Hi,
I think the design to use EJBs for implementing a kind of service which accumulates a set of db statements and then update the db does not call for the use of EJBs. This service could be implemented using simple java classes easily and then when a predefined threshold is reached, you can call the DBUtil class to update the db. In case you want to de-couple the task of updating the db then, on reaching the threshold post a message to a queue and then write a MDB which listens for this and it calls the DBUtil to do the update.
If you want to run all your db statements in a context of a transaction, you can use a stateless session bean to call the DBUtil, but again the service has to be in a java class.
Otherwise I dont see the use of EJBs, especially two beans one calling the other as stated by you as a good design.
Regards,
Naveen
Similar Messages
-
How many ejbCreate() can be in Session and Entity Bean???
Hi,
How many ejbCreate() method can be in a Session and Entity
Bean???
How many can be in Stateless and Stateful SessionBean???
How many can be in CMP and BMP SessionBean???
Thanks,
JavaCrazyLoverHow many ejbCreate() method can be in a Session
ion and Entity
Bean???For Stateful Session Beans and Entity Beans, as many as you'd like.
Stateless Session beans can only have one, since their ejbCreate methods can not take any parameters.
>
>
How many can be in CMP and BMP SessionBean???If you mean CMT/BMT(Container-Managed transactions / Bean-Managed Transactions), then
the answer is the same. The create method requirements are independent of the transactional nature of the bean.
If you really mean CMP/BMP(Container-Managed Persistence / Bean-Managed Persistence) , it doesn't apply to session beans, only entity beans. However, even for entity beans, CMP vs. BMP has no bearing on the rules regarding # of create methods.
--ken
>
>
Thanks,
JavaCrazyLover -
Session vs Entity Bean in Business Layer???
Hi,
I am developing a Hotel Management System project, I am planning to use the following softwares for it:-
Presentation - JSP
Web controller - Action class(Struts)
Business Layer - Session Facade( Stateless Session Bean)
DAO - Hibernate
DB - Oracle 9i
Model - ValueObject
This is what i have decided to use to build the flow of the application.
I have an idea about JSP,STRUTS,HIBERNATE & ORACLE. Since i have used it before.
But in the case of business layer, i have doubt (since i am going to use EJB for the first time) whether to use a Session bean or entity bean where i will be writing my own queries(Stored proc.) as well as i will be using the predefined functions of hibernate to store the data .
I also want to know whether i need to go for StatefullSB or Stateless SB if i use a sessionfacade(which i have planned to do)??
When in what situation i need to for this approach???
Please provide an answer for this & pls. do mention my flow is right or
wrong??
Excepting ur valuable thoughts..
Thanks,
JavaCrazyLoverHi
I also want to know whether i need to go for StatefullSB or Stateless SB if i >use a sessionfacade(which i have planned to do)??
When in what situation i need to for this approach???That depends on how your application will be used.
Stateless and Statefull session bean are different.
If you want to keep informations such as shopping cart, you can use Statefull.
If you plan to have a huge number of request at time, Stateless can be faster.
You can also keep your information such as shopping cart in the session scope of your web jsp tier. (if you use only web client.)
In your case, i would choice, Stateless.
Anybody, correct me if i'm wrong.
Tks. -
[HOWTO] JSF + Session Facade + Entity Bean (EJB3)
I'm trying to find a tutorial that shows the advisable way to use JSF with EJB 3 entity beans using the Session Facade pattern (?), but the only tutorials around show very basic usage of JSF (validation, conversions etc.).
The only thing that is close is this: http://forum.java.sun.com/thread.jspa?threadID=5122284 but still not what I'm looking for.
Is there any documentation available out there..?
Message was edited by:
HakelRausdHi,
I updated the online doc in blueprints solutions catalog with a small explanation of using JSF with EJB Session Bean at https://blueprints.dev.java.net/bpcatalog/ee5/persistence/ejbfacade.html
I will add an image soon too. The basic idea for JSF and EJB3 programming model is
JSF Page --> JSF Managed Bean(backing bean) --> Session Bean --> Java Persistence Object.
In general, ther would be several JSF pages,and several JSF Managed Beans, and several Java Persistence Objects, but fewer Session Beans. The Session Bean would be expected to be shared and accessed by several managed beans with with Session Bean serving as a facade to the Java Persistence Objects, so there would be few Session Beans.
The Session Bean would usually be a local Session bean and would only be remote if-and-only-if you wanted RMI-IIOP access. Usually web components like Servlets and JSF Managed Beans use local access to the Session Beans and the access is within the same VM, no remoteness.
Most of the time, the Session Bean would be a Stateless Session Bean, and would not be a Stateful Session Bean.
hth,
Sean -
Multi session over Entity bean
Hi All,
How an Entiry bean will be persistent over multi sessions.
Any help will be appreciatedEntiies are backed by some sort of database. What exactly do you mean by "multi sessions?"
-
Creating a Session & Entity bean in Weblogic
Hii javaities
I am new 2 EJB , and i want 2 create a apllication using EJB.
I want 2 create a session , and entity bean in WEblogic.
Can anybody help me i this
Or if u have some good links , plz pass it 2 me.
Thanking in anticipationhttp://java.sun.com/blueprints/corej2eepatterns/Patterns/SessionFacade.html
http://www.oracle.com/technology/sample_code/tech/java/j2ee/designpattern/businesstier/sessionfacade/readme.html
google search for more. -
Problem with getting Entity Beans refreshed within Session bean methods
I hav following code in session and entity beans:
Session bean pseudo code: (PrimaryKey is primary key class for the entity
bean referred here, and MySessionHome is the home interfac class for this
session bean).
public class MySession implements SessionBean {
// This method is present in remote interface class as well.
public void methodA(PrimaryKey pk) {
// code to find entity bean by primary key specified.
update the entity bean, and mark it as isModified.
public void methodB(PrimaryKey pk) {
// code to find entity bean by primary key specified.
do something.
public void methodC() {
MySessionHome sessHome = code to lookup sessionhome from JNDI.
MySessionRI sess = sessHome.create(); // MySessionRI is the remote
interface class for MySession
PrimaryKey pk = new PrimaryKey(params);
sess.methodA(); // LINE ABC1
sess.methodB(); // LINE ABC2
all the entity and session bean methods have required as the TX attribute.
In methodB() on LINE ABC2, the entity bean obtained by findByPrimaryKey does
not reflect the changes made in call to methodA() on LINE ABC1.
Now if I change the LINE ABC1 and LINE ABC2 to
methodA(); // LINE ABC1
methodB(); // LINE ABC2
in this case the entity bean obtained in methodB() has the changes made in
methodA().
Any idea why this is happening?Hi ad13217 and thanks for reply.
I'm sorry but my code is like this:
javax.naming.Context ctx=new javax.naming.InitialContext();
arguments was an error on copy, but it doesn't work.
Thanks
Fil -
Implementation of Entity Beans
Hi..
Can anyone help me in my doubts?
Whenever i have an entity bean object , and say at given instant of time more tan one user wants to update the data that the entity bean represent.
Take a particular case:
One user calls an entity bean modifies itzz state say one field but doesn't commit , now at the same time some other user modifies the state say another field and commits it.
What will happen to the modification made by the first user?are they lost or they are also commited with it.Now the first user undo itzz changes and commit it . What will be the state of the entity bean?
Thankzz in advance !!
SomiljYou first need to understand why two users would update the same row at the same time, and then define what you wish the expected results to be (the behaviour of locking all other users whilst one user updates data may be what you require).
Once you understand your desired behaviour, you can then consider how isolation levels and transactions help achieve that behaviour.
Loosely speaking, you can consider a transaction as an atomic operation on data in a database (enterprise resource), and Isolation levels as how that data may be manipulated when held in a transaction.
You can set isolation levels per entity bean method (e.g. SERIALIZABLE or REPEATABLE_READ) and indicate, per session bean method how it partakes in any transaction (e.g.TX_REQUIRED or TX_NOT_SUPPORTED).
For example, suppose you need to set some data in a row, perform a lot of other calculations controlled by a session bean, using other session and entity beans, then allow that data to be changed by someone else. To do so, it is likely that you would include all entity/session beans in a container managed transaction with the isolation level for the data set to serializable. Here the data would be 'locked' until the complete operation had finished.
Suppose you only need to lock the data for a small part of the overall computation, then you could choose to use several container managed transactions, or place the update of data outside a transaction, or use explicit Bean Managed Transactions (where the code you right manages the transaction).
Adam
Hi..
Can anyone help me in my doubts?
Whenever i have an entity bean object , and say at
given instant of time more tan one user wants to
update the data that the entity bean represent.
Take a particular case:
One user calls an entity bean modifies itzz state say
one field but doesn't commit , now at the same time
some other user modifies the state say another field
and commits it.
What will happen to the modification made by the first
user?are they lost or they are also commited with
it.Now the first user undo itzz changes and commit it
. What will be the state of the entity bean?
Thankzz in advance !!
Somilj -
Flow of sessiob bean and entity bean
Hi All,
Can any one help me how is the flow of session and entity beans i.e
What method is called first and what method is called next.
There are so many methods like create(),ejbcreate(),
ejbActivate(),ejbPassivate(),ejbDelete() etc.
What is the flow of these methods and when they are called.Hi vasudulla,
If you can, go to the bookstore and look for the book:
Entreprise JavaBeans 3rd Edition by Richard Monson-Haefel.
In the Appendix B, you can see the State and Sequence Diagrams, all the things you want to know about the Flow.
--Paul. -
Calling Stateful & Statless Methods from the same Entity Bean[EJB2.0]?
Dear All,
We using EJB2.0........
Regarding segregation of stateless and stateful methods..These methods are defined in Session bean.Now my question is
Is it a good practice to call Stateful and Stateless business methods from same single entity bean("EntityBean") defined at program level by extending MainBean..
The architecture is like
public class EntityBean extends MainBean
Public Methodxyz
stfobj.MakeConn();
stlobj.getXyz();
stfobj.CloseConn();
Public Class MainBean{lookup("stl");lookup(stf) ;stl_obj=home.create;stf_obj=home.create()............}
ejb-jar.xml
{ <session>
<description>Entity Bean Employee Example</description>
<ejb-name>stl</ejb-name>
<local-home>com.packg.stlHome</local-home>
<local>com.packg.stl</local>
<ejb-class>com.packg.stlBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<description>Entity Bean Employee Example for stateful</description>
<ejb-name>stf</ejb-name>
<local-home>com.packg.stfHome</local-home>
<local>com.packg.ejbeans.stf</local>
<ejb-class>com.packg.stfBean</ejb-class>
<session-type>Stateful</session-type>
<transaction-type>Container</transaction-type>
</session>
<session>
<description>Session bean for System Parameters</description>
<ejb-name>SysParam</ejb-name>
<local-home>com.packg.Home</local-home>
<local>com.packg.Param</local>
<ejb-class>com.packg.Bean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
<ejb-local-ref>
<ejb-ref-name>stl</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.packg.stlHome</local-home>
<local>com.packg.ejbeans.stl</local>
<ejb-link>stl</ejb-link>
</ejb-local-ref>
<ejb-local-ref>
<ejb-ref-name>stf</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>com.packg.stfHome</local-home>
<local>com.packg.stf</local>
<ejb-link>stf</ejb-link>
</ejb-local-ref>
</session>
Thanks !!
Edited by: user9052593 on Jun 18, 2012 2:20 AM
Edited by: user9052593 on Jun 18, 2012 2:25 AMAll Business logic resides in session beans[Stateful or Stateless]..For stateful beans we are opening connections in entity bean ,calling business methods and closing connection in entity bean itself..Problem is
I am doing lookup for stateful and stateless both since both objects are called by extending MainBean in same entity bean else will give null pointer exception..
So whenever i call a Stateful or Stateless method from entity bean Which ultimately extends/calling MainBean and thereby calling home.create methods of stateful and stateless both..creating objects..Is this way fine or it will affect the performance?
Do i need to segregate the Calls/invokation to Stateful / Stateless methods at entity bean level too..
For ex:- Whenever i call Methodxyz() method ..at the same time it create 2 objects as its extending MainBean...i want to extend/create 1 object either of stateful or stateless one for stateful and stateless methods call respectively..
See the code in entity bean is like
public class EntityBean extends MainBean
Public Methodxyz
stfobj.MakeConn(); call to stateful method defined in stateful bean
stlobj.getXyz();// call to stateless method defined in stateless bean
stfobj.CloseConn(); call to stateful method defined in stateful bean
------------------------------------------------------------ -
DBMS connection speed: Session vs Entity
Environment: WLS6.1 SP3, W2K, Oracle 8.1.7, OCI Driver
Hi,
we are experiencing performance problem when getting a connection from a
pool.
Getting a connection from a stateless session bean takes 300-500ms whereas
it takes 15ms
from an entity bean (local). Both session and entity beans are deployed in
the same ear.
In both cases we're getting the datasource using the following code snippet
Properties p = new Properties();
bla bla bla ...
Context ic = new InitialContext(p);
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/XXX");
and
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/YYY");
When getting the connection, we are experiencing the speed difference
described above.
connection conn = ds.getConnection();
Why do we have this difference? We have the reference to the datasource
already.
There is no further JNDI lookup. Is there something we are missing?
Thanks
Arnaud
Entity descriptor
<resource-ref>
<res-ref-name>jdbc/XXX</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>
WLS specific
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/XXX</res-ref-name>
<jndi-name>jdbc/MyDataSource</jndi-name>
</resource-description>
</reference-descriptor>
Session descriptor
<resource-ref>
<res-ref-name>jdbc/YYY</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>
WLS specific
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/YYY</res-ref-name>
<jndi-name>jdbc/MyDataSource</jndi-name>
</resource-description>
<ejb-local-reference-description>
<ejb-ref-name>ejb/XXX</ejb-ref-name>
<jndi-name>ejb/XXXLocal</jndi-name>
</ejb-local-reference-description>
</reference-descriptor>Hi Arnaud,
"Arnaud Benjacar" <[email protected]> wrote in message news:[email protected]...
<JDBCConnectionPool DriverName="oracle.jdbc.driver.OracleDriver"
InitialCapacity="5" MaxCapacity="10" Name="myPool"
Properties="user=M594;password=M594;dll=ocijdbc8;protocol=oci8"
Targets="ilimdev" URL="jdbc:oracle:oci8:@ilimdev"/>
<JDBCTxDataSource JNDIName="jdbc/MyDataSource"
Name="My Tx Data Source" PoolName="myPool" Targets="ilimdev"/>This configuration is far from the best performing one. I suggest you
to change it to:
<JDBCConnectionPool DriverName="oracle.jdbc.driver.OracleDriver"
Properties="user=M594;password=M594;dll=ocijdbc8;protocol=oci8"
InitialCapacity="20" MaxCapacity="20" Name="myPool"
LoginDelaySeconds="1" RefreshMinutes="99999"
ShrinkPeriodMinutes="5" ShrinkingEnabled="false"
TestConnectionsOnReserve="true" TestConnectionsOnRelease="false"
TestTableName="DUAL"
Targets="ilimdev" URL="jdbc:oracle:oci8:@ilimdev"/>
This configuration will perform better and will not spend time recreating
connections and will require less synchronized operations inside the
pool.
BTW, in your code sample you look up two datasources. Are they bound
to different pools?
Regards,
Slava Imeshev
>
>
>
"Slava Imeshev" <[email protected]> wrote in message
news:[email protected]...
Hi Arnaud,
Could you post an extract from config.xml in part of the connection
pools and datasources? I'm asking because the configuration
you have may be not tailored to best performance.
Regards,
Slava Imeshev
"Arnaud Benjacar" <[email protected]> wrote in message
news:[email protected]...
Environment: WLS6.1 SP3, W2K, Oracle 8.1.7, OCI Driver
Hi,
we are experiencing performance problem when getting a connection from a
pool.
Getting a connection from a stateless session bean takes 300-500mswhereas
it takes 15ms
from an entity bean (local). Both session and entity beans are deployedin
the same ear.
In both cases we're getting the datasource using the following codesnippet
Properties p = new Properties();
bla bla bla ...
Context ic = new InitialContext(p);
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/XXX");
and
DataSource ds = (DataSource) ic.lookup("java:comp/env/jdbc/YYY");
When getting the connection, we are experiencing the speed difference
described above.
connection conn = ds.getConnection();
Why do we have this difference? We have the reference to the datasource
already.
There is no further JNDI lookup. Is there something we are missing?
Thanks
Arnaud
Entity descriptor
<resource-ref>
<res-ref-name>jdbc/XXX</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>
WLS specific
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/XXX</res-ref-name>
<jndi-name>jdbc/MyDataSource</jndi-name>
</resource-description>
</reference-descriptor>
Session descriptor
<resource-ref>
<res-ref-name>jdbc/YYY</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
</resource-ref>
WLS specific
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/YYY</res-ref-name>
<jndi-name>jdbc/MyDataSource</jndi-name>
</resource-description>
<ejb-local-reference-description>
<ejb-ref-name>ejb/XXX</ejb-ref-name>
<jndi-name>ejb/XXXLocal</jndi-name>
</ejb-local-reference-description>
</reference-descriptor> -
NON-transactional session bean access entity bean
We are currently profiling our product using Borland OptmizeIt tool, and we
found some interesting issues. Due to our design, we have many session beans which
are non transactional, and these session beans will access entity beans to do
the reading operations, such as getWeight, getRate, since it's read only, there
is no need to do transaction commit stuff which really takes time, this could
be seen through the profile. I know weblogic support readonly entity bean, but
it seems that it only has benefit on ejbLoad call, my test program shows that
weblogic still creates local transaction even I specified it as transaction not
supported, and Transaction.commit() will always be called in postInvoke(), from
the profile, we got that for a single method call, such as getRate(), 80% time
spent on postInvoke(), any suggestion on this? BTW, most of our entity beans are
using Exclusive lock, that's the reason that we use non-transactional session
bean to avoid dead lock problem.
ThanksSlava,
Thanks for the link, actually I read it before, and following is what I extracted
it from the doc:
<weblogic-doc>
Do not set db-is-shared to "false" if you set the entity bean's concurrency
strategy to the "Database" option. If you do, WebLogic Server will ignore the
db-is-shared setting.
</weblogic-doc>
Thanks
"Slava Imeshev" <[email protected]> wrote:
Hi Jinsong,
You may want to read this to get more detailed explanation
on db-is-shared (cache-between-transactions for 7.0):
http://e-docs.bea.com/wls/docs61/ejb/EJB_environment.html#1127563
Let me know if you have any questions.
Regards,
Slava Imeshev
"Jinsong HU" <[email protected]> wrote in message
news:[email protected]...
Thanks.
But it's still not clear to me in db-is-shared setting, if I specifiedentity
lock as database lock, I assumed db-is-shared is useless, because foreach
new
transaction, entity bean will reload data anyway. Correct me if I amwrong.
Jinsong
"Slava Imeshev" <[email protected]> wrote:
Jinsong,
See my answers inline.
"Jinsong Hu" <[email protected]> wrote in message
news:[email protected]...
Hi Slava,
Thanks for your reply, actually, I agree with you, we need to
review
our db
schema and seperate business logic to avoid db lock. I can not say,guys,
we need
to change this and that, since it's a big application and developedsince
EJB1.0
spec, I think they are afraid to do such a big change.Total rewrite is the worst thing that can happen to an app. The
better aproach would be identifying the most critical piece and
make a surgery on it.
Following are questions in my mind:
(1) I think there should be many companies using weblogic serverto
develop
large enterprise applications, I am just wondering what's the maintransaction/lock
mechanism that is used? Transional session / database lock,
db-is-shared
entity
I can't say for the whole community, as for my experience the standard
usage patthern is session fasades calling Entity EJBs while having
Required TX attribute plus plain transacted JDBC calls for bulk
reads or inserts.
is the dominant one? It seems that if you speficy database lock,
the
db-is-shared
should be true, right?Basically it's not true. One will need db-is-shared only if thereare
changes
to the database done from outside of the app server.
(2) For RO bean, if I specify read-idle-timeout to 0, it shouldonly
load
once at the first use time, right?I assume read-timeout-seconds was meant. That's right, but if
an application constantly reads new RO data, RO beans will be
constantly dropped from cache and new ones will be loaded.
You may want to looks at server console to see if there's a lot
of passivation for RO beans.
(3) For clustering part, have anyone use it in real enterpriseapplication?
My concern, since database lock is the only way to choose, how aboutthe
affect
of ejbLoad to performance, since most transactions are short live,if high
volume
transactions are in processing, I am just scared to death about
the
ejbLoad overhead.
ejbLoad is a part of bean's lifecycle, how would you be scared ofit?
If ejbLoads take too much time, it could be a good idea to profile
used SQLs. Right index optimization can make huge difference.
Also you may want cosider using CMP beans to let weblogic
take care about load optimization.
(4) If using Optimization lock, all the ejbStore need to do
version
check
or timestamp check, right? How about this overhead?As for optimistic concurrency, it performs quite well as you can
use lighter isolation levels.
HTH,
Slava Imeshev
"Jinsong Hu" <[email protected]> wrote in message
news:[email protected]...
We are using Exclusive Lock for entity bean, because of we do
not
want
to
load
data in each new transaction. If we use Database lock, that means
we
dedicate
data access calls to database, if database deadlock happens,
it's
hard
to
detect,
while using Exclusive lock, we could detect this dead lock in
container
level.
The problem is, using Exclusive concurrency mode you serialize
access to data represented by the bean. This aproach has negative
effect on ablity of application to process concurrent requests.As
a
result the app may have performance problems under load.
Actually, at the beginnning, we did use database lock and usingtransactional
The fact that you had database deadlocking issues tells that
application logic / database schema may need some review.
Normally to avoid deadlocking it's good to group database
operations mixing in updattes and inserts into one place so
that db locking sequence is not spreaded in time. Moving to
forced serialized data access just hides design/implementation
problems.
session bean, but the database dead lock and frequent ejbLoad
really
kill
us,
so we decided to move to use Exclusive lock and to avoid dead
lock,
we
change
some session bean to non-transactional.Making session beans non-transactions makes container
creating short-living transactions for each call to entity bean
methods. It's a costly process and it puts additional load to
both container and database.
We could use ReadOnly lock for some entity beans, but since weblogicserver will
always create local transaction for entity bean, and we found
transaction
commit
is expensive, I am arguing why do we need create container leveltransaction for
read only bean.First, read-only beans still need to load data. Also, you may seeRO
beans
contanly loading data if db-is-shared set to true. Other reason
can
be
that
RO semantics is not applicable the data presented by RO bean (forinstance,
you have a reporting engine that constantly produces "RO" data,
while
application-consumer of that data retrieves only new data and neverasks
for "old" data). RO beans are good when there is a relatively stable
data
accessed repeatedly for read only access.
You may want to tell us more about your app, we may be of help.
Regards,
Slava Imeshev
I will post the performance data, let's see how costful
transaction.commit
is.
"Cameron Purdy" <[email protected]> wrote:
We are currently profiling our product using Borland
OptmizeIt
tool,
and we
found some interesting issues. Due to our design, we have
many
session
beans which
are non transactional, and these session beans will access
entity
beans
to
do
the reading operations, such as getWeight, getRate, since
it's
read
only,
there
is no need to do transaction commit stuff which really takes
time,
this
could
be seen through the profile. I know weblogic support readonly
entity
bean,
but
it seems that it only has benefit on ejbLoad call, my test
program
shows
that
weblogic still creates local transaction even I specified
it
as
transaction not
supported, and Transaction.commit() will always be called
in
postInvoke(),
from
the profile, we got that for a single method call, such as
getRate(),
80%
time
spent on postInvoke(), any suggestion on this? BTW, most of
our
entity
beans are
using Exclusive lock, that's the reason that we use
non-transactional
session
bean to avoid dead lock problem.I am worried that you have made some decisions based on an improper
understand of what WebLogic is doing.
First, you say "non transactional", but from your description
you
should
have those marked as tx REQUIRED to avoid multiple transactions
(since
non-transactional just means that the database operation becomesits
own
little transaction).
Second, you say you are using exclusive lock, which you shouldonly
use
if
you are absolutely sure that you need it, (and note that it
does
not
work in
a cluster).
Peace,
Cameron Purdy
Tangosol, Inc.
http://www.tangosol.com/coherence.jsp
Tangosol Coherence: Clustered Replicated Cache for Weblogic
"Jinsong Hu" <[email protected]> wrote in message
news:[email protected]...
> -
Timeout of session / entity bean
Hi all
We are facing "RollbackException: The transaction has been marked for rollback (timed out)" excpetion. please help us in resolving this.
Here is problem description.
Code Description:
Step1: Action class calls Session bean
Step2:Session Bean does three things
A. Reads various value from database and write it to fileOutputStream
B. Generate a Sequence number using Sequence
C. Call create method of Entity Bean by local reference to insert the created file (in step 2A) in database as blob
As per our observation session bean takes around 20-30 sec in processing 2A and 2B.
But at 2-C, code raises following error
TariffDocumentBlob is the Entity Bean
TariffSessionEJB is the Session Bean
javax.ejb.CreateException: Error creating EntityBean: RollbackException: The transaction has been marked for rollback (timed out)
05/10/24 16:04:01 at TariffDocumentBlobLocalHome_EntityHomeWrapper397.create(TariffDocumentBlobLocalHome_EntityHomeWrapper397.java:1135)
05/10/24 16:04:01 at com.derc.rims.businessservice.businessinterface.TariffSessionEJBBean.createTariffBlobMasterRecord(TariffSessionEJBBean.java:102)
05/10/24 16:04:01 at com.derc.rims.businessservice.businessinterface.TariffSessionEJBBean.uploadTariff(TariffSessionEJBBean.java:76)
05/10/24 16:04:01 at TariffSessionEJBLocal_StatelessSessionBeanWrapper96.uploadTariff(TariffSessionEJBLocal_StatelessSessionBeanWrapper96.java:80)
05/10/24 16:04:01 at com.derc.rims.businessservice.businessinterface.BISessionFacadeEJBBean.delegate(BISessionFacadeEJBBean.java:534)
05/10/24 16:04:01 at BISessionFacadeEJB_StatelessSessionBeanWrapper4.delegate(BISessionFacadeEJB_StatelessSessionBeanWrapper4.java:101)
05/10/24 16:04:01 at com.derc.rims.action.tariff.CalculateTariffAction.execute(CalculateTariffAction.java:75)
05/10/24 16:04:01 at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
05/10/24 16:04:01 at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
05/10/24 16:04:01 at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)05/10/24 16:04:01 at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)05/10/24 16:04:01 at
javax.servlet.http.HttpServlet.service(HttpServlet.java:760)05/10/24 16:04:01 at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)05/10/24 16:04:01
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)05/10/24 16:04:01 at
oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)05/10/24 16:04:01 at
com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)05/10/24 16:04:01 at
com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)05/10/24 16:04:01 TRANSACTION OVER05/10/24
16:04:01 at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
05/10/24 16:04:01 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
05/10/24 16:04:01 at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
05/10/24 16:04:01 at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
05/10/24 16:04:01 at java.lang.Thread.run(Thread.java:534)
com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: timed out at
BISessionFacadeEJB_StatelessSessionBeanWrapper4.delegate(BISessionFacadeEJB_StatelessSessionBeanWrapper4.java:159)
at com.derc.rims.action.tariff.CalculateTariffAction.execute(CalculateTariffAction.java:75)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Nested exception is:java.rmi.RemoteException: No Exception - originate from:java.lang.Exception: No Exception - originate from:; nested exception is:
java.lang.Exception: No Exception - originate from: at com.evermind.server.ejb.EJBUtils.makeException(EJBUtils.java:931)
at BISessionFacadeEJB_StatelessSessionBeanWrapper4.delegate(BISessionFacadeEJB_StatelessSessionBeanWrapper4.java:159)
at com.derc.rims.action.tariff.CalculateTariffAction.execute(CalculateTariffAction.java:75)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1485)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:527)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
at oracle.security.jazn.oc4j.JAZNFilter.doFilter(Unknown Source)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:649)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:322)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.Exception: No Exception - originate from: at com.evermind.server.ejb.EJBUtils.makeException(EJBUtils.java:930)
... 17 more
We have tried out .....
- Making new Enity Bean
- changing timeout of session bean by changing it in properties
<session-deployment name="TariffSessionEJB" timeout="300" >
We are using Oracle 10g application Sever and Oracle 10.1 database.Assuming you are using either 9.0.4 or 10.1.2, please note that default transaction time out is 30s and you can change that <transaction-config> element in server.xml. This is specified in millliseconds
-Debu -
Problems accessing fields in a CMP entity bean from a session bean
Hello everybody,
I'm getting the next problem: when I try to access a field in a CMP entity bean that I have instantiated from a session bean (trhoug entitybean.getNameOfField), I get the error "the entity bean does not exist in the database".
This entity bean is accessing a table in an external database (not the DB of the WAS), but I know that it's getting the correct data from the table, sinceĀ I check the entitybean.size() and the entitybean.findByPrimaryKey(), and I get the right information. For some reason, the only thing that it doesn't work in the entity bean are the getter/setter methods (I created them automatically after having created the entity fields).
I access the entity bean through its local interface...
I know it's really difficult to give an answer with so few details, but... does anybody think I forgot something important to configure??
Thank very much in advance!!
Isidrogetter and setter methods for cmp-fields are abstract.
getter and setter methods for cmr-fields are abstract.
"John Lee" <[email protected]> wrote:
>
Hi:
Which method in a CMP Entity bean should be abstract? just only SetXXX
and
GetXXX?
Thanks!
John Lee -
How does a session bean find entity beans in EJB 3.0
Hi,
I am new to J2EE. I have difficulties finding out how a session bean locates the entity-manager for a group of entity beans. I understand that the entitymanager in the session bean is injected using the PersistenceContext annotation, but I dont see how it locates the intended EntityManager (which could be on another server).
I realize this is probably trivial, but can any of you guys tell me what I am missing?
Best Regards
ThomasHi Thomas,
Good question. Each @PersistenceContext annotation is associated with a single Persistence Unit. A Persistence Unit is defined either at the module level or at the .ear level. Each persistence unit has a name associated with it. The unitName() attribute is used to map @PersistenceContext to the associated PersistenceUnit. Since the most common case is that an application will only define one persistence unit, the spec requires that if the unitName() is not specified, it will automatically map to that single persistence unit.
--ken
Maybe you are looking for
-
Adding columns to a single documents in facing pages
I am using facing pages, and I dont need columns to all pages, but I would like to know how I can add the columns to the pages that I do need them ?
-
Factory Radio Car Adapter for iphone
I just purchased an ipod interface for factory GM Radio by Peripheral Electronics. It connects to the 30 pin connector on an ipod and plugs into an empty plug in the back of my factory radio. I connected my iphone to it.I get the message "incompatibl
-
help
-
How to select installation language when using silent install
Hi, How can i select installation language when using silent install. Power management Presentation_Director System_Update EasyEject_Utility When i install those programs with silent install string it will install language i have select at windows re
-
Excel crashes due to Essbase add-in
Hi, I have Essbase 11.1.1.3 and am using the excel addin 11.1.1.3 on Office 2003 in Win XP. One issue everyone is facing is that, once we install the excel add-in on their machine, they are unable to run any other tool that launches excel. For exampl