[EJB/JBoss] - Unable to compile class for JSP after deploying EAR update
by sbalexander
Using JBoss 4.2.x, if I build an EAR file on my Mac OSX workstation and upload it to my production Linux web server's deploy directory, there is a seemingly random chance per .JSP page that going to that page will generate an "Unable to compile class for JSP" exception.
If I keep stopping and restarting the production JBoss server, eventually all the JSP pages work, but this is a complete nightmare for reliable deployment.
I can't find anything on the internet describing this problem. Currently using JBoss 4.2.3 on all machines. Thought the problem might be time zone related so I set my workstation to the same time zone as the production machines, but still didn't fix the problem.
Here is a typical error:
java.io.FileNotFoundException: no such file: /usr/java/jboss-4.2.3.GA/server/default/work/jboss.web/localhost/_/org/apache/jsp/Web/overview_jsp.class
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200181#4200181
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200181
17 years, 3 months
[Installation, Configuration & DEPLOYMENT] - Re: virtual directories in Jboss 5
by PeterJ
I went back and tried this on various releases. The results:
4.2.3: works
5.0.0.Beta4: works
5.0.0.CR1 & CR2: does not work
5.0.0.GA: generates this error:
11:48:18,994 ERROR [AbstractKernelController] Error installing to Start: name=WebServer state=Create
| org.jboss.xb.binding.JBossXBException: Failed to parse source: Context not found as a child of Host
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:183)
| at org.jboss.xb.binding.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:133)
| at org.jboss.web.tomcat.service.deployers.TomcatService.startService(TomcatService.java:171)
| at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:376)
| ...
I would open a JIRA issue, but for some reason I do not have update access to JIRA...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200175#4200175
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200175
17 years, 3 months
[Microcontainer] - Re: Parsing Error run DZone_1_0 demos
by Gary Marsh
alesj; I spoke too soon regarding the clean run. I had a previously compiled jar of my own in the classpath that apparently provided information needed to resolve this error. When I removed it from the classpath the error returned. Now I only have MC 2.0.2GA libraries in the path and I get the following error when I deploy the jboss-demos-models.jar to the sandbox directory:
JBoss-MC-Demo DEBUG [07-01-2009 11:32:01] SaxJBossXBParser - Created parser: com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl@62fb35, isNamespaceAware: true, is
| Validating: true, isXIncludeAware: true
| JBoss-MC-Demo DEBUG [07-01-2009 11:32:01] JBossEntityResolver - Cannot resolve [publicID=urn:jboss:spring-beans:2.0,systemID=beans]
| JBoss-MC-Demo WARN [07-01-2009 11:32:01] JBossEntityResolver - Cannot load systemId from resource: mc-spring-beans_2_0.xsd
| JBoss-MC-Demo DEBUG [07-01-2009 11:32:01] JBossEntityResolver - Cannot resolve [publicID=null,systemID=urn:jboss:spring-beans:2.0]
| JBoss-MC-Demo DEBUG [07-01-2009 11:32:01] BeanDeployer - Error during deploy: vfszip:/C:/JBoss/DZone_1_0/branches/DZone_1_0/sandbox/jboss-demos-models.jar
| org.jboss.deployers.spi.DeploymentException: Error creating managed object for vfszip:/C:/JBoss/DZone_1_0/branches/DZone_1_0/sandbox/jboss-demos-models.jar
| at org.jboss.deployers.spi.DeploymentException.rethrowAsDeploymentException(DeploymentException.java:49)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:337)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:297)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.createMetaData(AbstractParsingDeployerWithOutput.java:269)
| at org.jboss.deployers.spi.deployer.helpers.AbstractParsingDeployerWithOutput.deploy(AbstractParsingDeployerWithOutput.java:230)
| at org.jboss.deployers.plugins.deployers.DeployerWrapper.deploy(DeployerWrapper.java:171)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.doDeploy(DeployersImpl.java:1439)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.doInstallParentFirst(DeployersImpl.java:1157)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.install(DeployersImpl.java:1098)
| at org.jboss.dependency.plugins.AbstractControllerContext.install(AbstractControllerContext.java:348)
| at org.jboss.dependency.plugins.AbstractController.install(AbstractController.java:1598)
| at org.jboss.dependency.plugins.AbstractController.incrementState(AbstractController.java:934)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:1062)
| at org.jboss.dependency.plugins.AbstractController.resolveContexts(AbstractController.java:984)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:822)
| at org.jboss.dependency.plugins.AbstractController.change(AbstractController.java:553)
| at org.jboss.deployers.plugins.deployers.DeployersImpl.process(DeployersImpl.java:781)
| at org.jboss.deployers.plugins.main.MainDeployerImpl.process(MainDeployerImpl.java:545)
| at org.jboss.demos.bootstrap.MainDeployerHelper.process(MainDeployerHelper.java:86)
| at org.jboss.demos.bootstrap.HDScanner.scan(HDScanner.java:153)
| at org.jboss.demos.bootstrap.HDScanner.run(HDScanner.java:113)
| at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
| at java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
| at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:181)
| at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:205)
| at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
| at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
| at java.lang.Thread.run(Thread.java:619)
| Caused by: org.jboss.xb.binding.JBossXBException: Failed to parse source: Failed to resolve schema nsURI=urn:jboss:spring-beans:2.0 location=beans
| at org.jboss.xb.binding.parser.sax.SaxJBossXBParser.parse(SaxJBossXBParser.java:203)
|
|
| So I guess I need to know how to resolve the problem of the spring-beans definition which is misssing.
|
| Regards,
|
| GMarsh
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200172#4200172
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200172
17 years, 3 months
[EJB 3.0] - Re: JBoss 5 deployment error
by jhsingle
I have posted a zip of the entire log at
http://rabasrv.jhuapl.edu/server.log.zip
The zip file is about 1 Meg and unzips to about 14 Meg. The first ClassNotFoundException occurs on line 31730.
There was one other bean with self-injection and I had changed that one also before my last post. Just to be sure, here's the code for WorkflowEngine with the self-injection removed:
| package workflow.ejb.server;
|
| import java.io.Serializable;
| import java.lang.reflect.Method;
| import java.util.ArrayList;
| import java.util.Date;
| import java.util.HashMap;
| import java.util.List;
| import java.util.Map;
|
| import javax.annotation.security.RolesAllowed;
| import javax.ejb.Local;
| import javax.ejb.Stateless;
| import javax.ejb.TransactionAttribute;
| import javax.ejb.TransactionAttributeType;
| import javax.ejb.TransactionManagement;
| import javax.ejb.TransactionManagementType;
| import javax.persistence.EntityManager;
| import javax.persistence.PersistenceContext;
| import javax.persistence.Query;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
| import org.jboss.ejb3.annotation.LocalBinding;
|
| import security.ejb.client.User;
| import workflow.ejb.client.ExecutionDetail;
| import workflow.ejb.client.ExecutionSummary;
| import workflow.ejb.client.ResultingParams;
| import workflow.ejb.client.StateDefinition;
| import workflow.ejb.client.StepDefinition;
| import workflow.ejb.client.TransitionDefinition;
| import workflow.ejb.client.TransitionReference;
| import workflow.ejb.client.WorkflowEngineLocal;
| import workflow.ejb.util.ParamUtil;
| import workflow.ejb.util.XPDLUtil;
|
| /**
| * Processes workflow. Uses Declaritive Transaction Mgmt for individual methods.
| */
| @Stateless
| @RolesAllowed( { "UNCLASSIFIED" })
| @LocalBinding(jndiBinding = "workflow/WorkflowEngine/local")
| @TransactionManagement(value = TransactionManagementType.CONTAINER)
| public class WorkflowEngine implements Serializable, WorkflowEngineLocal {
|
| /**
| * The class logger
| */
| private static Log logger = LogFactory.getLog(WorkflowEngine.class);
|
| /** workflow engine */
| // @javax.annotation.Resource(mappedName = "workflow/WorkflowEngine/local")
| // private WorkflowEngineLocal workflowEngineLocal;
|
| /**
| * The entity manager
| */
| protected @PersistenceContext(unitName = "workflow")
| EntityManager em;
|
| /**
| * Sets the execution summary id of the execution detail.
| *
| * @param executionSummaryId
| * @param executionDetailCopy
| */
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public void addExecutionDetailToExecutionSummary(long executionSummaryId,
| ExecutionDetail executionDetailCopy) {
|
| Query updateComplete = em
| .createNativeQuery("update EXECUTION_DETAIL set EX_SUMMARY_ID = :first where ID = :second");
|
| updateComplete.setParameter("first", executionSummaryId);
| updateComplete.setParameter("second", executionDetailCopy.getId());
| updateComplete.executeUpdate();
| }
|
| /**
| * Make sure that all transition definitions for a join have an associated
| * execution detail meaning that the join can proceed.
| *
| * @param tdList
| * @param esId
| * @return boolean
| */
| @SuppressWarnings("unchecked")
| public boolean areAllJoinTransitionsFinished(
| List<TransitionDefinition> tdList, long esId) {
|
| if (tdList == null) {
| logger.error("No transitions found for fork in execution summary: "
| + esId);
| return false;
| }
|
| for (TransitionDefinition td : tdList) {
|
| Query query = em
| .createQuery("from ExecutionDetail e "
| + " WHERE e.associatedStepId =:first AND e.executionSummaryId =:second AND e.completed =:third");
|
| query.setParameter("first", td.getId());
| query.setParameter("second", esId);
| query.setParameter("third", Long.parseLong("1"));
|
| List<ExecutionDetail> edList = query.getResultList();
| long edSize = edList.size();
|
| if (edSize < 1) {
| return false;
| }
| }
| return true;
| }
|
| /**
| * Checks if an execution detail exists for an execution summary and step
| * definition id.
| *
| * @param executionSummaryId
| * @param stepDefinitionId
| * @return int
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public int checkIfExecutionDetailExists(long executionSummaryId,
| long stepDefinitionId) {
| Query lockQuery = em
| .createNativeQuery("SELECT ID FROM EXECUTION_DETAIL WHERE EX_SUMMARY_ID = :first AND STEP_ID= :second ");
|
| lockQuery.setParameter("first", executionSummaryId);
| lockQuery.setParameter("second", stepDefinitionId);
|
| List results = lockQuery.getResultList();
| int noUpdate = 0;
| if (results != null && results.size() != 0) {
| noUpdate = 1;
| }
|
| return noUpdate;
| }
|
| /**
| * Creates a result params entry for an execution detail and execution
| * summary. This method does not insert the LOB, PARAMS_AS_XML.
| *
| * @param executionSummaryId
| * @param executionDetailId
| * @return int - number inserted
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public int createResultParams(long executionSummaryId,
| long executionDetailId) {
|
| // adding execution ids to entry and result param tables.
| Query insertRPQuery = em
| .createNativeQuery("INSERT INTO RESULTING_PARAMS(EX_DETAIL_ID,EX_SUMMARY_ID) "
| + " VALUES (:first,:second)");
| insertRPQuery.setParameter("first", executionDetailId);
| insertRPQuery.setParameter("second", executionSummaryId);
| int noInsert = insertRPQuery.executeUpdate();
|
| return noInsert;
| }
|
| /**
| * Get previous steps' execution params add the definition params.
| *
| * @param eSummaryId
| * @param edId
| * @param stateDef
| * @return params
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public Map<String, Object> getDefinitionParams(long eSummaryId, long edId,
| StateDefinition stateDef) {
|
| // get previous steps' execution params
| Map<String, Object> params = new HashMap<String, Object>();
|
| // add the definition params.
| params.putAll(stateDef.getParams());
|
| return params;
| }
|
| /**
| * Get Execution Detail based on execution summary and step definition. This
| * method is highly nested.
| *
| * @param executionSummaryId
| * The id of an ExecutionSummary
| * @param stepDefinitionId
| * The id of a StepDefinition
| * @return ExecutionDetail the execution detail for the associated
| * ExecutionSummary and StepDefinition.
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public ExecutionDetail getExecutionDetail(long executionSummaryId,
| long stepDefinitionId) {
|
| int noUpdate = checkIfExecutionDetailExists(
| executionSummaryId, stepDefinitionId);
|
| if (noUpdate == 0) {
| insertExecutionDetail(executionSummaryId,
| stepDefinitionId);
| }
|
| Query query = em
| .createQuery("from ExecutionDetail e WHERE e.executionSummaryId =:first AND e.associatedStepId =:second");
|
| // get execution detail of previous step.
| query.setParameter("first", executionSummaryId);
| query.setParameter("second", stepDefinitionId);
|
| // long edqtime = System.currentTimeMillis();
| List<ExecutionDetail> edList = query.getResultList();
|
| ExecutionDetail eDetail = null;
| // Add in the results in order.
| for (ExecutionDetail executionDetailFromQuery : edList) {
| eDetail = executionDetailFromQuery;
| }
|
| // adding execution ids to entry and result param tables.
| if (noUpdate == 0) {
| createResultParams(executionSummaryId, eDetail
| .getId());
| }
|
| return eDetail;
| }
|
| /**
| * Get the next TransitionDefinition for a fromState.
| *
| * @param stateDefId
| * @return TransitionDefinition
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public TransitionDefinition getNextTransitionDefinition(long stateDefId) {
| Query query = em
| .createQuery("from TransitionDefinition t WHERE t.fromState.id =:first ");
| query.setParameter("first", stateDefId);
|
| List<TransitionDefinition> edList = query.getResultList();
|
| TransitionDefinition td = null;
| if (edList != null && edList.size() > 0) {
| td = edList.get(0);
| }
|
| return td;
| }
|
| /**
| * Gets the resulting params for an execution detail.
| *
| * @param edId
| *
| * @param stepDefinition
| * a step definition
| * @param esId
| * Execution summary id
| * @return Map containing parameters
| */
|
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public Map<String, Object> getPersistedParams(long edId, long esId) {
|
| Query query = em
| .createQuery(
| "from ResultingParams rp WHERE rp.exSummaryId =:first AND rp.exDetailId =:second")
| .setHint("org.hibernate.readOnly", Boolean.TRUE);
|
| // get execution detail of previous step.
| query.setParameter("first", esId);
|
| query.setParameter("second", edId);
|
| List<ResultingParams> resultParamList = query.getResultList();
| Map<String, Object> params = new HashMap<String, Object>();
|
| if (resultParamList != null) {
| // Add in the results in order.
| for (ResultingParams resultParam : resultParamList) {
| params.putAll(ParamUtil.paramsAsXML(resultParam
| .getResultingParamsAsXML(), true));
| }
| }
|
| return params;
| }
|
| /**
| * Gets the params from the previous transition definition.
| *
| * @param eSummaryId
| * @param stateDef
| * @return runtimeParams
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public Map<String, Object> getRuntimeParams(long eSummaryId,
| StateDefinition stateDef) {
| Map<String, Object> runtimeParams = new HashMap<String, Object>();
|
| List<TransitionDefinition> transitionDefinitionList =
| getTransitionDefinitionsWithToId(stateDef.getId());
| for (TransitionDefinition td : transitionDefinitionList) {
|
| ExecutionDetail prevED = getExecutionDetail(
| eSummaryId, td.getFromState().getId());
| runtimeParams.putAll(getPersistedParams(prevED
| .getId(), eSummaryId));
| }
|
| return runtimeParams;
| }
|
| /**
| * Get TransitionDefinitions for a transitionReference id.
| *
| * @param transitionReferenceId
| * @return List of TransitionDefinitionS
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public List<TransitionDefinition> getTransitionDefinitions(
| long transitionReferenceId) {
|
| Query fetchTQuery = em
| .createQuery(
| "from TransitionDefinition td WHERE td.transitionReference.id =:first")
| .setHint("org.hibernate.readOnly", Boolean.TRUE);
| fetchTQuery.setParameter("first", transitionReferenceId);
| List<TransitionDefinition> transitionDefinitionList = fetchTQuery
| .getResultList();
| if (transitionDefinitionList != null) {
|
| }
| return transitionDefinitionList;
| }
|
| /**
| * Get TransitionDefinitions for a toState id.
| *
| * @param toStateDefId
| * @return List of TransitionDefinitionS
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public List<TransitionDefinition> getTransitionDefinitionsWithToId(
| long toStateDefId) {
|
| Query fetchTQuery = em.createQuery(
| "from TransitionDefinition td WHERE td.toState.id =:first")
| .setHint("org.hibernate.readOnly", Boolean.TRUE);
| fetchTQuery.setParameter("first", toStateDefId);
|
| List<TransitionDefinition> tdList = new ArrayList<TransitionDefinition>();
| try {
|
| List<TransitionDefinition> tempTdList = fetchTQuery.getResultList();
| if (tempTdList != null && tempTdList.size() > 0) {
| tdList = getTransitionDefinitions(tempTdList.get(0)
| .getTransitionReference().getId());
| }
| } catch (javax.persistence.NoResultException e) {
| logger.error("No transition defs found with " + toStateDefId
| + " as a 'To' state.", e);
| }
|
| return tdList;
| }
|
| /**
| * Handle action for a state definition.
| *
| * @param stateDefinition
| * a state Definition
| * @param definitionParams
| * @param runtimeParams
| * @param params
| * The state parameters
| * @param user
| * a User
| * @return a Map<String, Object> the results of a action class method
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public Map<String, Object> handleAction(StateDefinition stateDefinition,
| Map<String, Object> definitionParams,
| Map<String, Object> runtimeParams, User user) {
| Map<String, Object> retmap = null;
| try {
|
| definitionParams.put("user", user);
|
| Class c = Class.forName(stateDefinition.getActionClass());
| Class[] argClasses = new Class[3];
| argClasses[0] = StateDefinition.class;
| argClasses[1] = Map.class;
| argClasses[2] = Map.class;
| Method mymethod = c.getMethod(stateDefinition.getActionMethod(),
| argClasses);
| Object[] args = new Object[3];
| args[0] = stateDefinition;
| args[1] = definitionParams;
| args[2] = runtimeParams;
| Object obj = c.newInstance();
| retmap = (Map<String, Object>) mymethod.invoke(obj, args);
| } catch (Exception e) {
| logger.error("An error occured while running an algorithm", e);
| throw new RuntimeException(
| "An error occured while running an algorithm");
| }
| return retmap;
| }
|
| /**
| * Create execution detail.
| *
| * @param executionSummaryId
| * @param stepDefinitionId
| * @return number inserted
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public int insertExecutionDetail(long executionSummaryId,
| long stepDefinitionId) {
|
| Query insertQuery = em
| .createNativeQuery("INSERT INTO EXECUTION_DETAIL(EX_SUMMARY_ID, STEP_ID) "
| + " VALUES (:first, :second)");
|
| insertQuery.setParameter("first", executionSummaryId);
| insertQuery.setParameter("second", stepDefinitionId);
| int noInsert = insertQuery.executeUpdate();
| return noInsert;
| }
|
| /**
| * Send message to queue.
| *
| * @param eSummaryId
| * @param tdId
| * @param user
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void postMessageForNextStep(long eSummaryId, long tdId, User user) {
| WorkflowUtil.sendMessage(WorkflowManager.queueName, tdId, user,
| eSummaryId);
| }
|
| /**
| * Get the ExecutionDetail,StepDefinition,ExecutionSummary and process the
| * next step.
| *
| * @param eSummaryId
| * @param stepDefId
| * @param user
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void process(long eSummaryId, long stepDefId, User user) {
|
| // get objects by their id.
| ExecutionDetail executionDetail =
| getExecutionDetail(eSummaryId, stepDefId);
| StepDefinition stepDefinition = em
| .find(StepDefinition.class, stepDefId);
| ExecutionSummary executionSummary = em.find(ExecutionSummary.class,
| eSummaryId);
|
| // if all needed objects were found, process this step
| if (executionSummary != null
| && executionSummary.getWhenCompleted() == null
| && stepDefinition != null) {
| processStep(executionSummary, stepDefinition,
| executionDetail, user);
| }
| }
|
| /**
| * Process a FORK step.
| *
| * @param eDetail
| * @param tDef
| * @param tRef
| * @param eSummaryId
| * @param user
| */
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void processFork(ExecutionDetail eDetail, TransitionDefinition tDef,
| TransitionReference tRef, long eSummaryId, User user) {
|
| // place all transitions into queue. Since each will get called
| // do the same thing as a
| // series. We just don't have a condition.
| eDetail.setActionClassCalled("FORK");
|
| List<TransitionDefinition> transitionDefinitionList =
| getTransitionDefinitions(tRef.getId());
|
| for (TransitionDefinition td : transitionDefinitionList) {
|
| setExecutionDetailCompleted(eDetail);
|
| postMessageForNextStep(eSummaryId, td
| .getToState().getId(), user);
|
| }
|
| }
|
| /**
| * Process a JOIN step.
| *
| * @param eDetail
| * @param tDef
| * @param tRef
| * @param eSummaryId
| * @param user
| */
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public void processJoin(ExecutionDetail eDetail, TransitionDefinition tDef,
| TransitionReference tRef, long eSummaryId, User user) {
|
| List<TransitionDefinition> transitionDefinitionList =
| getTransitionDefinitions(tRef.getId());
|
| setExecutionDetailCompleted(eDetail);
|
| if (areAllJoinTransitionsFinished(
| transitionDefinitionList, eSummaryId)) {
| postMessageForNextStep(eSummaryId, tDef
| .getToState().getId(), user);
| }
|
| }
|
| /**
| *
| * @see workflow.ejb.client.WorkflowEngineLocal#processLoop(long,
| * workflow.ejb.client.ExecutionDetail,
| * workflow.ejb.client.StateDefinition, security.ejb.client.User)
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void processLoop(long eSummaryId, ExecutionDetail eDetail,
| StateDefinition stateDef, User user) {
| String interval = Long.toString(stateDef.getLoopInterval());
| if (!interval.contains(".")) {
| interval = interval + ".0";
| }
|
| try {
| if (stateDef.getWhenToTest().equalsIgnoreCase("before")) {
|
| for (; stateDef.getLoopCounter() < stateDef.getLoopMaximum(); stateDef
| .setLoopCounter(stateDef.getLoopCounter() + 1)) {
| processStateAlgorithm(eSummaryId, eDetail.getId(),
| stateDef, user);
| Thread.sleep(stateDef.getLoopInterval());
| }
| }
| // whenToTest is assumed to be "after"
| else {
|
| do {
| processStateAlgorithm(eSummaryId, eDetail.getId(),
| stateDef, user);
| stateDef.setLoopCounter(stateDef.getLoopCounter() + 1);
| Thread.sleep(stateDef.getLoopInterval());
| } while (stateDef.getLoopCounter() < stateDef.getLoopMaximum());
| }
| } catch (InterruptedException e) {
| logger.error("Interruption exception received. ", e);
| }
|
| }
|
| /**
| * Process a SERIES.
| *
| * @param eSummaryId
| * @param tDef
| * @param eDetail
| * @param user
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void processSeries(long eSummaryId, TransitionDefinition tDef,
| ExecutionDetail eDetail, User user) {
|
| ExecutionDetail prevED = getExecutionDetail(
| eSummaryId, tDef.getFromState().getId());
| Map<String, Object> params = getPersistedParams(
| prevED.getId(), eSummaryId);
|
| // evaluate condition to move to next state.
| boolean res = tDef.getConditionForEval() == null ? true : XPDLUtil
| .evaluateCondition(tDef.getConditionForEval(), params);
| if (res) {
| // move to the next state.
| eDetail = getExecutionDetail(eSummaryId, tDef
| .getId());
|
| setExecutionDetailCompleted(eDetail);
|
| postMessageForNextStep(eSummaryId, tDef
| .getToState().getId(), user);
| }
| }
|
| /**
| * Runs the algorithm.
| *
| * @param eSummary
| * @param stateDef
| * @param eDetail
| * @param user
| * @param em
| */
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public void processStateDefinition(ExecutionSummary eSummary,
| StateDefinition stateDef, ExecutionDetail eDetail, User user) {
|
| try {
| boolean hasLoop = (stateDef.getLoopMaximum() > 0);
|
| if (hasLoop) {
| processLoop(eSummary.getId(), eDetail, stateDef, user);
| } else {
| processStateAlgorithm(eSummary.getId(), eDetail.getId(),
| stateDef, user);
| }
|
| TransitionDefinition td =
| getNextTransitionDefinition(stateDef.getId());
|
| // finished state processing
| setExecutionDetailCompleted(eDetail);
|
| if (td != null) {
| // follow next transition
| postMessageForNextStep(eSummary.getId(), td
| .getId(), user);
| return;
| } else {
| endWorkflow(eSummary);
| }
| } catch (Exception e) {
| endWorkflowInError(eSummary, eDetail);
| logger.debug(e.toString());
| }
| }
|
| /**
| *
| * @see workflow.ejb.client.WorkflowEngineLocal#endWorkflow(workflow.ejb.client.ExecutionSummary)
| */
| public void endWorkflow(ExecutionSummary eSummary) {
| // end workflow
| Date completed = new Date();
|
| eSummary.setWhenCompleted(completed);
|
| Query updateComplete = em
| .createNativeQuery("update EXECUTION_SUMMARY set WHEN_COMPLETED = :first where ID = :second");
|
| updateComplete.setParameter("first", completed);
| updateComplete.setParameter("second", eSummary.getId());
| updateComplete.executeUpdate();
| }
|
| /**
| *
| * @see workflow.ejb.client.WorkflowEngineLocal#endWorkflowInError(workflow.ejb.client.ExecutionSummary,
| * workflow.ejb.client.ExecutionDetail)
| */
| public void endWorkflowInError(ExecutionSummary eSummary,
| ExecutionDetail eDetail) {
| setExecutionDetailCompleted(eDetail);
| endWorkflow(eSummary);
| }
|
| /**
| * Process the state algorithm
| *
| * @param eSummaryId
| * Summary ID
| * @param eDetailId
| * Detail ID
| * @param stateDef
| * State definition
| * @param user
| * User
| */
| private void processStateAlgorithm(long eSummaryId, long eDetailId,
| StateDefinition stateDef, User user) {
| // get params needed to process step
| Map<String, Object> defParams =
| getDefinitionParams(eSummaryId, eDetailId, stateDef);
|
| Map<String, Object> runtimeParams = new HashMap<String, Object>();
|
| List<TransitionDefinition> transitionDefinitionList =
| getTransitionDefinitionsWithToId(stateDef.getId());
| for (TransitionDefinition td : transitionDefinitionList) {
|
| ExecutionDetail prevED = getExecutionDetail(
| eSummaryId, td.getFromState().getId());
| runtimeParams.putAll(getPersistedParams(prevED
| .getId(), eSummaryId));
| }
|
| // run the algorithm
| if (stateDef.getActionClass() != null
| && stateDef.getActionClass().length() > 0) {
| Map<String, Object> resultMap = handleAction(
| stateDef, defParams, runtimeParams, user);
|
| updatePersistedResultParams(eDetailId,
| eSummaryId, resultMap);
| } else // must be a fork or join state
| {
| updatePersistedResultParams(eDetailId,
| eSummaryId, runtimeParams);
| }
| }
|
| /**
| * Process step.
| *
| * @param executionSummary
| * an ExecutionSummary
| * @param stepDefinition
| * a StateDefinition
| * @param executionDetail
| * an executionDetail
| * @param user
| * a User
| * @param params
| */
|
| @SuppressWarnings("unchecked")
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void processStep(ExecutionSummary executionSummary,
| StepDefinition stepDefinition, ExecutionDetail executionDetail,
| User user) {
|
| if (stepDefinition instanceof StateDefinition) {
| StateDefinition stateDef = (StateDefinition) stepDefinition;
| processStateDefinition(executionSummary,
| stateDef, executionDetail, user);
| } else if (stepDefinition instanceof TransitionDefinition) {
| processTransitionDefinition(executionSummary,
| (TransitionDefinition) stepDefinition, executionDetail,
| user);
| } else {
| logger.error("Cannot understand what to process for step with id="
| + stepDefinition.getId());
| throw new RuntimeException(
| "Cannot understand what to process for step with id="
| + stepDefinition.getId());
| }
| addExecutionDetailToExecutionSummary(
| executionSummary.getId(), executionDetail);
| }
|
| /**
| * Process a TransitionDefinition.
| *
| * @param eSummary
| * @param tDef
| * @param eDetail
| * @param user
| */
| @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
| public void processTransitionDefinition(ExecutionSummary eSummary,
| TransitionDefinition tDef, ExecutionDetail eDetail, User user) {
|
| TransitionReference tRef = tDef.getTransitionReference();
|
| if (tRef.getTransitionType() == TransitionReference.FORK) {
| processFork(eDetail, tDef, tRef, eSummary
| .getId(), user);
| } else if (tRef.getTransitionType() == TransitionReference.JOIN) {
| processJoin(eDetail, tDef, tRef, eSummary
| .getId(), user);
| } else if (tRef.getTransitionType() == TransitionReference.SERIES) {
| processSeries(eSummary.getId(), tDef, eDetail,
| user);
|
| } else {
| logger.error("Transition type " + tRef.getTransitionType()
| + "is not understood.");
| throw new RuntimeException("Transition type "
| + tRef.getTransitionType() + "is not understood.");
| }
| }
|
| /**
| * Sets an ExecutionDetail as completed.
| *
| * @param eDetail
| * @return number updated
| */
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public int setExecutionDetailCompleted(ExecutionDetail eDetail) {
|
| Query completed = em
| .createNativeQuery("UPDATE EXECUTION_DETAIL SET COMPLETED = '1' WHERE ID = :first");
| completed.setParameter("first", eDetail.getId());
| int numUpdated = completed.executeUpdate();
| eDetail.setCompleted(1);
|
| return numUpdated;
| }
|
| /**
| * Updates the LOB, PARAMS_AS_XML.
| *
| * @param edId
| * @param esId
| * @param params
| */
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public void updatePersistedResultParams(long edId, long esId,
| Map<String, Object> params) {
|
| Query updateResultParamsQuery = em
| .createNativeQuery("UPDATE RESULTING_PARAMS SET RESULTING_PARAMS_AS_XML = :first WHERE EX_DETAIL_ID = :second");
|
| updateResultParamsQuery.setParameter("first", ParamUtil.paramsFromMap(
| params, true));
| updateResultParamsQuery.setParameter("second", edId);
| updateResultParamsQuery.executeUpdate();
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4200171#4200171
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4200171
17 years, 3 months