Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Local transaction and non-XA resource

okmich-JavaNetMar 27 2008 — edited Mar 31 2008
I have an issue with a stateless bean that is being called by a timer service. Because I am moving data from an old system to a new system on a scheduled basis..
      @Resource(name="jdbc/accountConnection")
    private DataSource dataSource;
    
    @PersistenceContext(unitName="agencyPU")
    private EntityManager entityManager;
the datasource connects to the old with the entityManager is configured for the new system.
Now I have a method that does the transfer like this.
      @TransactionAttribute(TransactionAttributeType.REQUIRED)
    public void retrieveAgentRecordsFromHR() {
        try {
            PreparedStatement preparedStatement = connection.prepareStatement(SELECT_QUERY);
            ResultSet rs = preparedStatement.executeQuery();
            List<HRAgent> list = retrieveObjectFromResultSet(rs);
            System.out.println("list size " + list.size());
                    for (HRAgent hrAgent : list){
                          entityManager.merge(hrAgent);
                    }
        } catch (SQLException ex) {
            ex.printStackTrace();
        }
    }
the issue is that whenever the method is called, it throws an exception thus (from server.log):
[#|2008-03-27T11:06:27.201-0700|WARNING|sun-appserver9.1|javax.enterprise.resource.resourceadapter|_ThreadID=20;_ThreadName=p: thread-pool-1; w: 3;_agencyPool;java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources.  ;_RequestID=deffae31-e812-4866-86e9-62f9f6bfbcc8;|RAR5117 : Failed to obtain/create connection from connection pool [ _agencyPool ]. Reason : java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources.  |#]

[#|2008-03-27T11:06:27.201-0700|WARNING|sun-appserver9.1|javax.enterprise.resource.resourceadapter|_ThreadID=20;_ThreadName=p: thread-pool-1; w: 3;Error in allocating a connection. Cause: java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources.  ;_RequestID=deffae31-e812-4866-86e9-62f9f6bfbcc8;|RAR5114 : Error allocating connection : [Error in allocating a connection. Cause: java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources.  ]|#]

[#|2008-03-27T11:06:27.201-0700|WARNING|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/Sun/AppServer/domains/leadwayportal/applications/j2ee-apps/agency_app/agency_jar/-agencyPU|_ThreadID=20;_ThreadName=p: thread-pool-1; w: 3;_RequestID=deffae31-e812-4866-86e9-62f9f6bfbcc8;|
Local Exception Stack: 
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: java.lang.IllegalStateException: Local transaction already has 1 non-XA Resource: cannot add more resources.  
Error Code: 0
Call: SQLCall(INSERT INTO HR_AGENT (STAFF_NUMBER, BRANCH_CODE, EMAIL, LAST_NAME, ADDRESS_LINE_1, FIRST_NAME, ADDRESS_LINE_2, PHONE_NUMBER, EMPLOYMENT_DATE) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?))
what does the statement "Local transaction already has 1 non-XA Resource: cannot add more resources. " mean ??
what could the problem really be here?


Regards,
Michael
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 28 2008
Added on Mar 27 2008
5 comments
3,453 views