[JBoss jBPM] - Strange problem calling TaskInstance.end [could not initiali
by bloreguy
I am using Jbpm + Hibernate on MSSQL Server and see this error frequently. Sometimes, I am able to run without any problems. Any help in understanding and fixing this issue will be deeply appreciated.
10:29:29,947 WARN [JDBCExceptionReporter] SQL Error: 0, SQLState:
HYT00
10:29:29,951 ERROR [JDBCExceptionReporter] The query has timed out.
10:29:29,956 ERROR [BatchSearchAction] Error in assigning all docs
message:could not initialize a collection: [org.jbpm.taskmgmt.exe.TaskInstance.variableInstances#767]
10:29:29,970 INFO [BatchSearchAction] Exception:
org.hibernate.exception.GenericJDBCException: could not initialize a collection:
[org.jbpm.taskmgmt.exe.TaskInstance.variableInstances#767]
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException
(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.j
ava:91)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelp
er.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2001)
at org.hibernate.loader.collection.CollectionLoader.initialize(Collectio
nLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initia
lize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onIn
itializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:
1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(Abst
ractPersistentCollection.java:344)
at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPe
rsistentCollection.java:86)
at org.hibernate.collection.PersistentMap.values(PersistentMap.java:234)
at org.jbpm.taskmgmt.exe.TaskInstance.submitVariables(TaskInstance.java:
135)
at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:458)
at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:418)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147061#4147061
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147061
17 years, 11 months
[EJB 3.0] - Re: LazyInitializationException in many-to-many relation tha
by JuliaF
Hello, jaikiran
Many thanks for posting the tip. I fixed the LazyInitialisationException problem in this instance. However, I think I am facing a much more general EJB design problem, which I will try to explain further down.
With regards to the earlier posting, in addition to using merge() before persist(), as you helpfully suggested, I also had to add this:
@TransactionAttribute(TransactionAttributeType.REQUIRED)
| public void addPublicSubject(Subject s, User u) {
|
| User u = entityManager.merge(user);
| Subject s = entityManager.merge(subject);
|
| u.getSubjectsThisUserSubscribedTo().add(s);
| s.getUsersThatSubscribedToMe().add(u);
|
| entityManager.persist(u);
| entityManager.persist(s);
|
| }
|
Thus, it updates the relationship table (shared_subject in this case)
In addition I modified findSubject(int subjectId) of session bean SubjectBean as follows
| @TransactionAttribute(TransactionAttributeType.REQUIRED)
| public Subject findSubject(int subjectId) {
| Subject s = (Subject)entityManager.find(Subject.class, subjectId);
|
| s.getOwner();
| s.getUpdater();
| Collection<Topic> temp_topics= s.getMyTopics();
| if(!temp_topics.isEmpty()) temp_topics.size();
| Set<User> temp_users = s.getUsersThatSubscribedToMe();
| if(!temp_users.isEmpty()) temp_users.size();
| return s;
| }
|
because I read in one of the tutorials that all relationships must be managed explicitly in the transactional code.
That is if we want the client to have access to the cmr fields of the Subject they must be pre-fetched within the transaction by executing seemingly useless statements like collectionXXX.size() or s.getOwner() even though we donÃÂÃÂÃÂÃÂt assign the result of such statements to anything and donÃÂÃÂÃÂÃÂt use it within the transaction.
EJB design problem:
So, to avoid LasyInitialisationException CMR Fields first have to be accessed in the transactional context of a session bean in order to be loaded into the Entity Bean
Suppose, I have a bean User with the following CMR fields:
| Set<Subject> mySubjects;
| Set<Topic> topicsThisUserCreated;
| Set<Entry> entriesThisUserAuthored;
| Set<Topic> topicsThisUserUpdated;
| Set<Topic> entriesThisUserUpdated;
| Set<Subject> subjectsThisUserSubscribedTo;
|
Respectively each object in each collection has CMR fields
|
| Subject:
| User owner;
| User updater;
| Collection<Topic> myTopics;
| Set<User> usersThatSubscribedToMe;
| Topic:
| User creator;
| User updater;
| Subject subject;
| Topic parentTopic;
| private Collection<Topic> nestedTopics;
| private Set<Entry> entries;
|
| Entry:
| private Topic topic;
| private User author;
| private User updater;
| Plus entry has a field:
| private String entryBody; which is @Lob
|
When User is accessed in the detached context (somewhere in the client) technically speaking it is possible that the client will call something like:
| public void buildOutput(User user, Output out){
| User u = user;
| Set<Subject> ss = u.getSubjectsUserSubscribedTo();
| for(subject:ss) {
| Set<Topic> tt = subject.getMyTopics();
| for(topic:tt) {
| outputTopic(topic, u, out);
|
| }
| }
| public void outputTopic(Topic topic, User u, out) {
|
| if(topic.getParent()!=null) outputTopic(topic.getParent(), u, out);
| out.setElemet(ÃÂÃÂTopic.class.getName());
| out.add(topic.getName);
| out.add(topic.getCreator().getUserName());
| out.add(topic.getUpdater().getUserName();
| out.add(topic.getCreator().getTopicsThisUserUpdated().size());
| Set<Entry> ee = topic.getEntries();
| for(entry:ee){
| out.setElement(Entry.class.getName()ÃÂÃÂ);
| out.add(entry.getName();
| out.add(entry.getAuthor().getUserName());
| out.add(entry.getBody());
| }
| }
|
|
I donÃÂÃÂt think it will work because LazyInitializationException can be thrown in the dozens of places in this snippet of code.
This poses a design issue:
The getters and setters of CMR fields must be public so that the EJB container could manage them.
If they are public the client has access to them in the detached context, but to avoid Lazy Loading Exception they have to be set and accessed in the transactional context of a session bean.
My understanding is that EJB3 disposed of the Data Transfer and Data Access objects in order to simplify the EJB model and instead introduced the notion of the detached context in which Data Access objects (User, Subject, Topic, Entry in this case) act as Data Transfer Objects as far as client is concerned. However, LazyInitializationException will always be on the way in this model.
So, the question is how can we ensure that the client doesnÃÂÃÂt access CMR fields outside of transactional context from the design point of view?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147060#4147060
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147060
17 years, 11 months
[JBoss/Spring Integration] - Unable to lookup datasource in jboss 4.2.2 with spring 2.0.8
by suneetshah
ello,
I have trying to use the datasource in my JBoss 4.2.2 server, but I am getting the error below. I have tried a number of permutations on the jndi name in the applicationcontext.xml file, but none seem to work.
Any suggestions would be greatly appreciated.
My jboss xxxDS.xml file look like:
<local-tx-datasource>
| <jndi-name>oracleDS</jndi-name>
My applicationcontext.xml has the following value:
| <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
| <property name="jndiName">oracleDS</property>
|
| </bean>
|
I have also tried:
java:OracleDS
java:/oracleDS
All of them result in the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is javax.naming.NameNotFoundException: oracleDS not bound
| Caused by:
| javax.naming.NameNotFoundException: oracleDS not bound
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:529)
| at org.jnp.server.NamingServer.getBinding(NamingServer.java:537)
| at org.jnp.server.NamingServer.getObject(NamingServer.java:543)
| at org.jnp.server.NamingServer.lookup(NamingServer.java:296)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
| at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
| at javax.naming.InitialContext.lookup(InitialContext.java:351)
| at org.springframework.jndi.JndiTemplate$1.doInContext(JndiTemplate.java
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4147056#4147056
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4147056
17 years, 11 months