[Beginners Corner] - Inserting custom classloader to delegation chain?
by hentar
Hello.
I'm trying to define a custom classloader to create certain classes at runtime.
My classloader itself is just deriving from ClassLoadder and overriding the findClass with something like
| @Override
| protected Class<?> findClass(String className) throws ClassNotFoundException {
| ClassLoader parentLoader = this.getClass().getClassLoader();
| if(className.equals("classToBeCreatedAtRuntime")){
| Class c = createClass(className);
| return c;
| }else{
| return Class.forName(className, true, parentLoader);
| }
| }
|
What I want from my classloader is to create and load class at runtime if needed or just delegate the responsibility to parent class loader.
The main problem I face is to "push" my custom loader into the delegation chain. I've tried to set it with Thread.currentThread().setContextClassLoader but I'm getting classcast exceptions, so this doesn't seems like a right way.
Am I missing something? How this can be achieved?
Thanks a lot.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074477#4074477
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074477
18Â years, 11Â months
[JBoss jBPM] - Re: assign swimlane dynamically according to previous transi
by rossputin
Hi,
I am getting the following error when testing a simple process with a custom assignment handler attached to a task...
Error completing task: An exception of type "org.jbpm.graph.def.DelegationException" was thrown.
I compiled my handler, and put it under WEB-INF/classes in my web app. The node in question is...
| <task-node name="decision chose red light">
| <task name="decision made red">
| <assignment class="DatacentreAssignmentHandler"></assignment>
| </task>
| <transition to="end decision"></transition>
| </task-node>
|
and the body of my 'assign' method is...
| ContextInstance contextInstance = executionContext.getContextInstance();
|
| if (contextInstance.getVariable("colour").equals("green")) {
| assignable.setActorId("ross");
| } else {
| assignable.setActorId("user");
| }
|
what might be causing this?
Thanks for your help in advance,
regards
Ross
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074473#4074473
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074473
18Â years, 11Â months
[JBoss Seam] - Re: TransactionalSeamPhaseListener + Spring @Transactional
by youngm
anonymous wrote : 1. I am not able to locate the class TransactionalSeamPhaseListener in Seam 2.0? Has it been replaced by the general SeamPhaseListener?
|
Ya, it was removed in 2.0 beta and was replaced by the "transaction-management-enabled" attribute
anonymous wrote :
| 2. Where can I download the 2.0.0. CR1? (you mean RC1?)
|
Unfortunately it is not out yet. Feel free to checkout the latest from CVS and build your own snapshot though.
anonymous wrote :
| 3. I want to deploy my application in Tomcat, where no UserTransaction is available in JNDI? I encountered some problem in the class org.jboss.seam.transaction.Transaction, which always exists the method getUserTransaction with a runtime exception: I am forced to disable the seam tx management in components.xml with <core:init debug="true" transaction-management-enabled="false"/> to get rid of the problem. But I think I am then only relying on the spring tx management and might get LazyInitilizationException. Is my understanding right?
So first of all in 2.0.0 CR1 you will be able to use a spring TM as a Seam TM and will be able to enable "transaction-management-enabled". For now though who is doing the transaction management has nothing to do with getting LazyInitializationExceptions. What "transaction-management-enabled" disabled will mean is that when you wish to flush() your conversation scoped PC it will be best to do it inside of a Service call with @Transactional.
Otherwise your configuration looks fine otherwise. A couple of points:
1. You don't need to inject a dataSource into your JpaTransactionManager. I'm not sure if it will mess things up or not but I know it is not necessary.
2. Make sure your components.xml has your entityManager definition:
| <persistence:managed-persistence-context name="entityManager"
| auto-create="true"
| entity-manager-factory="#{entityManagerFactory}"/>
And uncomment and rename your SeamManagedEntityManagerFactoryBean to something like:
| <bean id="seamEntityManagerFactory"
| class="org.jboss.seam.ioc.spring.SeamManagedEntityManagerFactoryBean">
| <property name="persistenceContextName" value="entityManager" />
| </bean>
And make sure that you use your seamEntityManagerFactory with your JpaTransactionManager like:
| <bean id="transactionManager"
| class="org.springframework.orm.jpa.JpaTransactionManager">
| <property name="entityManagerFactory"
| ref="seamEntityManagerFactory" />
| </bean>
|
Otherwise read over more closely the Seam+Spring docs regarding Persistence contexts.
Mike
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4074470#4074470
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4074470
18Â years, 11Â months