on 06-08-2009 10:57 AM
I get the following error:
Caused by: com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot get connection. Reason: the thread of component "ejbContexts/.../TreeHolderBean" in application "..." is currently associated with a restricted resource set and it is not allowed to get connection within it.
I get this from a Web Dynpro application, that references an EJB application through local interface, the EJB wants to connect to Database through a stateful session bean.
No idea what that means... Any help?
Thx,
Frank
How is the connection being established? Via data source alias?
BR, Sergei
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It was a stupid mistake from my site.
I instantiated a resource via the statement in the declaration of a private variable inside a stateless Session Bean. Like
private Resource myRes = new Resource();
Inside that "new Resource()" somewhere the DB connection was made. That will naturaly not work. I put that statement in the business method and voila it worked.
Thx for your time and help anyway
Frank
Hi all,
i get a very similar exception:
"ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot get connection. Reason: the thread of component 'ejbContexts/JavaEE/.../<StatelessBean>' in application 'JavaEE/<app>' is currently associated with a restricted resource set and it is not allowed to get connection within it."
We declared the data source & an data source alias in separate data-sources.xml and data-source-aliases.xml files in the META-INF folder and the above stated error occures during write operations. As background: we use Hibernate as persistence provider and a TableGenerator based GeneratedValue for the associated object ID, declared via annotations in the ejb 3 project.
any help is very appreciated!
Arne Hildebrand
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Frank,
thanks for the reply. The getConnection() call is outside of my control. My stack trace is:
caused by: org.hibernate.exception.JDBCConnectionException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:97)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:590)
at org.hibernate.engine.transaction.Isolater$JtaDelegate.delegateWork(Isolater.java:127)
at org.hibernate.engine.transaction.Isolater.doIsolatedWork(Isolater.java:64)
at org.hibernate.engine.TransactionHelper.doWorkInNewTransaction(TransactionHelper.java:74)
at org.hibernate.id.MultipleHiLoPerTableGenerator.generate(MultipleHiLoPerTableGenerator.java:210)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:122)
at org.hibernate.ejb.event.EJB3MergeEventListener.saveWithGeneratedId(EJB3MergeEventListener.java:43)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:238)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:170)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:81)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:704)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:688)
at org.hibernate.impl.SessionImpl.merge(SessionImpl.java:692)
at org.hibernate.ejb.AbstractEntityManagerImpl.merge(AbstractEntityManagerImpl.java:235)
... 161 more
Caused by: com.sap.engine.services.dbpool.exceptions.BaseSQLException: ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Error in ResourceSet.addAndEnlist("com.sap.engine.services.connector.resource.impl.HandleWrapper@45a9bf[com.sap.engine.services.dbpool.cci.DirectConnectionHandle@3cfe4](delisted:true) -> com.sap.engine.services.connector.resource.impl.MCEventHandler@18b69ec --> 29(locTrSupp:true)").
at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:59)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46)
at org.hibernate.jdbc.AbstractBatcher.openConnection(AbstractBatcher.java:587)
... 174 more
Caused by: com.sap.engine.services.connector.exceptions.BaseResourceException: Error in ResourceSet.addAndEnlist("com.sap.engine.services.connector.resource.impl.HandleWrapper@45a9bf[com.sap.engine.services.dbpool.cci.DirectConnectionHandle@3cfe4](delisted:true) -> com.sap.engine.services.connector.resource.impl.MCEventHandler@18b69ec --> 29(locTrSupp:true)").
at com.sap.engine.services.connector.jca.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:339)
at com.sap.engine.services.connector.jca.ShareableConnectionManager.allocateConnection(ShareableConnectionManager.java:54)
at com.sap.engine.services.dbpool.cci.ConnectionFactoryImpl.getConnection(ConnectionFactoryImpl.java:51)
... 176 more
Caused by: javax.transaction.SystemException: Due to internal problems component which is currently working into the thread is associated with wrong transaction. Check trace files for other problems.
at com.sap.engine.services.connector.resource.impl.ResourceSetImpl.addAndEnlist(ResourceSetImpl.java:304)
at com.sap.engine.services.connector.jca.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:336)
... 178 more
And after invetigating the log files if found:
ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot get connection. Reason: the thread of component 'ejbContexts/JavaEE/hai-ear-1.2-SNAPSHOT/hai-ejb.jar/ProjectDaoImpl' in application 'JavaEE/hai-ear-1.2-SNAPSHOT' is currently associated with a restricted resource set and it is not allowed to get connection within it.
so if have no clue how to get things to work or where i can configure the resource access rights.Any ideas?
thanks, Arne
Hi Arne,
its nothing about configuration you are facing here. Somewhere in your Bean you allocate the Hibernate resources. Inside this the "getConnection" is called.
Check where you do this, its possibly the wrong place. Its a part of the EJB Spec where you can do this. You said you use a stateless session bean, so the only place to allocate resources is a business method. You can keep the allocated hibernate resources in an instance variable of course an reuse it next time the session bean is called.
Frank
Hi Frank,
thanks for your answer. IMHO Hibernate will do this transparently (obtain connections & stuff around). Anyhow - i am going to refactor our app in order to avoid using hibernate in favor to the extisting persistence provider. I have still some trouble with it but i will open another thread therefore.
Best, Arne
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.