How do I reference jarred classes in my Smooks Groovy script
chrycheng Apr 4, 2012 2:30 AMI want to use mixed DOM and SAX processing with Groovy in my Smooks action. My Smooks config file is:
<?xml version="1.0" encoding="UTF-8"?> <smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd" xmlns:g="http://www.milyn.org/xsd/smooks/groovy-1.1.xsd"> <params> <param name="stream.filter.type">SAX</param> </params> <g:groovy executeOnElement="test"> <g:imports> import com.sample.Test; import com.sample.TestInJar; </g:imports> <g:script> <!-- println "*** Creating Test ***"; def test = new Test(); println "*** Created Test ***"; println "*** Creating TestInJar ***"; def testInJar = new TestInJar(); println "*** Created TestInJar ***"; --> </g:script> </g:groovy> </smooks-resource-list>
This works in my local JBossESB Server 4.7 installation but doesn't in our project's test server running JBoss SOA-P 5.0.0. The output in the server log is:
2012-04-04 11:51:37,974 INFO [STDOUT] (pool-287-thread-1) Hello: 2012-04-04 11:51:37,974 INFO [STDOUT] (pool-287-thread-1) [<test:test xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:test="http://www.example.org/test">?</ test:test>]. 2012-04-04 11:51:37,974 DEBUG [org.milyn.cdr.SmooksResourceConfigurationList] (pool-287-thread-1) Resource [Target Profile: [[null-dom]], Selector: [global-parameters], Sele ctor Namespace URI: [null], Resource: [null], Num Params: [1]] not targeted at profile [org.milyn.profile.Profile#default_profile]. Sub Profiles: [] 2012-04-04 11:51:37,975 DEBUG [org.milyn.cdr.SmooksResourceConfigurationList] (pool-287-thread-1) Resource [Target Profile: [[null-sax]], Selector: [global-parameters], Sele ctor Namespace URI: [null], Resource: [null], Num Params: [1]] not targeted at profile [org.milyn.profile.Profile#default_profile]. Sub Profiles: [] 2012-04-04 11:51:37,983 DEBUG [org.milyn.delivery.ContentDeliveryConfigBuilder] (pool-287-thread-1) Request to attempt ContentHandlerFactory creation based on a null/empty r esource type. 2012-04-04 11:51:38,024 DEBUG [org.milyn.smooks.scripting.groovy.GroovyContentHandlerFactory] (pool-287-thread-1) Failed to create Visitor class instance directly from scrip t: ========================== println "*** Creating Test ***"; def test = new Test(); println "*** Created Test ***"; println "*** Creating TestInJar ***"; def testInJar = new TestInJar(); println "*** Created TestInJar ***"; ========================== Will try applying Visitor template to script. org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, script1333511497996.groovy: 4: unable to resolve class Test @ line 4, column 20.script1333511497996.groovy: 7: unable to resolve class TestInJar @ line 7, column 25. 2 errors at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:296) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:787) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:438) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:277) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:248) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:243) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:205) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:215) at org.milyn.smooks.scripting.groovy.GroovyContentHandlerFactory.create(GroovyContentHandlerFactory.java:179) at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.addCDU(ContentDeliveryConfigBuilder.java:620) at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyCDUStrategy(ContentDeliveryConfigBuilder.java:567) at org.milyn.delivery.ContentDeliveryConfigBuilder$ContentHandlerExtractionStrategy.applyStrategy(ContentDeliveryConfigBuilder.java:533) at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.iterate(ContentDeliveryConfigBuilder.java:708) at org.milyn.delivery.ContentDeliveryConfigBuilder$SmooksResourceConfigurationTableIterator.access$300(ContentDeliveryConfigBuilder.java:687) at org.milyn.delivery.ContentDeliveryConfigBuilder.extractContentHandlers(ContentDeliveryConfigBuilder.java:481) at org.milyn.delivery.ContentDeliveryConfigBuilder.load(ContentDeliveryConfigBuilder.java:346) at org.milyn.delivery.ContentDeliveryConfigBuilder.getConfig(ContentDeliveryConfigBuilder.java:146) at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:88) at org.milyn.container.standalone.StandaloneExecutionContext.<init>(StandaloneExecutionContext.java:62) at org.milyn.Smooks.createExecutionContext(Smooks.java:356) at org.jboss.soa.esb.smooks.SmooksAction.process(SmooksAction.java:201) at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:635) at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.processPipeline(ActionProcessingPipeline.java:589) at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:419) at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:540) 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:662) 2012-04-04 11:51:38,535 WARN [org.jboss.soa.esb.listeners.message.ActionProcessingPipeline] (pool-287-thread-1) No fault address defined for fault message! To: JMSEpr [ Por tReference < <wsa:Address jms:0.0.0.0:1099#queue/quickstart_helloworld_Request_esb/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.Nami ngContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.provider.url : 0.0.0.0:1099/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jnp.int erfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:destination-name : queue/quickstart_helloworld_Request_esb/>, <wsa :ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:pe rsistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] MessageID: 4e8c9d40-ed6a-437c-a150-cfb77a250ac3 RelatesTo: jms:correlationID#4e8c9d40-ed6a-437c-a150-cfb77a250ac3
It would seem that there is a bug in JBoss SOA-P 5.0.0 which prevents it from loading jarred classes into the classpath? Or is my Smooks config file lacking some sort of setting that JBoss SOA-P 5.0.0 needs to "see" those jarred classes? I have also attached the ESB and jar projects if anyone wants to try them out.
-
test-jar.zip 2.3 KB
-
smooks-action-bug.zip 6.4 KB