DAO and CMT config...
Hi.
I am using WLS 8.1 sp2 . I have a stateless session bean that uses a DAO for database access. It appears that the DAO is not participating in the transaction. Here is a very simple example, here is my slsb method:
public String doTransaction(int id, String name, String description)
throws RemoteException
//Call two methods, do the first to write a record, then
//call setRollbackOnly to see if it is rolled back.
try
StoreDAO storeDAO = StoreDAOFactory.getDAO();
storeDAO.saveT1(id, name);
//I FORCE THIS CALL TO THROW AN EXCEPTION
storeDAO.saveT2(id, description);
catch( Exception e)
ctx.setRollbackOnly(); //<-- saveT1 is NOT rolled back
System.out.println("Ok, the rollbackonly was called");
return e.getMessage();
return "ok";
Here is ejb-jar.xml as it pertains to this method:
<container-transaction>
<method>
<ejb-name>ShoppingCartBean</ejb-name>
<method-name>doTransaction</method-name>
</method>
<trans-attribute>RequiresNew</trans-attribute>
</container-transaction>
I force saveT2 to throw an exception right away, so the transaction will be rolled back, but the data that was written to the database during the saveT1 call is not rolled back.
I obtain the database connection in the DAO by doing a JNDI lookup for the datasource that I configured with weblogic.
Any Ideas?
How is the DataSource configured? Is is a JDBCDataSource or a
JDBCTxDataSource? If it isn't the latter, it isn't transactional and it will
not be enlisted in the transaction started by the container.
Bill
"david kessler" <[email protected]> wrote in message
news:15207409.1107277453717.JavaMail.root@jserv5...
> Hi.
>
> I am using WLS 8.1 sp2 . I have a stateless session bean that uses a DAO
> for database access. It appears that the DAO is not participating in the
> transaction. Here is a very simple example, here is my slsb method:
>
> public String doTransaction(int id, String name, String description)
> throws RemoteException
> {
> //Call two methods, do the first to write a record, then
> //call setRollbackOnly to see if it is rolled back.
> try
> {
> StoreDAO storeDAO = StoreDAOFactory.getDAO();
> storeDAO.saveT1(id, name);
> //I FORCE THIS CALL TO THROW AN EXCEPTION
> storeDAO.saveT2(id, description);
> }
> catch( Exception e)
> {
> ctx.setRollbackOnly(); //<-- saveT1 is NOT rolled back
> System.out.println("Ok, the rollbackonly was called");
> return e.getMessage();
> }
> return "ok";
> }
>
> Here is ejb-jar.xml as it pertains to this method:
>
> <container-transaction>
> <method>
> <ejb-name>ShoppingCartBean</ejb-name>
> <method-name>doTransaction</method-name>
> </method>
> <trans-attribute>RequiresNew</trans-attribute>
> </container-transaction>
>
> I force saveT2 to throw an exception right away, so the transaction will
> be rolled back, but the data that was written to the database during the
> saveT1 call is not rolled back.
>
> I obtain the database connection in the DAO by doing a JNDI lookup for the
> datasource that I configured with weblogic.
>
> Any Ideas?
Similar Messages
-
Ejb interceptor and CMT transaction
hi all,
i have one stateless session bean using CMT.
And it has been intercept by ejb interceptor.
actually, i try to catch all the exception from session bean method using interceptor.
eg.
try {
target2 = invocation.proceed();
return target2;
} catch (Exception e) {
But i can't catch some kind of SQLException. because it looks like transaction doesn't commit after invocation.proceed();
So, i can only catch those exception from caller.
Is there any way to solve it?
is there any way to catch all the exception from interceptor ?
With Regards,
WPThanks for reply.
we do not support to use requires_new because we may have another ejb layer(caller) and our ejb may need to join transaction of caller.
So, i would like to choose EntityManager.flush().
Then, I have DAO layer to insert record to db. Something like generic DAO and it is supported for all kinds of entity.
So, when we invoke two times DAO layer from our stateless session bean method, how it will behave?
I mean in the following ejb method, both DAO call can be in same transaction?
eg. DAO
public void create(T t) {
entityManager.persist(t);
entityManager.flush();
EJB Method
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
public void performInsert(){
dao.create(EmployeeEntity);
dao.create(AddressEntity);
} -
What is difference between ADF Task Flow and Faces-Config - when delpoy ?
What is difference between ADF Task Flow and Faces-Config? When I create navigation between pages with ADF task flow then the navigation don't work when I deploy my application to Weblogic 10.3. When I use default server then navigation works fine. With Faces_config in both situations all works ok - on Stanalone server and default.
Where is the problem?
Best regards!Shay, I don't use both faces-config and adf task flow! When I failed with task flow I tried faces-config.
I have active on my weblogic - adf.oracle.domain(1.0,11.1.1.0.0). This is the right ADF? If yes then where is the problem?
Best regards! -
Is it possible to import and export Config Toll Configuration from one sys
Hi All,
Is it possible to import and export Config Toll Configuration from one system to Another system (QUS/PRD), for especific service.
Kindly let me know the pro and corn of it and step by step process
Thanks alot for your time.
Thanks
ABYes...It is certainly possible but then you would need to bring OS level j2ee filestructure as well and there are lots of changes at OS level in *.properties file and then at configtool level changes related to hostname, system numbers and port numbers etc.
This is not much difficult but not impossible also if you do it very carefully. Please note that SAP DOES NOT SUPPORT THIS METHOD.
alternatively, you can use sapinst to export-import j2ee filesystem from source to target which inturn would require to do configtool export/import and then changes at configtool level.
Do let us know your requirement so that we cud help you in case you are facing any issues.
cheers !!!
Ashish -
hello,
could anyone please post screen capture of ISE posture configuration ( and remediation )
I need urgently a dACL and a redirection ACL that work at least in a mockup lab.
Authentification and authorizations policies not needed.
posture and remediation policies not needed.
The issue is about ACLs (I guess)
Also needed is a valid switch config file, with ACL (if necessary) a the DOT1x ethernet port.
My IOS is 122.55 SE or 52 SE
Thank you by advance.
Best regards.
V.Hi Venkatesh,
Your the ultimate ISE Guru !!
You're right
Thanks a lot.
See screen captures and Sw config below
aaa new-model
aaa group server radius ISE
server 192.168.6.10 auth-port 1812 acct-port 1813
server 192.168.6.10 auth-port 1645 acct-port 1646
aaa authentication login default local
aaa authentication dot1x default group ISE
aaa authorization network default group ISE
aaa authorization network auth-list group ISE
aaa authorization auth-proxy default group radius
aaa accounting dot1x default start-stop group ISE
aaa server radius dynamic-author
client 192.168.6.10 server-key 123456789
ip dhcp snooping
ip device tracking
dot1x system-auth-control
dot1x critical eapol
interface FastEthernet1/0/1
switchport mode access
ip access-group ACL-ALLOW in
authentication port-control auto
authentication periodic
dot1x pae authenticator
dot1x timeout tx-period 10
spanning-tree portfast
spanning-tree bpduguard enable
ip http server
ip http secure-server
ip access-list extended ACL-ALLOW
permit ip any any
ip access-list extended ACL-POSTURE-REDIRECT
deny udp any any eq domain
deny udp any host 192.168.6.10 eq 8905
deny udp any host 192.168.6.10 eq 8906
deny tcp any host 192.168.6.10 eq 8443
deny tcp any host 192.168.6.10 eq 8905
deny tcp any host 192.168.6.10 eq www
permit ip any any
snmp-server community snmp RO
snmp-server community RO RO
snmp-server enable traps snmp authentication linkdown linkup coldstart warmstart
snmp-server enable traps mac-notification change move threshold
snmp-server host 192.168.6.10 public
snmp-server host 192.168.6.10 version 2c snmp mac-notification
radius-server attribute 6 on-for-login-auth
radius-server attribute 6 support-multiple
radius-server attribute 8 include-in-access-req
radius-server attribute 25 access-request include
radius-server dead-criteria time 5 tries 3
radius-server host 192.168.6.10 auth-port 1645 acct-port 1646 key 123456789
radius-server vsa send accounting
radius-server vsa send authentication
V. -
Hi,
why do we need to specify role base provider and membership provider files in central admin and securiy config files.
thanks,
gauravWe use 3 settings in Forms based auth:
1 Membership = This contains Users and groups information. (This table also has username and password)
2 ConnectionString = Connetion details to connect to database is stored here(servername, databasename, username, password, port )
3 Role = This table contains all the Roles (Admin, contibutor, etc of the data source) -
Location of MTA and POA config files:
Hello. I'm reading an article from cool tools by Kiril Stankov regarding
moving a groupwise database to a new volume or server. In step 4 he says
if you are moving data between servers make sure to copy the POA, MTA,
WAA and GWIA config files. The only one I can find is the gwia.cfg. I
looked under SYS:\system for the others and can't find them anywhere.
Thanks> What's in grpwise.ncf ?
>
> It should be something like
>
> LOAD SYS:\SYSTEM\GWPOA @POA.POA
> LOAD SYS:\SYSTEM\GWMTA @MTA.MTA
LOAD SYS:\SYSTEM\GWPOA @CTCPO.POA
LOAD SYS:\SYSTEM\GWMTA @CTCMAIL.MTA
> the files you want are the ones after the @ sign, and they should be in
> the directory referred to in the load bit, in this case sys:\system
Ok. So I can, in my case anyway, just copy my SYS directory over if I
choose too
> Cheers Dave
>
>
> --
> Dave Parkes [NSCS]
> Occasionally resident at http://support-forums.novell.com/ -
How to save column widths in tag monitor and tag config editor?
how to save column widths in tag monitor and tag config editor?
The attached example may help.
After launching the editor, I locate a reference to the front panel control named "Tag List".
This is type cast as a multicolumn list box which then allows me to increment through all of the cells and set the widths as i go.
Trying to help,
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
Set_Width2.vi 60 KB
SET_WIDTH.JPG 94 KB -
Cannot Read From Registry - Need to save and load config
I have code the I have tested in other programs. I cannot read or write to the registry from a plugin. Any ideas?
Any suggestions for the best way to save and load config information?
Thanks!!!Hi Srikanth,
Thank you for responding.
I had a problem on one material. So deleted the request and Reload it from PSA. That issue got solved.
And Now the problem is , Now my senior is saying Delete the data from April-09 till date and Reload it. The issue is My CUBE ( ZSD_C03 ) is updated with 4 data sources. 2LIS_11_V_ITM , 2LIS_13_VDITM , 2LIS_12_VCHDR , 2LIS_11_VAITM .
And I need to delete data from 2LIS_13_VDITM data source . How Can I proceed for the current issue ?
Please suggest ...
Thank you ,
Utpal -
Managed bean in both adfc-config.xml and faces-config.xml file
hi,
i can see that it's possible to declare managed bean in both adfc-config.xml and faces-config.xml file.
is there any difference? which one is recommended?
read here - http://www.jaypillai.com/tag/adf/
but still not clear.
thanks.Hi.
As you know ADF is a framework based on JSF.
In faces-config.xml you define general application manage beans. It offers you define manage beans for all application using JSF default scopes (application, session, request).
In adfc-config.xml you define general application manage beans using ADF Scopes. It means that you can use JSF default ones including "view, pageFlow and backing".
My recommendation is use only one point entry for your general manage beans. Use adfc-config.xml because allow you to use more scopes.
Regards. -
In the following piece of code:-
package com.informit.myejb.dao;
public interface SampleDAO
public SampleModel create( long id, String name, String data ) throws
SampleDAOException;
public void delete( long id ) throws SampleDAOException;
public void update( long id, SampleModel model ) throws
SampleDAOException;
public SampleModel[] findByName( String name ) throws
SampleDAOException;
public SampleModel findById( long id ) throws SampleDAOException;
}we are creating a DTO named sampleModel. Now considering that I just need one value out of the whole table. Wouldn't creating the whole DTO object be a waste of time effort and memory, specially if each time we hae to access the DTO we have to create a new one. specially if the keys being passed to the method are used only once.
I understand the concept of separation of concerns but I am concerned over here about the amount of effort required to create these DAOs and DTOs specially in cases where only one or two fields are required.
To me it seems like an over kill.
Any comments.well Martin Fowlwer does propose IdentityMap pattern in such a case where he says that thes objects should be stored in a Map with the primary key being the key for the map. So next time you need an object you check with the map if it exists or not and if it doesnot you try to grab it again.
But IMHO if the hit ratio(no. of times the same data is used again) is less these Maps might pose a nightmare in terms of memory and garbage collection.
So should one use IdentityMap or avoid it?
What do you think. -
I m new to Struts and i wsh to do a stuff in it....
I m not clear with the DAOs and Business Delegate model in it and i need a sample code for continuing with wher can i get if anybody culd suggest me a well start point??hi
thanks for ur response,
Actually i tried the tryme.war from http://javaboutique.internet.com/tutorials/ApacheDAOs/tryme.war
i hav configured my conf/server.xml as
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase" pathname="conf/tomcat-users.xml" factory="org.apache.catalina.users.MemoryUserDatabaseFactory"/>
<Resource name="PointBaseJNDI" type="javax.sql.DataSource" password="mysql" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/test" maxActive="40"/>
<Resource name="jdbc/hrweb" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" password="mysql" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/hrweb" maxActive="4"/>
<Resource name="jdbc/hrsite" type="javax.sql.DataSource" password="mysql" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/hrsite" maxActive="40"/>
<Resource name="testmysql" type="javax.sql.DataSource" password="admin" driverClassName="sun.jdbc.odbc.JdbcOdbcDriver" maxIdle="2" maxWait="5000" username="root" url="jdbc:odbc:tomtest" maxActive="4"/>
<Resource name="jdbc/dao" type="javax.sql.DataSource" password="mysql" driverClassName="com.mysql.jdbc.Driver" maxIdle="2" maxWait="5000" username="root" url="jdbc:mysql://localhost:3306/test" maxActive="4"/>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8088" redirectPort="8443" maxSpareThreads="75" maxThreads="150" minSpareThreads="25">
</Connector>
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
</Host>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>
</Engine>
</Service>
</Server>
also my catalina/localhost/root.xml to be
<?xml version='1.0' encoding='utf-8'?>
<Context displayName="Welcome to Tomcat" docBase="ROOT" path="" workDir="work\Catalina\localhost\_">
<ResourceLink global="jdbc/dao" name="jdbc/daoref" type="javax.sql.sourceParams"/>
<ResourceLink global="testmysql" name="testmysqlref" type="javax.sql.DataSource"/>
<ResourceLink global="PointBaseJNDI" name="PointBaseJNDIRef" type="javax.sql.DataSource"/>
<ResourceLink global="AccessJNDI" name="AccessJNDIRef" type="javax.sql.DataSource"/>
</Context>
but when i tried to get run the tryme.war , list.jsp file
i m getting the follown error...
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot find bean dvds in any scope
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:845)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:778)
org.apache.jsp.list_jsp._jspService(org.apache.jsp.list_jsp:106)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.jsp.JspException: Cannot find bean dvds in any scope
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:938)
org.apache.struts.taglib.logic.IterateTag.doStartTag(IterateTag.java:277)
org.apache.jsp.list_jsp._jspService(org.apache.jsp.list_jsp:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.
could u please figure out the problem? -
Exact functions of Servlet context and servlet Config inside web container
What is the correct(exact) function in the Servlet Context and Servlet Config inside the Web Container?.
Pls anybody response me.
-- PalaniServletConfig:
The container reads the servlet init-parameters specified in web.xml then adds them to ServletConfig. The container then passes ServletConfig to the servlet. Thereafter, the servlet can access the ServletConfig and get the servlet init-parameters. The idea is that you can avoid hard coding data that might change in your servlet code, e.g. an email address. If the email address changes, you can change it in web.xml instead of having to hunt through all your code and change the email address every place it appears and then recompiling the servlet.
Servlet init-parameters in web.xml are targeted for one servlet.
ServletContext:
The ServletContext is an app wide bulletin board where you can post data. Other parts of your app, e.g. other servlets, can then read the data on the bulletin board.
Also, similar to ServeltConfig, the container reads context-init parameters from web.xml and inserts them into ServletContext. However, in this case they are inserted into an app wide bulletin board, and therefore all servlets can read them.
An example: you might put database connection info in some context-init parameters. Then when the ServletContext is created, you can have "a listener" respond to the ServletContext creation event and get the database info, create a database connection, and attach it to the ServletContext. Then the database connection will be available to any servlet that needs it.
palanithendral wrote:
What is the correct(exact) function in the Servlet Context and Servlet Config inside the Web Container?.
The exact function of each would be determined by the group of methods each one provides. You need to check the java docs to see what each method does. -
Visual Studio generates wrong proxy and client config for WCF Service Host with customBinding
Hi,
I have a simple WCF test service.
The serviceModel configuration for the looks like this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="NewBinding0">
<byteStreamMessageEncoding>
<readerQuotas maxDepth="10" maxStringContentLength="10000" maxArrayLength="10000"
maxBytesPerRead="1000" maxNameTableCharCount="200" />
</byteStreamMessageEncoding>
<tcpTransport />
</binding>
</customBinding>
</bindings>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<services>
<service name="WcfServiceLibrary2.Service1">
<endpoint address="mex" binding="mexHttpBinding" name="mexName"
contract="IMetadataExchange" />
<endpoint address="net.tcp://localhost:8734/WcfServiceLibrary2/Service1.svc"
binding="customBinding" bindingConfiguration="NewBinding0" name="tcpName"
bindingName="" contract="WcfServiceLibrary2.IService1" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8733/Design_Time_Addresses/WcfServiceLibrary2/Service1/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
However the auto generated client side serviceModel looks like this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="tcpName">
<textMessageEncoding messageVersion="Soap12" />
<tcpTransport />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8734/WcfServiceLibrary2/Service1.svc"
binding="customBinding" bindingConfiguration="tcpName" contract="ServiceReference2.IService1"
name="tcpName" />
</client>
</system.serviceModel>
Note the Encoding has changed to from byteStreamMessageEncoding to textMessageEncoding.
When I test the service with WCF Test Client, I get the error "Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding
WS-Addressing headers."
The error message makes sense in considering the client is mis-configured. I could manually modify the client side configuration, but I don't know how to give that to the WCF Test Client.
When I run my own test client code, I get a NullReferenceException creating the Channel
at System.Text.UTF8Encoding.GetByteCount(String chars)
at System.ServiceModel.Channels.EncodedFramingRecord..ctor(FramingRecordType recordType, String value)
at System.ServiceModel.Channels.EncodedContentType.Create(String contentType)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.CreatePreamble()
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel..ctor(ChannelManagerBase factory, IConnectionOrientedTransportChannelFactorySettings settings, EndpointAddress remoteAddresss, Uri via, IConnectionInitiator connectionInitiator, ConnectionPool connectionPool, Boolean exposeConnectionProperty, Boolean flowIdentity)
at System.ServiceModel.Channels.ConnectionOrientedTransportChannelFactory`1.OnCreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.Channels.ChannelFactoryBase`1.InternalCreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.Channels.ServiceChannelFactory.ServiceChannelFactoryOverDuplexSession.CreateInnerChannelBinder(EndpointAddress to, Uri via)
at System.ServiceModel.Channels.ServiceChannelFactory.CreateServiceChannel(EndpointAddress address, Uri via)
at System.ServiceModel.Channels.ServiceChannelFactory.CreateChannel(Type channelType, EndpointAddress address, Uri via)
at System.ServiceModel.ChannelFactory`1.CreateChannel(EndpointAddress address, Uri via)
at System.ServiceModel.ClientBase`1.CreateChannel()
at System.ServiceModel.ClientBase`1.CreateChannelInternal()
at System.ServiceModel.ClientBase`1.get_Channel()
at ConsolWCFTestApp.ServiceReference2.Service1Client.GetXSDFiles(String path) in c:\Users\malley\Documents\Visual Studio 2013\Projects\WcfService1\ConsolWCFTestApp\Service References\ServiceReference2\Reference.cs:line 127
at ConsolWCFTestApp.Program.Main(String[] args) in c:\Users\malley\Documents\Visual Studio 2013\Projects\WcfService1\ConsolWCFTestApp\Program.cs:line 14
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Any suggestions much appreciated.
MartinHi Martin00,
I have tested your code in my side and I can meet the same exception as you.
>>"Addressing Version 'AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none)' does not support adding WS-Addressing headers."
Based the above exception, I try to use the following config:
<textMessageEncoding messageVersion="Soap12" />
Instead of this config code:
<byteStreamMessageEncoding>
<readerQuotas maxDepth="10" maxStringContentLength="10000" maxArrayLength="10000"
maxBytesPerRead="1000" maxNameTableCharCount="200" />
</byteStreamMessageEncoding>-->
After that it works fine as following:
Best Regards,
Amy Peng
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Problem with rollback in EJB and CMT
Hello,
I faced a problem in my application that I really do not understand (but I really would like to). How can I trigger a rollback of a transaction that is container-managed (CMT)? I know that any system exceptions are supposed to be handled by the container automatically and will cause a transaction rollback when they are thrown from an enterprise bean method. My Problem now is that I'm unable to make this work in my application.
Consider a situation like this:
The ManageEntityBean holds a simple save() method that creates an instance of EntityA and another of EntityB. Both instances store an arbitrary number (here 10). After this, the entityManger (injected from the container) is asked to make these instances persistent. EntityB is mapped with a "unique" constraint, so any attempt to store the same number twice will cause an SQL Exception.
First time when the save() method is invoked, the instances aEntity and bEntity are made permanent in the database. Second time when the save() method is invoked, the database throws an exception because bEntity is violating the unique constraint. What I would expect now is a complete rollback of the whole transaction. Instead, only bEntity has not been made permanent, but aEntity has.
What's wrong with this code?
@Stateless
public class ManageEntityBean implements ManageEntity {
@PersistenceContext
private EntityManager entityManager;
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public void save() {
try {
EntityA aEntity = new EntityA(10);
EntityB bEntity = new EntityB(10);
entityManager.persist(aEntity);
entityManager.persist(bEntity);
} catch (Exception e) {
throw new EJBException(e);
@Entity
public class EntityA implements java.io.Serializable {
@Id
@GeneratedValue
private long id;
@Column(name="NUMBER")
private int number;
public EntityA() {}
public EntityA(int number) {
this.number = number;
@Entity
public class EntityB implements java.io.Serializable {
@Id
@GeneratedValue
private long id;
@Column(name = "NUMBER", unique = true)
private int number;
public EntityB() {}
public EntityB(int number) {
this.number = number;
}I found two related topics in this forum but still I didn't find the solution yet.
[Enterprise JavaBeans - CMT and JDBC|http://forums.sun.com/thread.jspa?forumID=13&threadID=525651]
and
[ Forums - A CMT Session Bean Does Not Maintain the Transaction Correctly| http://forums.sun.com/thread.jspa?forumID=13&threadID=161512]
Maybe anyone can give me a hint. Help is very much appreciated
ChristophThank you for your input!
The save() method is simply invoked from the test applications main() method:
public class Test {
public static void main(String[] args) {
JndiUtil<ManageEntity> jndiUtil = new JndiUtil<ManageEntity>();
ManageEntity handler = jndiUtil.lookupBeanContext("ManageEntityBean", ManageEntity.class);
handler.save();
}Btw. I use Hibernate as persistence provider and JBoss 4.2.2.GA as application server.
For clarity I attach some lines of the debug logging that is produced when the test application is getting started for the second time:
### open Session
17:44:00,555 DEBUG *[SessionImpl] opened session at timestamp: 5007498610909184*
17:44:00,555 DEBUG [AbstractEntityManagerImpl] Looking for a JTA transaction to join
17:44:00,555 DEBUG [JDBCContext] successfully registered Synchronization
17:44:00,555 DEBUG [AbstractEntityManagerImpl] Looking for a JTA transaction to join
17:44:00,555 DEBUG [AbstractEntityManagerImpl] Transaction already joined
### invoke em.persist(aEntity)
17:44:00,555 DEBUG [AbstractSaveEventListener] executing identity-insert immediately
17:44:00,555 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:44:00,555 DEBUG *[ConnectionManager] opening JDBC connection*
17:44:00,555 DEBUG [SQL]
/* insert de.zippus.domain.EntityA
17:44:00,556 INFO [STDOUT] Hibernate:
/* insert de.zippus.domain.EntityA
17:44:00,558 DEBUG [IdentifierGeneratorFactory] Natively generated identity: 2
17:44:00,559 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:44:00,559 DEBUG [ConnectionManager] aggressively releasing JDBC connection
17:44:00,559 DEBUG [ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: >0)]
### invoke em.persist(bEntity)
17:44:00,559 DEBUG [AbstractSaveEventListener] executing identity-insert immediately
17:44:00,559 DEBUG [AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:44:00,559 DEBUG [ConnectionManager] opening JDBC connection
17:44:00,559 DEBUG [SQL]
/* insert de.zippus.domain.EntityB
17:44:00,560 INFO [STDOUT] Hibernate:
/* insert de.zippus.domain.EntityB
17:44:00,561 DEBUG [AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:44:00,561 DEBUG [ConnectionManager] aggressively releasing JDBC connection
17:44:00,561 DEBUG [ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: >0)]
17:44:00,561 DEBUG [JDBCExceptionReporter] could not insert: [de.zippus.domain.EntityB] [* insert de.zippus.domain.EntityB */ insert into >ENTITY_B (NUMBER) values (?)]
com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Duplicate entry '10' for key 2
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:931)
17:44:00,563 WARN [JDBCExceptionReporter] SQL Error: 1062, SQLState: 23000
17:44:00,563 ERROR [JDBCExceptionReporter] Duplicate entry '10' for key 2
17:44:00,563 DEBUG [AbstractEntityManagerImpl] mark transaction for rollback
17:44:00,563 ERROR [ManageEntityBean] Caught exception: javax.persistence.EntityExistsException: >org.hibernate.exception.ConstraintViolationException: could not insert: [de.zippus.domain.EntityB]
17:44:00,563 ERROR [ManageEntityBean] Exception Cause: org.hibernate.exception.ConstraintViolationException: could not insert: >[de.zippus.domain.EntityB]
17:44:00,564 DEBUG *[ManagedEntityManagerFactory] ************** closing entity managersession *************** Up to now I'm not that experienced in reading and understanding this kind of logging, but what I can see is, that there is a transaction that spans the whole unit of work and that this transaction is marked for rollback. I think that's quite a good thing, isn't it?
But what really puzzles me here is, that both calls of em.persist() result in an opening of a jdbc connection and an immidiate execution of a database insert. Tell me if I'm wrong, but is this really the right place to happen?
For what reason soever hibernate thinks it has to make these instances permanent, no matter if there is already a session that is taking care of this. If so, I might deal with a wrong hibernate configuration, I checked, but I can't find anything..
What do you think?
Thanks in advance!
Christoph
Maybe you are looking for
-
Photoshop CS4 Window Stays In Background
When I drag an image file into Photoshop CS4, the file opens but Photoshop remains in the background – i.e., in the window behind the one that I dragged the file from. For example - I open Photoshop, then open Bridge, with the Bridge window mostly co
-
Pulling multiple variables into a single line?
There really seems like an easy fix to this, but I'm just not finding it on my own here. Here's my setup: I've got four variables that are pulling data from our system: Customer Address, City, State, and Zip - for some silly reason we do not have a s
-
Inserting data into a MySQL database
Hi. I am currently working on a group project and know very little about java to be honest I'm trying to insert records into a local MySQL database, but I'm having trouble. When the application is started, a connection is made to the database, which,
-
How to maintain gap between table and graph in a report
HI, I have a report in which a graph is placed below a table and data in the table gets increased with time , then how to maintain the gap as constant between table and the graph ?? Like i have 50 rows in a table and then next day 10 rows are added
-
Screen captures for a 720p project?
What is the best way to take screen captures/grabs and prepare them for being placed in a 720p project? Thanks.