[jBPM] - JBPM 4.3: Is it possible to leave current state on timer listener?
by Nugroho Saputro
Nugroho Saputro [http://community.jboss.org/people/nsaputro] created the discussion
"JBPM 4.3: Is it possible to leave current state on timer listener?"
To view the discussion, visit: http://community.jboss.org/message/536790#536790
--------------------------------------------------------------
Hi All,
Please help me, I am newbie at JBPM 4.x. I have a problem with leaving a state programmatically in timer listener. I always get exception like this:
12 Apr 2010 11:21:11 ERROR org.jbpm.pvm.internal.cmd.ExecuteJobCmd - exception while executing 'timer[30|2010-04-12 11:21:11,412|timeout]'
org.jbpm.api.JbpmException: execution[ADSLProvisioning.22] is not active: inactive-scope
at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1024)
at org.jbpm.pvm.internal.model.ExecutionImpl.take(ExecutionImpl.java:466)
at org.jbpm.pvm.internal.model.ExecutionImpl.takeDefaultTransition(ExecutionImpl.java:449)
at uk.co.upshot.jbpm.handler.OrderStatusChecker.notify(OrderStatusChecker.java:62)
at org.jbpm.pvm.internal.wire.usercode.UserCodeEventListener.notify(UserCodeEventListener.java:39)
What I would like to do is checking status from database repeatedly every X minutes. When it found certain status e.g. COMPLETED it should go to the next state, otherwise it will repeat until that status is reached.
Currently I implement it as a state with a repeated timer:
<state name="Check Order Status">
<on event="timeout">
<timer duedate="10 minutes" repeat="10 minutes"></timer>
<event-listener expr="#{OrderStatusChecker}"></event-listener>
</on>
<transition name="to-status-decision" to="status-decision"></transition>
</state>
and on the timer listener:
public class OrderStatusChecker implements EventListener {
public void notify(EventListenerExecution event) throws Exception {
// Check status.
String status = ...... get status from Database ...
event.getProcessInstance().setVariable("status", status);
if (status.equals("COMPLETED")) {
// Leave current state
ActivityExecution execution = (ActivityExecution) event.getParent();
execution.takeDefaultTransition();
}
}
}
Is it possible to do that in JBPM? If it's not possible, is there any workaround for my case?
I use JBPM4.3 with spring 2.5.
Thank you.
Regards,
Nugroho
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536790#536790]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
[JBoss Web Services] - Need Help -- Exception Mapper for http exception does not work resteasy
by Ananta Amalkar
Ananta Amalkar [http://community.jboss.org/people/a_ananta] created the discussion
"Need Help -- Exception Mapper for http exception does not work resteasy"
To view the discussion, visit: http://community.jboss.org/message/536787#536787
--------------------------------------------------------------
Hi:
I'm implementing exception mapper so taht my application will throw approriate http error code.
here is my implementation:
1. MyRestApplication.java
public class MyRestApplication extends Application{
private Set<Object> singletons = new HashSet<Object>();
private Set<Class<?>> classes = new HashSet<Class<?>>();
public MyRestApplication() {
classes.add(MyRestEasyExceptionMapper.class);
classes.add(UnauthorizedExceptionMapper.class);
}
@Override
public Set<Class<?>> getClasses() {
return classes;
}
/**
* Return a set of rest easy implementation classes.
*/
@Override
public Set<Object> getSingletons() {
return singletons;
}
}
2. UnauthorizedExceptionMapper.java
@Provider
public class UnauthorizedExceptionMapper implements ExceptionMapper<UnauthorizedException> {
public Response toResponse(UnauthorizedException e)
{
return Response.status(Status.UNAUTHORIZED)
.entity(e)
.build();
}
}
3. MyRestEasyExceptionMapper.java
@Provider
public class MyRestEasyExceptionMapper implements ExceptionMapper<RuntimeException>{
private @Context Providers providers;
@SuppressWarnings("unchecked")
public Response toResponse(RuntimeException exception)
{
if (exception.getCause() == null)
{
return Response.serverError().build();
}
Class cause = exception.getCause().getClass();
ExceptionMapper mapper = null;
try{
mapper = providers.getExceptionMapper(cause);
}catch(Exception e){
System.out.println(e);
}
if (mapper == null)
{
return Response.serverError().build();
}
else
{
return mapper.toResponse(exception.getCause());
}
}
}
I have registred the mappers using MyRestApplication. My method throws "org.jboss.resteasy.spi.UnauthorizedException", which is wrapped up by RuntimeException, like:
Class A{
method a() thorws RuntimeException{
Class B b = new B();
b.validateAccess();
}
Class B{
method validateAccess() throws UnauthorizedException{
try{
// validate access
}Catch(RuntimeException e){
throw new UnauthorizedException(e.getMessage(), e);
}
}
}
It works well till it gets to find the MyRestEasyExceptionMapper. When control goes inside toResponse method of MyRestEasyExceptionMapper,
I can see the Class cause = exception.getCause().getClass(); is UnauthorizedException, which is correct.
So it means, the cause of the RuntimeException is unauthorisedexception, but then it can not find the mapper for this unauthorisedexception.
mapper = providers.getExceptionMapper(cause); this comes as null.
I'm not able to figure out what is wrong here?
For RuntimeException, it finds the correct mapper, but then from the mapper class of runtimeexception, it can not find the mapper for unauthorisedexception.
Any help will be highly appreciated here.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536787#536787]
Start a new discussion in JBoss Web Services at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
[JBoss Cache] - working with jboss cache
by Venkatesh Balaji
Venkatesh Balaji [http://community.jboss.org/people/venquet] created the discussion
"working with jboss cache"
To view the discussion, visit: http://community.jboss.org/message/536779#536779
--------------------------------------------------------------
Dear All,
I have below implementation with jboss cache, swing client is the user interface for our application and it talks to jboss server with help of apache webserver connected through ajp connector with loadbalancing, my requirement is i want to maintain some data when user has been succesfully authenticated, i will not be able to maintain in http-session, since our application has more no. of WAR. My idea is to put this data into jboss cache once the user authenticated, my loadbalance is without stickysession so request will be put into both apps from the same user, so enabling cluster would be right option.
Made the jboss-cache clustering setup and tested through jmx-console with repl-async mode and works perfectly.
Now my question is, how to implement this to put my data into cache when user has got succesful authentication (in short how to put this in jboss-cache in servlet) and need to retrieve back to validate and update the last request time. Please advise whether this can be implemented with jboss cache.
Thanks in advance.
Rgds
Balaji
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536779#536779]
Start a new discussion in JBoss Cache at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
[jBPM Development] - Injected hibernate SessionFactory is not used by jBPM 4.3?
by Guido Helmers
Guido Helmers [http://community.jboss.org/people/helmers] created the discussion
"Injected hibernate SessionFactory is not used by jBPM 4.3?"
To view the discussion, visit: http://community.jboss.org/message/536777#536777
--------------------------------------------------------------
Hi there,
I'm using jBPM 4.3 and I want jBPM to use my own SessionFactoryImpl object, instead of creating its own. I'm doing the following to inject my SessionFactory into jBPM:
new Configuration().setResource("jbpm/jbpm.cfg.xml").setHibernateSessionFactory(hibernateSessionFactory).buildProcessEngine();
But jBPM ignores what I pass in, and creates its own SessionFactory.
Does anyone know what I should do to make this work? Is there an additional jBPM configuration property that I need to set? Could it be a bug in jBPM?
I've attached a Maven project that you can use to debug this problem. I'll explain how you can debug it to see what's going wrong. If you want to know about the project structure (not really required to debug the jbpm problem), read the section at the end of this mail.
Cheers,
Guido
+Note: We're using Guice for dependency injection; dependencies are configured in the *Module classes. Warp-persist is used for transaction management in Guice. I'm not sure if guice and warp-persist are in the central maven repos, so I've put those libraries in the lib folder.+
h3.
How to debug
Import the maven project in your IDE.
(In Eclipse: mvn clean eclipse:clean eclipse:eclipse -Declipse.useProjectReferences=true -DdownloadSources=true -DdownloadJavadocs=true
You may have to install the guice libraries in your local maven repository. Do a "mvn clean compile" to check whether the project is complete).
Put a break point on the following lines / methods (basically everything in the code base related to a hibernate SessionFactory):
1. My code:1. JbpmLayerModule.provideProcessEngine()
2. jBPM code:1. ConfigurationImpl.setHibernateSessionFactory(Object)
2. HibernateSessionDescriptor.construct(WireContext)
3. HibernateSessionFactoryDescriptor.construct(wireContext)
Now run IssueServiceIntegrationTest.testCreate() in debug mode. On the above breakpoints, you'll see information similar to the following:
*[1.1]* hibernateSessionFactory=org.hibernate.impl.SessionFactoryImpl@5c6c0a(id=92)
*[2.1]* processEngineWireContext=WireContext "process-engine"(id=112)
*[2.2]* [Indirectly called by CheckDbCmd.execute()] wireContext="transaction"(id=166)
It's doing this: sessionFactory = environment.get(SessionFactory.class);
When I look in the 'environment' variable, I see there are 2 contexts in there: A 'transaction' context and a 'process-engine' context. The 'transaction' context contains ZERO SessionFactory definitions. The 'process-engine' context contains TWO SessionFactory definitions:
* org.hibernate.impl.SessionFactory->ProvidedObjectDescriptor (with .providedObject=the one I passed in)
* org.hibernate.SessionFactory->HibernateSessionFactoryDescriptor (with .name="org.hibernate.SessionFactory", all other fields null).
So my SessionFactory is available in the 'process-engine' context, under key "org.hibernate.impl.SessionFactory"...
==> Problem: My SessionFactory is stored under key '...SessionFactoryImpl', not under '...SessionFactory'!
That's why we end up in the following HibernateSessionFactoryDescriptor:
*[2.3]* It's doing this:
configuration = wireContext.get(Configuration.class);
...
SessionFactory sessionFactory = configuration.buildSessionFactory();
In other words, loading a new hibernate Configuration from scratch, and a new SessionFactory.
h3. Questions
It seems that in [3] (that is HibernateSessionDescriptor.construct()) something's going wrong.
* How can I have jBPM use the SessionFactory instance that was stored in the 'process-engine' WireContext, instead of using its own default mechanism to load hibernate configuration and construct a session factory?
* Did I forget some configuration properties in the jbpm.cfg.xml?* Is it a bug in jBPM?
* Isn't it scary that the 'process-engine' wireContext contain a mapping for 'SessionContext' and one for 'SessionContextImpl'. Depending on whether you're requesting the interface or implementation, you're obtaining a different session factory (I guess that's what this whole post is about...?)
I do see that in HibernateSessionDescriptor, there's a 'factoryName' property. If this property is set, it will lookup the SessionFactory in the 'transaction' wireContext under that 'factoryName'. Two questions:
1. Can I set the 'factoryName' somehow, from a jbpm configuration file? How?
2. If so, will it make any difference? Because it will then be looking up the SessionFactory in the 'transaction' wireContext, instead of the 'process-engine' wireContext (in which my SesionFactory is contained).
h3. Background info on attached project
The project is called 'jbpmtest'. It's a multimodule maven project, with the following (slightly simplified) dependency graph: [ service -> dao -> test -> domain -> commons ].
(About the domain: There's only one class in the domain, called 'Issue'. We store every Issue locally, and in addition an Issue has its own jBPM process instance; This is all managed by the IssueService. But this isn't relevant to the jBPM problem really..)
The Guice module structure (comparable to Spring's application
context) is as follows:
ServiceLayerIntegrationTestModule
|
|__ TestDataSourceModule
| |
| |__ JndiDataSourceCreator <-- Makes a datasource available under Jndi name 'jbpmtestDs'
|
|__ DataLayerModule
| |
| |__ bind(Configuration).to(HibernateConfigurationProvider) (*)
| |
| |__ PersistenceModule
| |
| |__ HibernatePersistenceModule (**)
|
|__ ServiceLayerModule
|
|__ JbpmLayerModule (***)
(*) Reads hibernate.cfg.xml and combines it with some other (programmatic) properties into a hibernate Configuration.
(**) Created with "PersistenceService.usingHibernate().across(UnitOfWork.TRANSACTION).buildModule()",
using (*).
(***) The wiring of jBPM beans is done in the JbpmLayerModule. It constructs a ProcessEngine singleton, which in turn is used to provide
the actual jBPM services (like RepositoryService, ExecutionService, etc.).
jBPM's ProcessEngine is created like this:
@Provides
@Singleton
ProcessEngine provideProcessEngine(SessionFactory hibernateSessionFactory) {
return new Configuration().setResource("jbpm/jbpm.cfg.xml")
.setHibernateSessionFactory(hibernateSessionFactory).buildProcessEngine();
}
You can see that org.jbpm.api.Configuration is passed in a hibernateSessionFactory; it's the SessionFactory created by Guice (somewhere inside the PersistenceService).
Please note that the whole Guice configuration isn't really relevant here, I just explained it for you to get a better understanding of the test project. The only interesting thing here is that JbpmLayerModule.provideProcessEngine() injects a SessionFactory object (provided by Guice!) into the jBPM Configuration, and that a later stage, jBPM seems to have constructed its own SessionFactory! I was hoping the SessionFactory to be a singleton, and that passing it into the jBPM Configuration causes jBPM to *not* read the hibernate.cfg.xml again and construct a second SessionFactory...
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536777#536777]
Start a new discussion in jBPM Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years
Re: [jboss-user] [Spring Integration] - @Autowiring of beans from Spring applicationcontext
by Martin Borgman
Martin Borgman [http://community.jboss.org/people/MartinBorgman] replied to the discussion
"@Autowiring of beans from Spring applicationcontext"
To view the discussion, visit: http://community.jboss.org/message/536772#536772
--------------------------------------------------------------
Hi Johannes,
Your autowiringtest.zip helped to find out what your problem really is.
My first question is why you replaced JBossWS Native, the one that is installed by default, with the JBoss Metro implementation? There is no real need to do this. I'm sure it should work, but at this point I think you're adding complexity you don't need.
The only real issue I found with the webservice is that you repleced org.springframework.web.context.support.SpringBeanAutowiringSupport by org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor. As the class name SpringBeanAutowiringInterceptor implies, it is intended to work in an EJB context, not in a web context.
Other than some typos here and there the webservice works on a standard JBoss 5.1.0.GA with the three snowdrop jars copied to ${JBOSS_HOME}/server/default/lib.
I've include the zip with my fixes.
The deployment now looks like this:
14:19:41,197 INFO [DefaultEndpointRegistry] register: jboss.ws:context=autowiring_war,endpoint=autowiring-webservice
14:19:41,203 INFO [WebMetaDataModifierImpl] Ignore servlet: my.pkg.AutowiringServlet
14:19:41,257 INFO [TomcatDeployment] deploy, ctxPath=/autowiring_war
14:19:41,326 INFO [[/autowiring_war]] Initializing Spring root WebApplicationContext
14:19:41,326 INFO [ContextLoader] Root WebApplicationContext: initialization started
14:19:41,364 INFO [ClassPathXmlApplicationContext] Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@253fd92e: display name [org.springframework.context.support.ClassPathXmlApplicationContext@253fd92e]; startup date [Sun Apr 11 14:19:41 CEST 2010]; root of context hierarchy
14:19:41,438 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from URL [vfszip:/Users/martinborgman/jboss-5.1.0.GA/server/default/deploy/autowiring_ear-1.0-SNAPSHOT.ear/beanRefContext.xml]
14:19:41,495 INFO [ClassPathXmlApplicationContext] Bean factory for application context [org.springframework.context.support.ClassPathXmlApplicationContext@253fd92e]: org.springframework.beans.factory.support.DefaultListableBeanFactory@c0e0960
14:19:41,514 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@c0e0960: defining beans [ear.context]; root of factory hierarchy
14:19:41,571 INFO [VFSClassPathXmlApplicationContext] Refreshing org.jboss.spring.vfs.context.VFSClassPathXmlApplicationContext@6651b294: display name [org.jboss.spring.vfs.context.VFSClassPathXmlApplicationContext@6651b294]; startup date [Sun Apr 11 14:19:41 CEST 2010]; root of context hierarchy
14:19:41,573 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from ZipEntryHandler(a)377437762[path=autowiring_ear-1.0-SNAPSHOT.ear/context.xml context=file:/Users/martinborgman/jboss-5.1.0.GA/server/default/deploy/ real=file:/Users/martinborgman/jboss-5.1.0.GA/server/default/deploy/autowiring_ear-1.0-SNAPSHOT.ear/context.xml]
14:19:41,588 INFO [VFSClassPathXmlApplicationContext] Bean factory for application context [org.jboss.spring.vfs.context.VFSClassPathXmlApplicationContext@6651b294]: org.springframework.beans.factory.support.DefaultListableBeanFactory@3f3499ef
14:19:41,590 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@3f3499ef: defining beans [myService]; root of factory hierarchy
14:19:41,602 INFO [VFSXmlWebApplicationContext] Refreshing org.jboss.spring.vfs.context.VFSXmlWebApplicationContext@214ef1ea: display name [Root WebApplicationContext]; startup date [Sun Apr 11 14:19:41 CEST 2010]; parent: ear.context
14:19:41,603 INFO [XmlBeanDefinitionReader] Loading XML bean definitions from FileHandler(a)529563278[path=WEB-INF/classes/applicationContext.xml context=file:/Users/martinborgman/jboss-5.1.0.GA/server/default/tmp/a002s-x8x9a6-g7vtmr79-1-g7vtnzfi-9r/autowiring_war-1.0-SNAPSHOT.war/ real=file:/Users/martinborgman/jboss-5.1.0.GA/server/default/tmp/a002s-x8x9a6-g7vtmr79-1-g7vtnzfi-9r/autowiring_war-1.0-SNAPSHOT.war/WEB-INF/classes/applicationContext.xml]
14:19:41,615 INFO [VFSXmlWebApplicationContext] Bean factory for application context [org.jboss.spring.vfs.context.VFSXmlWebApplicationContext@214ef1ea]: org.springframework.beans.factory.support.DefaultListableBeanFactory@165fb09d
14:19:41,628 INFO [DefaultListableBeanFactory] Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@165fb09d: defining beans []; parent: org.springframework.beans.factory.support.DefaultListableBeanFactory@3f3499ef
14:19:41,628 INFO [ContextLoader] Root WebApplicationContext: initialization completed in 302 ms
14:19:43,595 INFO [WSDLFilePublisher] WSDL published to: file:/Users/martinborgman/jboss-5.1.0.GA/server/default/data/wsdl/autowiring_ear-1.0-SNAPSHOT.ear/autowiring_war-1.0-SNAPSHOT.war/AutowiringWebService4718254481898707626.wsdl
Kind regards,
Martin
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/536772#536772]
Start a new discussion in Spring Integration at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years