L.S.,

Yeah, I don't think there's a problem for the SU classloader to access
the JRuby/Groovy/... classes, the problem is in spring-context that
needs to access those classes.  That jar is in the container classpath
so it won't have access to the classes you deployed in your SU.  For
ServiceMix 3.3.x, adding the necessary jars to lib/optional might well
be the only viable alternative to get the classes together in the same
classloader.

In ServiceMix 4, built on an OSGi framework, you can use OSGi
packaging to deploy your JBI endpoints, giving you a lot more
fine-grained control over the classpath/classloaders.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



On 15 February 2010 08:05, Alexanderz <[email protected]> wrote:
>
> Hello
>
> There is some interesting fact, It is possible to instantiate classed:
> org/jruby/exceptions/JumpException or
> org/codehaus/groovy/control/CompilationFailedException as plain spring
> beans.
>
>
> Alexanderz wrote:
>>
>> Hello,
>>
>>    Nope, it does not help me:
>>
>> <beans xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0";
>>   xmlns:lang="http://www.springframework.org/schema/lang";
>> ... >
>>
>>         <classpath inverse="true"/>
>>
>>     <lang:jruby scope="prototype" id="setterInterceptor"
>>             script-interfaces="org.apache.cxf.phase.PhaseInterceptor"
>>             script-source="classpath:PropertySetter.rb"/>
>> ...
>> <beans>
>>
>> BR,
>>     Alexander
>>
>>
>> Gert Vanthienen wrote:
>>>
>>> L.S.,
>>>
>>> This is probably being caused by the way classloading works in JBI --
>>> by default, the SU has a parent-first classloading mechanism so it
>>> will start looking in the component/container classpath before loading
>>> classes from the SU.  By putting the required jars in the lib/optional
>>> directory, they're being considered part of the container classpath
>>> and that's why this fixes the issue.
>>>
>>> You should be able to resolve this by explicitly configuring the SU to
>>> use self-first classloading as explained in
>>> http://servicemix.apache.org/classloaders.html.  If you're going to
>>> build multiple SU that use the same libraries, you might also want to
>>> consider packaging those up as a shared library and reference that
>>> from your SU (explained on the same wiki page).
>>>
>>> Regards,
>>>
>>> Gert Vanthienen
>>> ------------------------
>>> Open Source SOA: http://fusesource.com
>>> Blog: http://gertvanthienen.blogspot.com/
>>>
>>>
>>>
>>> On 13 February 2010 17:56, Alexanderz <[email protected]> wrote:
>>>>
>>>> Hi!
>>>>
>>>> Does anyone have an example of using the spring script
>>>> beans(http://static.springsource.org/spring/docs/2.5.x/reference/dynamic-language.html)
>>>> in SU without servicemix-script or servicemix-scripting SEs in SMX 3?
>>>>
>>>> For example I would like to implement custom cxf-api interceptor or
>>>> custom
>>>> predicate for eip:content-base-router on groovy or jruby spring beans.
>>>> But
>>>> It seems I've faced with classloading problem:
>>>>
>>>>
>>>> 1) <loc-message>org/jruby/exceptions/JumpException</loc-message>
>>>>
>>>> <stack-trace><![CDATA[java.lang.NoClassDefFoundError:
>>>> org/jruby/exceptions/JumpException
>>>>        at java.lang.Class.getDeclaredConstructors0(Native Method)
>>>>        at
>>>> java.lang.Class.privateGetDeclaredConstructors(Class.java:2384)
>>>>        at java.lang.Class.getDeclaredConstructors(Class.java:1812)
>>>>        at
>>>> org.springframework.beans.factory.support.ConstructorResolver.autowireCon
>>>>
>>>>
>>>> In SU pom file I have
>>>>    <dependency>
>>>>        <groupId>org.codehaus.groovy</groupId>
>>>>        <artifactId>groovy-all</artifactId>
>>>>        <version>1.7.0</version>
>>>>    </dependency>
>>>> and in SU zip I have groovy-all-1.7.0.jar
>>>> ...
>>>>  2319676  02-13-10 18:29   lib/groovy-all-1.7.0.jar
>>>>    61285  02-13-10 18:29   lib/jline-0.9.91.jar
>>>>     1434  02-13-10 18:29   jms-endpoints.xml
>>>> ...
>>>>
>>>> 2) Caused by: java.lang.NoClassDefFoundError:
>>>> org/codehaus/groovy/control/CompilationFailedException
>>>>        at java.lang.Class.getDeclaredMethods0(Native Method)
>>>>        at java.lang.Class.privateGetDeclaredMethods(Class.java:2422)
>>>>        at java.lang.Class.getDeclaredMethods(Class.java:1767)
>>>>
>>>> In SU pom file I have
>>>>    <dependency>
>>>>        <groupId>org.jruby</groupId>
>>>>        <artifactId>jruby</artifactId>
>>>>        <version>1.0.3</version>
>>>>    </dependency>
>>>>
>>>> and in SU zipI have ruby-1.0.3.jar
>>>>
>>>>    34832  02-13-10 18:29   lib/asm-2.2.3.jar
>>>>    15114  02-13-10 18:29   lib/asm-commons-2.2.3.jar
>>>>  2319676  02-13-10 18:29   lib/jruby-1.0.3.jar
>>>>    61285  02-13-10 18:29   lib/jline-0.9.91.jar
>>>>     1434  02-13-10 18:29   jms-endpoints.xml
>>>>
>>>> Cite from javadoc: "
>>>> public class NoClassDefFoundError
>>>> extends LinkageError
>>>>
>>>> Thrown if the Java Virtual Machine or a ClassLoader instance tries to
>>>> load
>>>> in the definition of a class (as part of a normal method call or as part
>>>> of
>>>> creating a new instance using the new expression) and no definition of
>>>> the
>>>> class could be found.
>>>>
>>>> The searched-for class definition existed when the currently executing
>>>> class
>>>> was compiled, but the definition can no longer be found."
>>>>
>>>> It means something happed with previously loaded class.
>>>>
>>>> If I put jruby-1.0.3.jar or groovy-all-1.7.0.jar to smx/lib or
>>>> smx/lib/optial directory problem is disappeared, but such workaround is
>>>> not
>>>> acceptable for me =(
>>>>
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/Groovy-JRuby-BeanShell-spring-beans-in-SMX-tp27576646p27576646.html
>>>> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>> -----
>>> ---
>>> Gert Vanthienen
>>> http://gertvanthienen.blogspot.com
>>>
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/Groovy-JRuby-BeanShell-spring-beans-in-SMX-tp27576646p27590202.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Reply via email to