Introduction
This article documents how I managed to run jBPM 5.2 embedded on applications deployed on Weblogic 11g (a.k.a. 10.3.5) without needing to use its special classloader configurations. I hope it's useful information and I'd love to know your thoughts and questions about any information that's missing here so I can improve it.
Problems you'll need to solve
- Many jBPM 5.2 dependencies conflict with Weblogic 11g provided libraries.
- You'll need to configure jBPM to get resources from Weblogic 11g server. This may be optional depending on your context. It was mandatory for me.
Problem 1: resolving the dependencies
You can solve that with the attached pom.xml which contains information about the dependencies you'll have to solve. You can copy the whole file into your web project (changing the appropriate information) or simply copy the <properties> and <dependencies> sections into your current pom.xml. Please, read the file for extra information since it is thoroughly commented.
Problem 2: configure jBPM
You'll need to tell jBPM to search for the correct transaction manager. I accomplished that with the following code.
private static final String transactionManagerName = "javax.transaction.TransactionManager"; //default Weblogic 11g configuration private static final String persistentUnitName = "org.jbpm.persistence.jpa"; private static final String[] processDefinitionFiles = "process.bpmn"; private void configure(String[] processDefinitionFiles, String persistentUnitName, String transactionManagerName) { //default KB configuration KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); for (String processDefinitionFile : processDefinitionFiles) { kbuilder.add(ResourceFactory.newClassPathResource(processDefinitionFile), ResourceType.BPMN2); } final KnowledgeBase kbase = kbuilder.newKnowledgeBase(); //Configure EntityManagerFactory final EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory(persistentUnitName); //Configure TransactionManager final TransactionManager transactionManager = getTransactionManager(transactionManagerName); //Configure Environment final Environment env = getEnvironment(entityManagerFactory, transactionManager); //Put here your code that will allow the application to reach the relevan jBPM objects, if you find it necessary logger.debug("Done configuring jBPM."); } private TransactionManager getTransactionManager(String transactionManagerName) { try { InitialContext ctx = new InitialContext(); TransactionManager tm = (TransactionManager) ctx.lookup(transactionManagerName); return tm; } catch (NamingException e) { throw new RuntimeException(e); } } private Environment getEnvironment(EntityManagerFactory entityManagerFactory, TransactionManager transactionManager) { Environment environment = KnowledgeBaseFactory.newEnvironment(); environment.set(EnvironmentName.ENTITY_MANAGER_FACTORY, entityManagerFactory); environment.set(EnvironmentName.TRANSACTION_MANAGER, transactionManager); return environment; }
You're done!
After doing all that, you should be able to deploy and run your application on a Weblogic 11g instance with jBPM 5.2 embedded. Until now I had no issues with that configuration, but I'm still not using jBPM in it's full capabilities. Should anything change, I'll come back and update this article.
Comments