Re: [jboss-user] [jBPM] - JBPM 4.3 or 4.4 and LocalContainerEntityManagerFactoryBean
by Caine Lai
Caine Lai [http://community.jboss.org/people/unsavory] replied to the discussion
"JBPM 4.3 or 4.4 and LocalContainerEntityManagerFactoryBean"
To view the discussion, visit: http://community.jboss.org/message/556989#556989
--------------------------------------------------------------
Hi HuiSheng,
Thanks again for your help!
if you wish to get the hibernate session factory from the EntityManagerFactory using Java code, you would do:
public static SessionFactory getSessionFactory(EntityManagerFactory emf) {
if (emf == null) {
return null;
}
HibernateEntityManagerFactory hemf = (HibernateEntityManagerFactory) emf;
return hemf.getSessionFactory();
}
However, in Spring it is easy to retrieve a sessionFactory from the underlying entitymanagerfactory like so:
<!-- JPA EntityManagerFactory -->
<bean id="entityManagerFactory">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean>
<property name="showSql" value="${jpa.showSql}" />
<property name="database" value="${jpa.database}" />
</bean>
</property>
<property name="jpaDialect">
<bean />
</property>
<property name="jpaPropertyMap">
<map>
<!-- Database Configuration -->
<entry key="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect" />
<entry key="hibernate.hbm2ddl.auto" value="${hibernate.hbm2ddl.auto}" />
<entry key="hibernate.format_sql" value="false" />
<entry key="hibernate.use_sql_comments" value="true" />
<entry key="hibernate.default_batch_fetch_size" value="50" />
<entry key="hibernate.order_updates" value="true" />
<!-- Cache Configuration -->
<!-- <entry key="hibernate.cache.provider_class" value="net.sf.ehcache.hibernate.SingletonEhCacheProvider" /> -->
<!-- <entry key="net.sf.ehcache.configurationResourceName" value="ehcache.xml" /> -->
<entry key="hibernate.cache.use_second_level_cache" value="false" />
<entry key="hibernate.cache.use_query_cache" value="false" />
<!-- Transaction Management -->
<!-- <entry key="hibernate.current_session_context_class" value="org.hibernate.context.ThreadLocalSessionContext" /> -->
<entry key="hibernate.current_session_context_class" value="org.springframework.orm.hibernate3.SpringSessionContext" />
<!-- Hibernate Search -->
<!-- <entry key="hibernate.search.default.directory_provider" value="false" />
<entry key="hibernate.search.default.indexBase" value="C:/Temp/hibernate_test_indexes" />
<entry key="hibernate.search.default.batch.merge_factor" value="10" />
<entry key="hibernate.search.default.batch.max_buffered_docs" value="10" />
<entry key="hibernate.search.default.optimizer.operation_limit" value="500" />
<entry key="hibernate.search.default.optimizer.transaction_limit.max" value="100" /> -->
</map>
</property>
<!-- Custom implementation to enrich the PersistenceUnitInfo read from the persistence.xml
JPA configuration file with the JTA datasource. specifying the JTA datasource directly in
the Spring configuration file has the advantage that we can use a direct reference to the
datasource instead of using a JNDI name as requied by the jta-data-source setting in the
persistence.xml file -->
<property name="persistenceUnitPostProcessors">
<bean>
<property name="jtaDataSource" ref="dataSource" />
</bean>
</property>
<property name="loadTimeWeaver">
<bean />
</property>
</bean>
<bean id="sessionFactory" factory-bean="entityManagerFactory" factory-method="getSessionFactory" />
The sesssion factory returned by this method will be of type HibernateSessionFactory.
Does this help?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/556989#556989]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months
Re: [jboss-user] [JBoss Web Services] - [JBoss 6.0.0M3] Cannot use @EJB on jax-ws handler and webservice port
by Olaf Bergner
Olaf Bergner [http://community.jboss.org/people/O.Bergner] replied to the discussion
"[JBoss 6.0.0M3] Cannot use @EJB on jax-ws handler and webservice port"
To view the discussion, visit: http://community.jboss.org/message/556964#556964
--------------------------------------------------------------
I tried to debug the issue, alas without much luck. What puzzles me though when looking at the method
protected String findWithin(DeploymentUnit du, DeploymentUnit excludeChild, EjbReference reference)
{
String jndiName = find(du, reference);
if(jndiName != null)
return jndiName;
List<DeploymentUnit> children = du.getChildren();
if(children != null)
{
for(DeploymentUnit child : children)
{
// already searched that one
if(child == excludeChild)
continue;
jndiName = findWithin(child, null, reference);
if(jndiName != null)
return jndiName;
}
}
DeploymentUnit parent = du.getParent();
if(parent != null)
return findWithin(parent, du, reference);
return null;
}
is the question how it is supposed to work. Let's say we have
app.ear
|
-- ejb1.jar
|
-- ejb2.jar
|
-- ejb3.jar
ejb1.jar contains an artifact referencing a session bean that resides in ejb3.jar. If I understand the code above correctly - and this is a BIG if - what will happen is what follows:
1. We start searching in ejb1.jar.
2. We try to find the referenced session bean in ejb1.jar itself. This fails.
3. We try to find the referenced session bean in one of ejb1.jar's children. There are no such children, so this fails, too.
4. We try to find the referenced session bean in ejb1.jar's parent, i.e. app.ear, telling this parent to exclude the current deployment unit, i.e. ejb1.jar.
5. We try to find - since app.ear itself does not contain any session beans - the referenced session bean in the list of app.ear's children minus ejb1.jar, i.e. [ejb2.jar, ejb3.jar].
6. Since ejb2.jar does not contain the referenced session bean either, we end up repeating steps 2 - 4, with ejb1.jar replaced by ejb2.jar.
7. We try to find the referenced session bean in the list of app.ear's children minus ejb2.jar, i.e. [ejb1.jar,ejb3.jar]. And now we are in trouble, since ...
8. We repeat steps 1 - 7 until we run out of stack space.
Could it be that the above algorithm only succeeds if
1. the number of children to app.ear is not greater than two OR
2. the referenced session bean resides in the same deployment unit as the referencing artifact OR
3. the referenced session bean resides in the deployment unit immediately following - from app.ear's perspective - the deployment unit containing the referencing artifact (ejb2.jar in our example)?
At least this seems to be implied by a casual analysis of the code above. But then again, I may be wrong and it's rather a problem in my code.
Cheers,
Olaf
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/556964#556964]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months
Re: [jboss-user] [EJB 3.0 Development] - Deferring instance creation/injection to CDI
by Marius Bogoevici
Marius Bogoevici [http://community.jboss.org/people/marius.bogoevici] replied to the discussion
"Deferring instance creation/injection to CDI"
To view the discussion, visit: http://community.jboss.org/message/556962#556962
--------------------------------------------------------------
>
> > Marius Bogoevici wrote:
> >
> > 2) EJB container provides a hook for preprocessing interceptors after instantiation. The main reason is that EJB interceptors may be CDI-injected
> > (note: could we reuse the same mechanism as for EJB instantiation, since it boils down to producing an instance of the class? )
>
> I'm pretty sure we could do this too. We have this bit of code, though I haven't verified if it's currently used or cruft:
>
>
> *public* Object createInterceptor(Class<?> interceptorClass) *throws* InstantiationException, IllegalAccessException
> {
> Object instance = interceptorClass.newInstance();
> InterceptorInjector interceptorInjector = interceptorInjectors.get(interceptorClass);
> *assert* interceptorInjector != *null* : "interceptorInjector not found for " + interceptorClass;
> interceptorInjector.inject(null, instance);
> *return* instance;
> }
>
>
>
>
>
>
> Plenty of room in there to both abstract away the instantiation or give some post-instantiation callback before the instance is returned.
>
>
>
This looks good, and I see that is currently being used for @Resource injection in the least. The main challenge seems to be that interceptorInjectors is encapsulated and initialized inside org.jboss.ejb3.EJBContainer.
I am wondering if we could provide a mechanism similar to the instantiator for passing a custom interceptor injector at deployment time.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/556962#556962]
Start a new discussion in EJB 3.0 Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months
[jBPM] - Process fails to deploy
by Ivan Pazmino
Ivan Pazmino [http://community.jboss.org/people/iapazmino] created the discussion
"Process fails to deploy"
To view the discussion, visit: http://community.jboss.org/message/556961#556961
--------------------------------------------------------------
I'm trying to deploy a simple process in a jbpm 3.2 installation over jboss 4.2 and an oracle 10g db.
the jbpm tables are empty, since this should be the first process. I have designed a small process with the eclipse's gpd plug in. when I try deploying it an exception is thrown at the server's log complaining it can't find the process definition for tester, which is the name I gave to the test process.
13:19:31,970 ERROR [ProcessUploadServlet] Failed to deploy process tester org.jbpm.JbpmException: could not find process definition 'tester'
...
an blames the failure to a malformed sql command
Caused by: org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
...
Caused by: java.sql.SQLException: ORA-00933: SQL command not properly ended
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
...
before this exception is thrown the failing query is
13:19:31,963 INFO [STDOUT] Hibernate:
/* named HQL query GraphSession.findLatestProcessDefinitionQuery */ select
processdef0_.ID_ as ID1_4_,
processdef0_.NAME_ as NAME3_4_,
processdef0_.DESCRIPTION_ as DESCRIPT4_4_,
processdef0_.VERSION_ as VERSION5_4_,
processdef0_.ISTERMINATIONIMPLICIT_ as ISTERMIN6_4_,
processdef0_.STARTSTATE_ as STARTSTATE7_4_
from
JBPM_PROCESSDEFINITION processdef0_
where
processdef0_.NAME_=?
order by
processdef0_.VERSION_ desc limit ?
13:19:31,970 WARN [JDBCExceptionReporter] SQL Error: 933, SQLState: 42000
13:19:31,970 ERROR [JDBCExceptionReporter] ORA-00933: SQL command not properly ended
this query won't return any values because the JBPM_PROCESSDEFINITION table is empty, but it complains on the query. any configuration I'm missing?
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/556961#556961]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months
Re: [jboss-user] [jBPM] - JBPM 4.3 or 4.4 and LocalContainerEntityManagerFactoryBean
by Caine Lai
Caine Lai [http://community.jboss.org/people/unsavory] replied to the discussion
"JBPM 4.3 or 4.4 and LocalContainerEntityManagerFactoryBean"
To view the discussion, visit: http://community.jboss.org/message/556958#556958
--------------------------------------------------------------
Hi HuiSheng,
I appreciate the response. Here's the thing. The real problem lies in that JBPM assumes you are using a LocalSessionFactoryBean and specifically looks for one with the Spring configuration.
However, it is possible to retrieve the underlying hibernate session factory from Spring's LocalContainerEntityManagerFactoryBean. It's just that JBPM does not support this because it assumes you are using a LocalSessionFactoryBean.
I understand that JBPM needs to use hibernate and is using the org.hibernate.Session to access the database, but what I don't understand is why it requires the use of the Spring LocalSessionFactoryBean, when there are multiple other ways of configuring a hibernate session factory.
I saw some old forum posts about the ability to inject the session factory into the JBPM context using the session-factory attribute in jbpm.config.xml, but again it does not work because it is not of type LocalSessionFactoryBean.
This is a serious issue for anyone using JPA. It basically means if you are using JPA you cannot use JBPM without resorting to some major hacking. It is a shame that JBPM has chosen to abandon JPA users as this is the Java spec! It's fine if JBPM wishes to use hibernate underneath, but there should at least be some way of providing the hibernate session to JBPM from the JPA entitymanager.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/556958#556958]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
15 years, 8 months