If HibernateException is loaded from spring (and I guess it is), you have no way to work around that, but to put spring in your component, or put hibernate in the container classpath :(
On 9/29/06, Jamie McCrindle <[EMAIL PROTECTED]> wrote:
Hi Guilaume, I stopped using spring configuration and instead wired the objects together in Java. When loading LocalSessionFactoryBean loaded from the container classloader, it couldn't see HibernateException loaded by the component classloader. I used: Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); to set the classloader. cheers, j. On 9/29/06, Guillaume Nodet <[EMAIL PROTECTED]> wrote: > How do you load your spring configuration ? > You need to set up the thread context classloader > correctly in order to load beans defined in your > component, but you do not have to embed > spring, as it is already available in the container > classloader. > > On 9/29/06, Jamie McCrindle <[EMAIL PROTECTED]> wrote: > > right. changed all of the xml config into plain old java and still > > faced essentially the same problem. it turns out, though, that it's > > more to do with the difference in classloading between running > > servicemix as a maven goal (i.e. mvn:servicemix) rather than deploying > > into a running servicemix (mvn:projectDeploy). I still need to include > > spring in component but it looks like it can pick up the derby drivers > > from servicemix which means someone could drop oracle drivers in there > > if they like. > > > > cheers, > > j. > > > > On 9/28/06, Jamie McCrindle <[EMAIL PROTECTED]> wrote: > > > hi all, > > > > > > this isn't a bug or issue, just a question if someone has solved a > > > similar problem or info for someone who has a similar problem. > > > > > > i switched to putting a spring xml config into my component and > > > configuring it from there (mainly because i'm using hibernate and i > > > wanted to use the spring transaction management which seems a lot > > > easier using a spring beans configuration rather than hand cranking > > > it). > > > > > > unit testing went well, but i ran into all sorts of classloading > > > issues when deploying the component. essentially, it looks like if i > > > load spring from servicemix, it can't see classes loaded by the > > > component. this looks to be a reflection problem: > > > > > > Caused by: java.lang.NoClassDefFoundError: org/hibernate/HibernateException > > > at java.lang.Class.forName0(Native Method) > > > at java.lang.Class.forName(Class.java:242) > > > at org.springframework.util.ClassUtils.forName(ClassUtils.java:160) > > > at org.springframework.beans.factory.support.AbstractBeanDefinition.reso > > > lveBeanClass(AbstractBeanDefinition.java:308) > > > > > > using either: > > > > > > context.setClassLoader(getClass().getClassLoader()); > > > > > > or > > > > > > Thread.currentThread().setContextClassLoader(getClass().getClassLoader()); > > > > > > doesn't seem to make a difference. > > > > > > if i switch to self-first and put the spring jar into the component, i > > > need to add a bunch of other jars in that are part of the default > > > servicemix lib (e.g. xbean, activemq, exclude xml-api's, derby). these > > > are all jars that the component uses so it might not be a bad thing > > > from a jbi container portability point of view BUT because i'm using > > > hibernate, i need an easy way to allow people to dump new database > > > drivers into servicemix and it would be preferable if they could put > > > them into the servicemix/lib folder rather than either creating a > > > shared library component or rebuilding my component with them in. > > > > > > my current plan is to rip out the spring-beans config and hand crank > > > it (which i prefer in all honesty but is going to be a bit of a PITA). > > > > > > cheers, > > > j. > > > > > > > > -- > Cheers, > Guillaume Nodet >
-- Cheers, Guillaume Nodet
