Can Entity Bean be set with "RequiresNew" transaction Attribute?
I find it result in "dead lock"
when I call RequiresNew attributed CMP method in session Bean.
Then, Is it possible to use CMP which is set with "RequiresNew" transaction attribute?
I Wonder why.
Thanx in advance.
Requires-new makes the container start a new transaction. Only use that flag
at the point that you are certain that a NEW transaction should BEGIN. I
suggest you use Required as your default for all methods in the application,
and only change that to anything else when you are certain that you should.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"A.J,LEE" <[email protected]> wrote in message
news:3ba5adb2$[email protected]..
>
> I find it result in "dead lock"
> when I call RequiresNew attributed CMP method in session Bean.
> Then, Is it possible to use CMP which is set with "RequiresNew"
transaction attribute?
>
> I Wonder why.
>
> Thanx in advance.
Similar Messages
-
Can Entity Bean with Home Business Method replace Stateless Session Bean?
Since Entity Bean can have business methods in the Home Interface, can we use Entity Bean with Home Business Methods to replace Stateless Session Bean?
I am assuming we can get better performance by doing this since the overhead of creating Component Object can be avoided as compared to stateless session beans.Requires-new makes the container start a new transaction. Only use that flag
at the point that you are certain that a NEW transaction should BEGIN. I
suggest you use Required as your default for all methods in the application,
and only change that to anything else when you are certain that you should.
Peace,
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>
"A.J,LEE" <[email protected]> wrote in message
news:3ba5adb2$[email protected]..
>
> I find it result in "dead lock"
> when I call RequiresNew attributed CMP method in session Bean.
> Then, Is it possible to use CMP which is set with "RequiresNew"
transaction attribute?
>
> I Wonder why.
>
> Thanx in advance.
-
SystemException during Required -- RequiresNew Transaction Attribute
I have a batch process, which runs in RequiresNew Transaction Attribute (Child Transaction). My Parent transaction attribute is Required.
Say I am processing 10 Records, My requirement is in a normal flow, i need to commit each and every record after processing and incase Application Exception arises, i will log it and proceed with next record. So by that way i don't have any problem with Application Exception.
But when a systemException is thrown after processing 5 records, i will be able to rollback only the 6th record transaction, and the above commited 5 transactions cannot be rolledback. Can somebody suggest me a good solution to rollback all the transactions incase of SystemExceptions in RequiresNew
Thanks & Regards,
PrasannaHi
ThanX for your reply. I raised the issue to the BEA support, they said that the issue is the driver that i am using. It got resolved when i tried with the BEA provided driver. They call it the BEA branded driver for SQL Server.
Regards
Muthu -
CMP Entity Bean's problem with MS-SQL Server 2000
Hi everyone!
I have a problem regarding CMP Entity Bean on OC4J.
I made one CMP Entity Bean and deployed it to OC4J.
It was successful.
I used MS-SQL Server 2000 as Datasource.
So, I installed MS-SQL Server's JDBC Driver and add some jar files to classpath.
And I updated 'data-sources.xml' in OC4J's config directory.
Then, I updated also 'orion-ejb-jar.xml' in my application's directory.
I changed data-source's name to my data-source's name which use MS-SQL Server 2000.
Finally, I started OC4J and EJB Client program which called Enitiy Bean's create method.
But, The error occured which was 'Database error: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]LINE 1: '.' Wrong sentence'.
What's wrong? I need any helps.
Here is stack overflow message. Thank you. Best regards.
com.evermind.server.rmi.OrionRemoteException: Transaction was rolled back: Database error: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]LINE 1: '.' Wrong sentence.
at UserHome_EntityHomeWrapper2.create(UserHome_EntityHomeWrapper2.java:1114)
at java.lang.reflect.Method.invoke(Native Method)
at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:80)
at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
at connection to localhost/127.0.0.1 as admin
at com.evermind.server.rmi.RMIConnection.EXCEPTION_ORIGINATES_FROM_THE_REMOTE_SERVER(RMIConnection.java:1530)
at com.evermind.server.rmi.RMIConnection.invokeMethod(RMIConnection.java:1453)
at com.evermind.server.rmi.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:53)
at com.evermind.server.rmi.RecoverableRemoteInvocationHandler.invoke(RecoverableRemoteInvocationHandler.java:22)
at __Proxy0.create(Unknown Source)
at com.emc.ksc.ejb.user.UserBeanTestClient1.create(UserBeanTestClient1.java:73)
at com.emc.ksc.ejb.user.UserBeanTestClient1.<init>(UserBeanTestClient1.java:49)
at com.emc.ksc.ejb.user.UserBeanTestClient1.main(UserBeanTestClient1.java:1077)Hi Young,
From the information you have supplied, my guess is that the SQL
string that OC4J is sending to SQL-Server is incorrect. So it may
help if you could see the exact SQL string. In order to see the
SQL string, I suggest you either run OC4J in "debug" mode, or try
using "P6 Spy".
The following web page has details on running OC4J in "debug" mode:
http://kb.atlassian.com/content/atlassian/howto/orionproperties.jsp
And here is the web page for "P6 Spy"
http://www.provision6.com/
And these other web sites may also be of help (in general):
http://www.orionserver.com
http://www.orionsupport.com
http://www.atlassian.com
http://www.elephantwalker.com
Good Luck,
Avi. -
Question about multiple RequiresNew in Entity Bean transaction
Hi I've got a problem concerning transactions:
In both cases I've got a CMP Entity Bean called "Account" with some mothods like
increaseBalance(double amount)
decreaseBalance(double amount)
transferMoney(double amount)
for all methods the TransactionAttribute is "RequiresNew". When calling first decreaseBalance(amount) and afterwords
increaseBalance(amount), bothfrom within transferMoney(amount). When setting entityContext.RollbackOnly()
I would expect this rollback doesn't undo my changes because they are in a different transaction, which has been comitted
when the methods finished, but both are rolled back.
I thought there are no "nested transactions" in J2EE. Isn't this one?
Thanks!
MartinAhhhh! Right! If I call "this.increase(balance)" from the AccountBean method "transferMoney", the container has no chance to create a new transaction, so the same transaction as in "transferMoney" is used. I didn't think about that, but of course...
So one should never call a bean method directly even when it is a method of the same instance the thread is currently in.
Thanks a lot! -
We have a rather large system where we get a lot of transactions. To
tune our system we decided to turn off transaction support for some
beans. (by setting the transaction attribute to NotSupported).
The system did not decrease the amount of transactions run so we
started wondering what was going on.
To test this we first implemented a small test application and then
also tested some examples provided by weblogic. In both cases we came
to the conclusion that when using entity beans transactions are always
run. We tested with wl6.1 and wl6.1sp3
A short example of some code:
Client:
for (int i=0; i<numBeans; i++) {
accounts = findOrCreateAccount("ID: "+i, i * 1000);
//transfer 1000 from account 10 to account 11
try {
accounts[10].withdraw(1000);
accounts[11].deposit(1000);
} catch (ProcessingErrorException e) {
log(" could not xfer cash");
} catch (RemoteException e) {
log(" could not xfer cash");
AccountBean (Entity Bean)
public double deposit(double amount) {
log("Depositing $" + amount + " into '" + accountId + "'");
if (weblogic.transaction.TxHelper.getTransaction() == null) {
log("dep no transaction");
else {
log("dep tx:
"+weblogic.transaction.TxHelper.getTransaction().getXID());
balance += amount;
if(true) {
log("throwing EJB EXCEPTION FOR TESTING");
throw new EJBException();
return balance;
ejb-jar.xml
<container-transaction>
<method>
<ejb-name>beanManaged</ejb-name>
<method-intf>Remote</method-intf>
<method-name>deposit</method-name>
</method>
<method>
<ejb-name>beanManaged</ejb-name>
<method-intf>Remote</method-intf>
<method-name>withdraw</method-name>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
The first indication that a transaction was running was to check the
log:
deposit transaction: 370:971b99c458e3d95b
Then the transaction was rolled back and and we could see that the
account balance was unchanged which proves that a transaction was
running.
We can't be the first ones to discover this, but I can't find this
documented anywhere else.If an entity bean is called and no transaction is in effect, the container
will
always start a transaction for its own use. Its not expensive to start a
transaction in WLS. The best architecture is almost always to
begin/commit
transactions before calling entity beans and let the entity beans inherit
the transaction, so that multiple calls to an entity bean are grouped into
a single transaction.
Seth
Daniel Bernholc wrote:
We have a rather large system where we get a lot of transactions. To
tune our system we decided to turn off transaction support for some
beans. (by setting the transaction attribute to NotSupported).
The system did not decrease the amount of transactions run so we
started wondering what was going on.
To test this we first implemented a small test application and then
also tested some examples provided by weblogic. In both cases we came
to the conclusion that when using entity beans transactions are always
run. We tested with wl6.1 and wl6.1sp3
A short example of some code:
Client:
for (int i=0; i<numBeans; i++) {
accounts = findOrCreateAccount("ID: "+i, i * 1000);
//transfer 1000 from account 10 to account 11
try {
accounts[10].withdraw(1000);
accounts[11].deposit(1000);
} catch (ProcessingErrorException e) {
log(" could not xfer cash");
} catch (RemoteException e) {
log(" could not xfer cash");
AccountBean (Entity Bean)
public double deposit(double amount) {
log("Depositing $" + amount + " into '" + accountId + "'");
if (weblogic.transaction.TxHelper.getTransaction() == null) {
log("dep no transaction");
else {
log("dep tx:
"+weblogic.transaction.TxHelper.getTransaction().getXID());
balance += amount;
if(true) {
log("throwing EJB EXCEPTION FOR TESTING");
throw new EJBException();
return balance;
ejb-jar.xml
<container-transaction>
<method>
<ejb-name>beanManaged</ejb-name>
<method-intf>Remote</method-intf>
<method-name>deposit</method-name>
</method>
<method>
<ejb-name>beanManaged</ejb-name>
<method-intf>Remote</method-intf>
<method-name>withdraw</method-name>
</method>
<trans-attribute>NotSupported</trans-attribute>
</container-transaction>
The first indication that a transaction was running was to check the
log:
deposit transaction: 370:971b99c458e3d95b
Then the transaction was rolled back and and we could see that the
account balance was unchanged which proves that a transaction was
running.
We can't be the first ones to discover this, but I can't find this
documented anywhere else. -
Hi, I use the version 9.0.4.0.0
If I give an entity bean transaction type supports... what will be the actual transaction type when the bean is deployed....
So far I know the container does not suppert the tranaction type supports...
From
Oracle® Application Server Containers for J2EE
Enterprise JavaBeans Developer’s Guide
10g (9.0.4)
All entity beans with CMP and CMR relationships must be involved in a
transaction. As such, you cannot define any entity bean with a transaction attribute
of NEVER, SUPPORTS, or NOT_REQUIRED as this would put the entity outside of
a transaction.
But I can still deploy an entity bean with transaction type set to supports....
KrisIn the deployment descriptor file set the trasaction isolation level as TransactionReadUncommitted. It should solve your issue.
-
Use same transaction in entity-bean and Datasource
Hello
I've got following problem. In my stateless container managed transaction Sessionbean i do some inserts and update on my container managed entity bean. In the same transaction I have to read some informations on the database. Some of those informations are already set by the entity bean, but not yet commited. Now I want to read them through a javax.sql.DataSource. But this Datasource doesn't use the same transaction as the session bean.
Question: Is it possible to let a Datasoucre use the same Transaction as Sessionbean?
(i work with WSAD 4.0.3)
ThanksHi,
You would have to check that you are using an XADataSource instance, instead of a 'regular' DataSource instance (which will not adopt the transaction started by the application server). In particular, the JNDI lookup name of the DataSource should actually point to an instance of XADataSource; a special type for container transactions.
The administration/deployment tools of the WS will allow you to do that, under Resource Factories or DataSources somewhere.
Both types look the same towards your application code, so your session bean is probably fine the way it is and does not need rewriting. It is merely in the setup of the WS server that the difference lies.
Best,
Guy
http://www.atomikos.com -
Entity bean connection with SQL Server Error! urgent
Hi,
I am working with J2EE tutorial and when i tried SavingsAccount Entity bean to connect with SQL Server 2000(other than default Cloudscape)and I'm also having SQL Server 2K JDBC Driver installed. I also made entries in Server Configuration menu of J2EE deployment tool for this MS JDBC Driver for SQL Server 2K,I will enclose my dbName and connection method in the entity bean , but i am getting error like this.
my data base name in SQL Server 2K is 'rajeshrNew'.
private String dbName="java:comp/env/jdbc/rajeshrNew"; //dbName
private void makeConnection() throws NamingException, SQLException {
InitialContext ic = new InitialContext();
DataSource ds = (DataSource) ic.lookup(dbName);
con = ds.getConnection();
and errors receiving are:
java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to connect to database. No suitable driver; nested exception is:
javax.ejb.EJBException: Unable to connect to database. No suitable driver
java.rmi.RemoteException: nested exception is: javax.ejb.EJBException: Unable to connect to database. No suitable driver; nested exception is:
javax.ejb.EJBException: Unable to connect to database. No suitable driver
javax.ejb.EJBException: Unable to connect to database. No suitable driver <<no stack trace available>>
Please help me to resolve this problem!!
Regards
Rajesh Ryes i do create System DSN with rajeshrNew and my default.properties file look like this..
# maximum size of message driven bean instance
# pool per mdb type
messagebean.pool.size=3
# maximum size of a "bulk" message bean delivery
messagebean.max.serversessionmsgs=1
# message-bean container resource cleanup interval
messagebean.cleanup.interval=600
passivation.threshold.memory=128000000
idle.resource.threshold=600
log.directory=logs
log.output.file=output.log
log.error.file=error.log
log.event.file=event.log
distributed.transaction.recovery=false
transaction.timeout=0
transaction.nonXA.optimization=true
sessionbean.timeout=0
# validating parser values
# validating.perser is used when archive file are loaded by
# any of the J2EE Reference Implementation tools.
# deployment.validating.parser is used when deploying an
# archive on the J2EE AppServer.
validating.parser=false
deployment.validating.parser=true
now u tell me what i have to change..
with regards
Rajesh -
Question on Persistence (Entity Beans, Hibernate, JDBC)
Hi everybody!
Until now, I have read a lot about persistence in the J2EE-sector, but I am still confused about which technology to used in my case.
I hope, that maybe you can give me some hints, by telling me which technology is good or bad regarding my requirements:
I want to build a customer- and order-management system fullfilling the following requirements:
1. The client is a Java application, the server is a JBOSS 4.0.1
2. The databasa scheme exists already and I'm not allowed to change it.
Some data, that logically belongs together and which shall be presented together to the client is distributed over 2 database tables.
3. The user cannot just create new and view data, but will also edit existing data quite often.
4. The user can assign products to an order. Often, there will be more than 1000 products assigned to an order, which will be presented to the user as a table (e.g. JTable). The user can then edit each cell of that 1000-row table, which of course will lead to an update in the db.
5. The user can also assign customers to a specific role in an order-process. On the other hand, each customer can make many orders.
So, we have a n:m relation here with the db-tables Customer, Order, OrderCustomer.
6. A complex search functionality has to be implemented, where the db-query is created dynamically at runtime.
7. The application is a multi-user application (about 10 users). It will be very rare, that users will work on the same data at the same time, but it might happen.
8. The database type (SAP DB) will not be changed in the near future.
With these 8 requirements in mind, I dealed a lot with EntityBeans, Hibernate and JDBC with SesseionBeans during the last 2 weeks.
Until now, I came to the following conclusions.
Hibernate is too slow. That'S bad, for data is edited very often and sometimes I want to edit just a single cell in 1000-row table.
Hibernate's biggest advantage - that it makes your application independent of the database type - is not even required (see point 8).
JDBC with SessioBeans: Very fast (I tried a simple query and it was about 10 times faster than Hibernate).
The disadvantage is, that I have to take care about all the transaction, concurrency control etc. things.
If I use JDBC, I want to do it that way: A SessionFacade accesses a DAO-object which executes the DB-query and returns the result to the SessionFacade which in the last step will pass the result to the client.
Entity Beans: I am completely confused with Entity Beans.
I read a lot about the CompositeEntity-Pattern for BMP. But on sun's J2EE Pattern page (http://java.sun.com/blueprints/corej2eepatterns/Patterns/CompositeEntity.html)
they said, that it's just useful when using the EJB 1.1 specification, because from EJB 2.0. the container or whatever will take care about lazy loading and store optimization.
So, from EJB 2.0. you should prefer using CMP-Beans with Container Managed Relationships (CMR), but as I heard, the dependent objects cannot be accessed and changed by the client when using CMPBeans with CMR.
However, a simple DB/Entity-mapping will not work in my case, because as mentioned above, there are thousands of products from the db to be managed at the same time. So here, I thought, the Composite pattern with its lazy loading strategy would be useful.
Furthermore, I have an n:m relationship in my database scheme, which is not trivial to map to entity beans. And don't forget that some related data is spread over 2 databse tables.
To sum it up, it would be very nice if some of you could clarify this perisistence nightmare, especially some clarification about if and how to use EntityBeans when having n:m relationships, editing data a lot, managing lots of table rows at once and having related data distributed over 2 database tables.
So, which technology would you prefer with the 8 requirements in mind? Hibernate, Entity Beans or JDBC with SessionBeans? Or would you prefer a mixed solution?
Thanx for every hint.
Regards,
egonHere the requested information about the test:
Goal:
Find all customers, who's branches have the String "Branch" in their name.
Both times, a simple client accesses the same SessionBean in a JBOSS-Container.
This Bean has 2 methods. One accesses the DB via Hibernate (executeCriteria), the other one via JDBC (executeCriteriaJDBC).
The code to count the seconds of computation is as follows:
long startTime = System.currentTimeMillis();
List customerList = bean.executeCriteria(dc);
System.out.println("Hibernate: "+((System.currentTimeMillis()-startTime)/1000.0f)+" sek");
startTime = System.currentTimeMillis();
List customerListJDBC = bean.executeCriteriaJDBC(query);
System.out.println("JDBC: "+((System.currentTimeMillis()-startTime)/1000.0f)+" sek");
HIBERNATE:
CODE:
Branch Branch = new Branch();
Branch.setName("%Branch%");
Example example = Example.create(Branch);
DetachedCriteria dc = DetachedCriteria.forClass(Customer.class)
.createCriteria("branches").add(example.enableLike()).setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
QUERY:
select
this_.UUID as UUID1_1_,
this_.NAME as NAME1_1_,
this_.CUSTOMERNO as CUSTOMERNO1_1_,
this_.SHORTDESC as SHORTDESC1_1_,
this_.LONGDESC as LONGDESC1_1_,
this_.TAXNUMBER as TAXNUMBER1_1_,
this_.SALESTAXID as SALESTAXID1_1_,
this_.ACCOUNTHOLDER as ACCOUNTH8_1_1_,
this_.BANKACCOUNT as BANKACCO9_1_1_,
this_.BANKCODE as BANKCODE1_1_,
this_.BANKNAME as BANKNAME1_1_,
this_.AREA1TEXT as AREA12_1_1_,
this_.AREA2TEXT as AREA13_1_1_,
this_.AREA3TEXT as AREA14_1_1_,
this_.AREA4TEXT as AREA15_1_1_,
this_.AREA5TEXT as AREA16_1_1_,
this_.CH_UUID as CH17_1_1_,
this_.REFTEXT1 as REFTEXT18_1_1_,
this_.REFTEXT2 as REFTEXT19_1_1_,
this_.REFTEXT3 as REFTEXT20_1_1_,
branch1_.UUID as UUID0_0_,
branch1_.NAME as NAME0_0_,
branch1_.ILN as ILN0_0_,
branch1_.BRANCHID as BRANCHID0_0_,
branch1_.SHORTDESC as SHORTDESC0_0_,
branch1_.LONGDESC as LONGDESC0_0_,
branch1_.BAGSRECEIVED as BAGSRECE7_0_0_,
branch1_.CUSTOMER_UUID as CUSTOMER8_0_0_
from
CUSTOMER this_,
BRANCH branch1_
where
this_.UUID=branch1_.CUSTOMER_UUID
and (
branch1_.NAME like ?
RESULT:
Customername: Customer_A
Customername: Customer_F
Customername: Customer_D
Customername: Customer_R
Customername: Customer_S
TIME:
Hibernate: 1.343 sek
JDBC:
QUERY:
Select distinct c.* from Customer c, Branch b where b.id=b.Customer_id and b.name like '%Branch%'
// After getting the result of the query: Create a list of Customer-objects. Set all attributes of each Customer-object.
RESULT:
Customername: Customer_R
Customername: Customer_A
Customername: Customer_S
Customername: Customer_D
Customername: Customer_F
TIME:
JDBC: 0.125 sek
The Customer.hbm.xml (auto-generated in Eclipse with Middlegen)
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.2
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="hibernate.hibernate.Customer"
table="CUSTOMER"
lazy="false"
>
<id
name="uuid"
type="java.lang.String"
column="UUID"
>
<generator class="assigned" />
</id>
<property
name="name"
type="java.lang.String"
column="NAME"
length="100"
/>
<property
name="customerno"
type="java.lang.Integer"
column="CUSTOMERNO"
length="5"
/>
<property
name="shortdesc"
type="java.lang.String"
column="SHORTDESC"
length="50"
/>
<property
name="longdesc"
type="java.lang.String"
column="LONGDESC"
length="100"
/>
<property
name="taxnumber"
type="java.lang.String"
column="TAXNUMBER"
length="50"
/>
<property
name="salestaxid"
type="java.lang.String"
column="SALESTAXID"
length="50"
/>
<property
name="accountholder"
type="java.lang.String"
column="ACCOUNTHOLDER"
length="50"
/>
<property
name="bankaccount"
type="java.lang.String"
column="BANKACCOUNT"
length="50"
/>
<property
name="bankcode"
type="java.lang.String"
column="BANKCODE"
length="50"
/>
<property
name="bankname"
type="java.lang.String"
column="BANKNAME"
length="50"
/>
<property
name="area1text"
type="java.lang.String"
column="AREA1TEXT"
length="50"
/>
<property
name="area2text"
type="java.lang.String"
column="AREA2TEXT"
length="50"
/>
<property
name="area3text"
type="java.lang.String"
column="AREA3TEXT"
length="50"
/>
<property
name="area4text"
type="java.lang.String"
column="AREA4TEXT"
length="50"
/>
<property
name="area5text"
type="java.lang.String"
column="AREA5TEXT"
length="50"
/>
<property
name="chUuid"
type="java.lang.String"
column="CH_UUID"
length="50"
/>
<property
name="reftext1"
type="java.lang.String"
column="REFTEXT1"
length="50"
/>
<property
name="reftext2"
type="java.lang.String"
column="REFTEXT2"
length="50"
/>
<property
name="reftext3"
type="java.lang.String"
column="REFTEXT3"
length="50"
/>
<!-- Associations -->
<!-- bi-directional one-to-many association to Branch -->
<set
name="branches"
lazy="true"
inverse="true"
cascade="all"
>
<key>
<column name="CUSTOMER_UUID" />
</key>
<one-to-many
class="hibernate.hibernate.Branch"
/>
</set>
</class>
</hibernate-mapping>So, seems to me like Hibernate is also getting the data from the Branch-Table related to each Customer. Maybe this is the reason, why Hibernate is slower.
But as you can see in the mapping-File of the customer, I wanted Branches to be lazy loaded.
Do you have any ideas, why Hibernate is so much slower? Any hints for optimizing that code?
Do you have any further tricks to optimize Hibernate? Unfortunately I am not allowed to make changes at the database, so I cannot e.g. set indices for optimization.
However, I�m a Hibernate-Newbie. In fact, I just made this test and was very disappointed about its result, so I didn�t keep on working with Hibernate.
But maybe you can proof me, that Hibernate is a good choice. If so, do you have any good resources (links, books) that help working with Hibernate in connection with JBOSS, describe how to map n:m relationships, show how to work with large results and so forth?
Thanx for help,
egon -
Multiple create methods of entity beans in single transcation
Hi,
I have some entity beans with CMR. I am managing these entity beans with a Stateful session bean whose transaction type is Container Managed for all its methods.
In one particular method of this Session bean I am calling two entity bean's create method. i.e I am creating two entity beans through home.create() methods. There are two home.create() methods one after another inside a try catch block.
I want that the entire operation be under just one transcation so i have also given the transaction attribute as Required for all methods of Session bean and Entity Beans.
However if i pass invalid parameters to second create method so that it generates exception then still the first create statement is successful and database is updated.
what i want is that the first create also should be roll backed.
How can i acheive this through Container Managed Transaction Session Bean?Hi Ashwini,
"Ashwini" <[email protected]> wrote in message news:400291af$[email protected]..
I have some entity beans with CMR. I am managing these entity beans with a Stateful session bean whose transactiontype is Container Managed for all its methods.
>
In one particular method of this Session bean I am calling two entity bean's create method. i.e I am creatingtwo entity beans through home.create() methods. There are two home.create() methods one after another inside a try catch
block.
>
I want that the entire operation be under just one transcation so i have also given the transaction attribute asRequired for all methods of Session bean and Entity Beans.
>
However if i pass invalid parameters to second create method so that it generates exception then still the firstcreate statement is successful and database is updated.
what i want is that the first create also should be roll backed.
How can i acheive this through Container Managed Transaction Session Bean?o Do you use TXDatasource with your entity beans?
o In CMT transactions are automatically rolled back only when RuntimeExceptions
are thrown. What kind of exception is thrown in your case?
Regards,
Slava Imeshev -
Load balancing not happending but fail over is for Read only Entity beans
The following are the configuration.
Two NT servers with WL5.1 sp9 having only EJBs(Read only entity beans)
One Client with WL5.1 sp9 having servlet/java application as
EJB client.
I am trying to make a call like findbyprimarykey in one of the
entity bean. I could see the request is being directed only to the one of the
server always. When I bring that server, fail over is happening to the other server.
Here are the settings I have in the ejb-jar.xml :
<entity>
<ejb-name>device.StartHome</ejb-name>
<home>com.wl.api.device.StartHome</home>
<remote>com.wl.api.device.StartRemote</remote>
<ejb-class>com.wl.server.device.StartImpl</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>java.lang.Long</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<res-ref-name>jdbc/wlPool</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
Here are the settings I have in the weblogic-ejb-jar.xml.
<weblogic-enterprise-bean>
<ejb-name>device.StartHome</ejb-name>
<caching-descriptor>
<max-beans-in-cache>50</max-beans-in-cache>
<cache-strategy>Read-Only</cache-strategy>
<read-timeout-seconds>900</read-timeout-seconds>
</caching-descriptor>
<reference-descriptor>
<resource-description>
<res-ref-name>jdbc/wlPool</res-ref-name>
<jndi-name>weblogic.jdbc.pool.wlPool</jndi-name>
</resource-description>
</reference-descriptor>
<enable-call-by-reference>False</enable-call-by-reference>
<jndi-name>device.StartHome</jndi-name>
</weblogic-enterprise-bean>
Am I doin any mistake in this?
Any one's help is appreciated.
Thanks
Suresh
we are using 5.1
"Gene Chuang" <[email protected]> wrote in message
news:[email protected]...
> Colocation optimization occurs if your client resides in the same
container (and also in the same
> EAR for 6.0) as your ejbs.
>
> Gene
>
> "Suresh" <[email protected]> wrote in message
news:[email protected]...
> > Ok....the ejb-call-by-reference set to true is making the call to one
server
> > only. i am not sure why it is. I removed the property name and it
works.
> > Also I have one question, in our prduct environment, when i cache the
ejb
> > home it is not doing the load balancing. can any one help me for that.
> > thanks
> >
> > Mike,
> > From the sample pgm I sent, even from single client calls get load
> > balanced.
> >
> > Suresh
> >
> >
> > "Gene Chuang" <[email protected]> wrote in message
> > news:[email protected]...
> > > In WL, LoadBalancing will ONLY WORK if you reuse your EJBHome! Take
your
> > StartEndPointHome lookup
> > > out of your for loop and see if this fixes your problem.
> > >
> > > I've seen this discussion in ejb-interest, and some other vendor
(Borland,
> > I believe it is), brings
> > > up an interesting point: Clustering and LoadBalance is not in the
J2EE
> > specs, hence implementation
> > > is totally up to the vendor. Weblogic loadbalances from the remote
> > interfaces (EJBObject, EJBHome,
> > > etc..), while Borland loadbalances from JNDI Context lookup.
> > >
> > > Let me suggest a third implmentation: loadbalance from BOTH Context
> > lookup as well as stub method
> > > invocation! Or create a smart replica-aware list manager which
persists
> > on the client thread
> > > (ThreadLocal) and is aware of lookup/evocation history. Hence if I do
the
> > following in a client
> > > hitting a 3 node cluster, I'll still get perfect round-robining
regardless
> > of what I do on the
> > > client side:
> > >
> > > InitialContext ctxt = new InitialContext();
> > > EJBHome myHome = ctxt.lookup(MY_BEAN);
> > > myHome.findByPrimaryKey(pk); <== hits Node #1
> > > myHome = ctxt.lookup(MY_BEAN);
> > > myHome.findByPrimaryKey(pk); <== hits Node #2
> > > myHome.findByPrimaryKey(pk); <== hits Node #3
> > > myHome = ctxt.lookup(MY_BEAN);
> > > myHome.findByPrimaryKey(pk); <== hits Node #1
> > > ...
> > >
> > >
> > > Gene
> > >
> > > "Suresh" <[email protected]> wrote in message
> > news:[email protected]...
> > > > Mike ,
> > > >
> > > > Do you have any reasons for the total number of machines to be 10.
> > > >
> > > > I tried with 7 machines.
> > > >
> > > >
> > > > Here is my sample client java application running individual in the
> > seven
> > > > machines.
> > > >
> > > > StartEndPointHome =
> > > > (StartEndPointHome)ctx.lookup("dev.StartEndPointHome");
> > > > for(;;)
> > > > {
> > > > // logMsg(" --in loop "+currentTime);
> > > > if (currentTime > nextRefereshTime)
> > > > {
> > > > logMsg("****- going to call");
> > > > currentTime=getSystemTime();
> > > > nextRefereshTime=currentTime+timeInterval;
> > > > StartEndPointHome =
> > > > (StartEndPointHome)ctx.lookup("dev.StartEndPointHome");
> > > > long rndno=(long)(Math.random()*10)+range;
> > > > logMsg(" going to call remotestub"+rndno);
> > > > retVal =
> > > >
> >
((StartEndPointHome)getStartHome()).findByNumber("pe"+rndno+"_mportal_dsk36.
> > > > mportal.com");
> > > >
> > > > logMsg("**++- called stub");
> > > > }
> > > >
> > > >
> > > >
> > > > The range value is different for each of the machines in the
cluster.
> > > >
> > > > If the first request starts at srv1, all request starts hitting the
same
> > > > server.
> > > > If the first request starts at srv2, all request starts hitting the
same
> > > > server.
> > > >
> > > > I have the following for the url , user and pwd values for the
context
> > .
> > > >
> > > > public static String url="t3://10.11.12.14,10.11.12.117:8000";
> > > > public static String user="guest";
> > > > public static String password="guest";
> > > >
> > > >
> > > >
> > > > It would be great if you could help me.
> > > >
> > > > Thanks
> > > > suresh
> > > >
> > > >
> > > > "Mike Reiche" <[email protected]> wrote in message
> > > > news:[email protected]...
> > > > >
> > > > > If you have only one client don't be surprised if you only hit one
> > server.
> > > > Try
> > > > > running ten different clients and see if the hit the same server.
> > > > >
> > > > > Mike
> > > > >
> > > > >
> > > > > "suresh" <[email protected]> wrote:
> > > > > >
> > > > > >The following are the configuration.
> > > > > >
> > > > > > Two NT servers with WL5.1 sp9 having only EJBs(Read only entity
> > beans)
> > > > > >
> > > > > > One Client with WL5.1 sp9 having servlet/java application as
> > > > > > EJB client.
> > > > > >
> > > > > >
> > > > > >I am trying to make a call like findbyprimarykey in one of the
> > > > > >entity bean. I could see the request is being directed only to
the
> > one
> > > > > >of the
> > > > > >server always. When I bring that server, fail over is happening
to
> > the
> > > > > >other server.
> > > > > >
> > > > > >
> > > > > >Here are the settings I have in the ejb-jar.xml :
> > > > > > <entity>
> > > > > > <ejb-name>device.StartHome</ejb-name>
> > > > > > <home>com.wl.api.device.StartHome</home>
> > > > > > <remote>com.wl.api.device.StartRemote</remote>
> > > > > > <ejb-class>com.wl.server.device.StartImpl</ejb-class>
> > > > > > <persistence-type>Bean</persistence-type>
> > > > > > <prim-key-class>java.lang.Long</prim-key-class>
> > > > > > <reentrant>False</reentrant>
> > > > > > <resource-ref>
> > > > > > <res-ref-name>jdbc/wlPool</res-ref-name>
> > > > > > <res-type>javax.sql.DataSource</res-type>
> > > > > > <res-auth>Container</res-auth>
> > > > > > </resource-ref>
> > > > > > </entity>
> > > > > >
> > > > > >
> > > > > >Here are the settings I have in the weblogic-ejb-jar.xml.
> > > > > >
> > > > > ><weblogic-enterprise-bean>
> > > > > > <ejb-name>device.StartHome</ejb-name>
> > > > > >
> > > > > > <caching-descriptor>
> > > > > > <max-beans-in-cache>50</max-beans-in-cache>
> > > > > > <cache-strategy>Read-Only</cache-strategy>
> > > > > > <read-timeout-seconds>900</read-timeout-seconds>
> > > > > > </caching-descriptor>
> > > > > >
> > > > > > <reference-descriptor>
> > > > > > <resource-description>
> > > > > > <res-ref-name>jdbc/wlPool</res-ref-name>
> > > > > > <jndi-name>weblogic.jdbc.pool.wlPool</jndi-name>
> > > > > > </resource-description>
> > > > > > </reference-descriptor>
> > > > > > <enable-call-by-reference>False</enable-call-by-reference>
> > > > > > <jndi-name>device.StartHome</jndi-name>
> > > > > > </weblogic-enterprise-bean>
> > > > > >
> > > > > >
> > > > > >Am I doin any mistake in this?
> > > > > >
> > > > > >Any one's help is appreciated.
> > > > > >Thanks
> > > > > >Suresh
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>
-
Strange Session/Entity Bean Cross-Instance Calls in Cluster
In one of our enviroments, we are seeing session entity bean cross-instance
calls that are hard to explain. The following is our configuration:
The cluster contains 4 instances on 2 machines (2 on each machine). The same
beans are deployed to each instance. "jndi.properties" is on the classpath
for the each instance with jndi provider url = mach1inst1-ip, mach1inst2-ip,
mach2inst1-ip, mach2inst2-ip:70001. Same servlets are also deployed to each
instances.
Requests from the web are load balanced through weblogic's proxy plugin for
IPlanet and are forwarded to the 4 weblogic cluster instances. The servlet
processing the requests calls a stateless session bean which uses an entity
bean. The entity bean is configured with "home-is-clusterable" set to
"false".
What we have observed is that when all 4 instances are up, sometimes (even
when the load is not high) the session bean is accessing entity bean from an
instance on one machine to an instnace on another machine, while if only one
machine (with 2 instances) is up, we don't see such calls.
My theory is that because the jndi provider url is the same for all
instances, the jndi lookup from each instance goes to the instance bound to
the first IP specified in the provider url: machine 1 istance 1. If the
request is from machine 2, because of co-location optimization, even though
the home stub is from machine 1 instance 1, the session bean returned from
the home stub actually is from machine 2. However, when the session bean
does jndi lookup to get an entity bean home, the home stub is from machine 1
and instance 1. And unfortunately, because the entity bean home is not
clusterable, the stub can only point back to machine 1, co-location can not
work. Thus entity bean from machine 1 is referenced by the session bean
located on machine 2. I do not have a chance to verify this. But it seems to
make sense to me.
Unfortunately, I don't feel that I have a theory to explain why we don't see
cross instance session entity bean calls when only 1 machine is up (with 2
instances).
Any ideas or hints would be greatly appreciated.
Thanks,
David Chen
rs = stmt.executeQuery() , insert statement is not a query. So use executeUpdate.
-
Entity Beans /JDO and Datawarehousing
Hi,
Currently i'm involved in a project, in which we want to generate some very basic custom reports, like turnover calculations etc.
These reports will be publish on a intranet environment.
My questions are:
How do Entity Beans perform when handling large tables (like a few million of rows).
What about transactions? The datawarehouse will not be updated by the application. Is it therefore advisible to turn it of, in order to gain performance?
I'm am completely new to JDO, would JDO be a better alternative compared to entity beans when working with large resultsets?
I hope someone can help
Thanks and Regards,
Vellihello
I strongly suggest to use JDBC instead of EJB/JDO. EJB's are great if you need transactions and has a lot of concurrent access. But they are very slow if you read huge data, because for every row an EJB instance is created. For reports you would need to iterate all those instance, in short, performace would be very bad.
Turning off transactions wont help. Some containers (WEBLogic) allows to configure entity beans as "read only", thus improving performance by data caching in EJB instances. So... if you really need EJB then you can use that.
However this would not be very effective too, if you really have millions of rows, because it's not possible to keep them all in RAM.
For several thousands of records it would be very good, but not millions.
Furthermore, several design patterns suggest to use JDBC in such sitoation. For more information you can read:
+ http://java.sun.com/blueprints/patterns/FastLaneReader.html
+ book "EJB design patterns" (You can find it at TSS)
+ book "Bitter Java"
Maris Orbidans
System.out.println(out2.readOutputValue()); -
Error when deploying a simple Entity bean (EJB3) on Glassfich or Sun AS
Hi,
After some problems when deploying complex EJB3 Entity bean on GlassFich with a MySQL connector, I have made a simple entity.
(test with Glassfish and Sun AS with same result)
With netbean 5.5 => New EJB Module
File->New->Persistence Unit (and use default values)
Persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="test" transaction-type="JTA">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<jta-data-source>jdbc/sample</jta-data-source>
<properties>
<property name="toplink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
</persistence>File->New->Entity Class
EntityTest.java
package test;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class EntityTest implements Serializable
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
/** Creates a new instance of EntityTest */
public EntityTest()
public Long getId()
return id;
public void setId(Long id)
this.id = id;
public String toString()
//TODO change toString() implementation to return a better display name
return "" + this.id;
}Build of project work fine but when I try to deploy (with the 2 servers), I have the error :
Exception occured in J2EEC Phase
com.sun.enterprise.deployment.backend.IASDeploymentException: Deployment Error -- null
at java.util.HashMap$HashIterator.nextEntry(HashMap.java:790)
at java.util.HashMap$KeyIterator.next(HashMap.java:823)
at com.sun.enterprise.deployment.backend.EjbModuleDeployer.generatePolicy(EjbModuleDeployer.java:203)
at com.sun.enterprise.deployment.backend.ModuleDeployer.doRequestFinish(ModuleDeployer.java:171)
at com.sun.enterprise.deployment.phasing.J2EECPhase.runPhase(J2EECPhase.java:169)
at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:95)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:871)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:266)
at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:739)
at com.sun.enterprise.management.deploy.DeployThread.deploy(DeployThread.java:174)
at com.sun.enterprise.management.deploy.DeployThread.run(DeployThread.java:210)Yes, the problem is that the ejb-jar must contain at least one ejb component. It's a common misconception that Java Persistence API Entity classes are ejb components but they are NOT. The Java Persistence API was developed within the EJB 3.0 JSR and works very well with EJB but the entity classes themselves are not full-fledged ejb components.
--ken
Maybe you are looking for
-
Document control failed due to error in [DOCMGR-CANCEL] with a return code
i am getting this error while calceling the purchase order "Document control failed due to error in [DOCMGR-CANCEL] with a return code of [OTHER]. " I am doing the calcel like this Nav: buyer work centre --> order searche the po and then select order
-
Error on Automatic PO at GR Level
Hi, I wish to enable automatic PO creation, on goods receipt. For this I have done the following in config: 1) Assigned a standard Purchasing Org for the plant 2) Created a standard Purchasing Inforecord for the material, vendor combination 3) Enable
-
Attachments for mail adapter?
Hello everybody, I've seen that XI 3.0 provides a file adapter. Has anyone experiences with this adapter? I'm looking for information if it's possible to send and receive the XML message content as attachment. Thanks in advance Björn
-
Memory Leak with the new PatchMix App Beta?
E6300/ASUS P5B-D/2GB RAM/EMU 0404/Vista Ultimate 32bit The problem happens after I upgrade to the PatchMix driver set dated 9/11. The physical memory usage bumps from ~24M to 150M after running 24 hours, and I didnt load any FX. The commit size(real
-
Hi,i am trying to put a raisedBevel border around my JButtons.It works fine for four of the five buttons,but as soon as i set it around my fifth button the buttons become greatly reduced in size.Thanx for your time.