cancel
Showing results for 
Search instead for 
Did you mean: 

restricted resource set

Former Member
0 Kudos

Hi !

I am struglling a while with Hibernate DB schema auto-creation in SAP NetWeaver SE 7.1.

I am managing Hibernate (3.3.2) Entities with help of Stateless EJB.

Everything seems to be ok, until my entities are processed per annotations at system set up time.

I get this Exception allover log files:

-


ResourceException occurred in method ConnectionFactoryImpl.getConnection(): com.sap.engine.services.connector.exceptions.BaseResourceException: Cannot get connection. Reason: the thread of component "ejbContexts/sap.com/PROJECT/XXX.jar/ManagerBean" in application "sap.com/PROJECT" is currently associated with a restricted resource set and it is not allowed to get connection within it.

-


Related exception :

13503561 [HTTP Worker [3]] ERROR org.hibernate.tool.hbm2ddl.SchemaExport - schema export unsuccessful 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/sap.com/PROJECT/XXX.jar/ManagerBean" in application "sap.com/PROJECT" is currently associated with a restricted resource set and it is not allowed to get connection within it.

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.tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.prepare(SuppliedConnectionProviderConnectionHelper.java:51)

at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:252)

at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:211)

at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:353)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1341)

at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)

at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)

at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:132)

....

-


For schema auto generation I am using <property name="hibernate.hbm2ddl.auto" value="create-drop"/> in persistence.xml

Connection is tried to set up at systems start-up time where no link between DataSource and bean schould be made(in my opinion).

IMPORTANT

When application invokes beans business method, which accesses EntityManager to find Persisted Entities, there is no "restricted resource set" Exceptions anymore - Hibernate simply cannot find related table (it was not auto-generated)

Any ideas, why Hibernate auto-generation could cause such Exception ?

Edited by: Aziris on Jan 17, 2011 7:12 PM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

I had in mind, that hibernate.hbm2ddl.auto SchemaExport process has nothing to do with EJB context...

Now I realise that it realy does !

SAP NetWeaver CE 7.1 Exports Schema by LAZY principles - only on first demand, and that appears to be in a Stateless Session Beans, initialization phase.

Stateless session beans really cannot create any resource connections outside business method boundaries (i.e at initialization stage).

A Statefull Session bean could make resource connections at initialization stages ? Am I right or not ?

That would mean - you cannot use schema auto-generation if your first access is to Stateless bean ?

I am having issues to use Statefull form of session bean, because it appears somehow not inserted into JNDI context... hmm

Maybe it is related to same problem differently - bean failed "harder" on SchemaExport than stateless bean ?

There is absolutely no evidence of Exceptions in logs, when Statefull bean is used... as this bean never existed.

I am going to try some more to bring Stateful beans to life.

P.S.

Statefull bean is visible in JNDI as far as I dont put @PersistenceContext in it.

But it does not do what it is inteded for, of course.

Former Member
0 Kudos

I found out terrible mistake in my web.xml and faces-config.xml files (wrong references to older XSD files) which caused some other problems for me, like @EJB was not working, etc..

Unfortunately this does not solve SchemaExport problems.

Is there anyone, who has seen <property name="hibernate.hbm2ddl.auto" value="create-drop"/> to work on SAP NetWeaver 7.1 CE at all ?

Maybe other version of Hibernate or some way to change initialisation mechanism on NW AS ? Why Hibernate cannot be initialized fully at start-up time ?

rolf_paulsen
Active Participant
0 Kudos

Hi,

you may try to add

<property name="transaction.manager_lookup_class">org.hibernate.transaction.SAPWebASTransactionManagerLookup"/>

and/or

<property name="hibernate.transaction.factory_class" value="org.hibernate.transaction.JTATransactionFactory"/>

in persistence xml and integrate this class into your app:

package org.hibernate.transaction;
public class SAPWebASTransactionManagerLookup
extends org.hibernate.transaction.JNDITransactionManagerLookup {
protected String getName() {
return "TransactionManager";
}
public String getUserTransactionName() {
return "UserTransaction";
}
}

Cheers,

-Rolf

Former Member
0 Kudos

Thanks Rolf,

but that class is already imported in separate jar together with HARD-ref Hibernate libraries and the property in persistance.xml is set accordingly.

This does not seems to be the problem.

Does your Hibernate SchemaExporter works on NetWeaver ?

If yes, which version of Hibernate are you using ?

Cheers !