Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

Transaction problem in ejbCreate()

瀏覽次數:2 次
跳到第一則未讀訊息

Nils Winkler

未讀,
2001年8月8日 清晨5:54:302001/8/8
收件者:
Hi,

I'm having a problem with transactions in the ejbCreate() method of a
stateful session bean:

The ejbCreate() method does not run in a transaction, even if "Required"
is specified in the Deployment Descriptor:

<container-transaction>
<method>
<ejb-name>XXXBean</ejb-name>
<method-intf>Remote</method-intf>
<method-name>*</method-name>
</method>
<method>
<ejb-name>XXXBean</ejb-name>
<method-intf>Home</method-intf>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>

I noticed this because I'm trying to do some JDBC queries from the
ejbCreate() method. The queries go against a TXDataSource, using the
jDriver provided by WebLogic (weblogic.jdbc.oci.xa.XADataSource). When
the server tries to do the query, it spits out the following exception:

java.sql.SQLException: Does not support SQL execution with no global
transaction
at
weblogic.jdbc.oci.xa.XAConnection.beforeExecute(XAConnection.java:137)
at
weblogic.jdbc.oci.xa.XAConnection.prepareStatement(XAConnection.java:240)
at
weblogic.jdbc.oci.xa.Connection.prepareStatement(Connection.java:63)
at
weblogic.jdbc.jta.XAConnection.prepareStatement(XAConnection.java:415)
at
weblogic.jdbc.jta.Connection.prepareStatement(Connection.java:228)
at
weblogic.jdbc.rmi.internal.ConnectionImpl.prepareStatement(ConnectionImpl.java:135)
at
weblogic.jdbc.rmi.SerialConnection.prepareStatement(SerialConnection.java:76)
at XXXBean.loadIds(XXXBean.java:529)
at XXXBean.doInit(XXXBean.java:500)
at XXXBean.ejbCreate(XXXBean.java:189)
at XXXBean_dlkzvg_Impl.ejbCreate(XXXBean_dlkzvg_Impl.java:112)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.ejb20.manager.StatefulSessionManager.create(StatefulSessionManager.java:661)
at
weblogic.ejb20.manager.StatefulSessionManager.remoteCreate(StatefulSessionManager.java:709)
at
weblogic.ejb20.internal.StatefulEJBHome.create(StatefulEJBHome.java:142)
at
XXXBean_dlkzvg_HomeImpl.create(XXXBean_dlkzvg_HomeImpl.java:75)
at RequestProcessor.handleInitialize(RequestProcessor.java:2560)
at RequestProcessor.handleEvent(RequestProcessor.java:250)
at RequestProcessor.processRequest(RequestProcessor.java:106)
at jsp_servlet._controller._jspService(_controller.java:155)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:263)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:200)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:2390)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1959)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

As you can see, ejbCreate() calls the method doInit(), which calls
loadIds(), which tries to prepare the SQL statement.

When I remove the call to doInit from ejbCreate() and call doInit() from
the client, everything works fine. But I don't want to do it that way,
since the initialization done in doInit() really belongs in ejbCreate().

I also tried playing around with the "container-transaction" settings
(explicitly creating an entry for "create" in the Home "method-intf"),
but to no avail...

Can someone please help me?

Configuration: WL 6.1, Win2K Professional, JDK 1.3.1, Oracle jDriver,
Oracle 8.1.6

Thanks,

Nils

====================
nils.w...@tietoenator.com

kesh

未讀,
2001年8月8日 上午10:28:082001/8/8
收件者:
ejbCreate method of session ejbs is called with an unspecified transaction
context.
EJB2.0 spec 7.5.7

/kesh

"Nils Winkler" <nils.w...@tietoenator.com> wrote in message
news:3B710C56...@tietoenator.com...

Cameron Purdy

未讀,
2001年8月8日 晚上9:54:382001/8/8
收件者:
WL runs ejbCreate w/in a tx context. There used to be a bug (previous to
5.1sp6?) that prevented this, but it was fixed. (I can't remember how to
specify that a tx is required, if it is necessary at all.)

Peace,

--
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>


"kesh" <ksib...@powernetinc.com> wrote in message
news:3b71...@newsgroups.bea.com...

Rob Woollen

未讀,
2001年8月9日 下午1:57:452001/8/9
收件者:
I think you're mixing up our bugs :>

Session beans run ejbCreate and ejbRemove in an "unspecified"
transaction context. No matter what you set in your descriptor, these
methods run as NotSupported.

Entity beans support (and should have) transactions on their create and
remove methods. There was a bug in 5.1.0 that messed this up, and it
was fixed in SP2 or 3.

-- Rob

--

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

Coming Soon: Building J2EE Applications & BEA WebLogic Server

by Michael Girdley, Rob Woollen, and Sandra Emerson

http://learnweblogic.com

Cameron Purdy

未讀,
2001年8月9日 晚上7:57:362001/8/9
收件者:
You are right (bien sur!), I was talking about entities. I will learn to
notice little things like "session bean" in future posts.

Peace,

--
Cameron Purdy
Tangosol Inc.
<< Tangosol Server: How Weblogic applications are customized >>
<< Download now from http://www.tangosol.com/download.jsp >>


"Rob Woollen" <nelloowrehpo...@rorrim.moc> wrote in message
news:3B72CF19...@rorrim.moc...

0 則新訊息