Index: modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/union2.pig
===================================================================
--- modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/union2.pig	(revision 36306)
+++ modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/union2.pig	(revision 36307)
@@ -1,11 +1,11 @@
 define avro_load_input
 org.apache.pig.piggybank.storage.avro.AvroStorage(
-'input_schema_class', '$schema_input');
+'schema', '$schema_input');
 
 define avro_store_output
 org.apache.pig.piggybank.storage.avro.AvroStorage(
 'index', '0',
-'output_schema_class', '$schema_output');
+'schema', '$schema_output');
 
 input1 = load '$input_1' using avro_load_input;
 input2 = load '$input_2' using avro_load_input;
Index: modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/union3.pig
===================================================================
--- modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/union3.pig	(revision 36306)
+++ modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/union3.pig	(revision 36307)
@@ -1,11 +1,11 @@
 define avro_load_input
 org.apache.pig.piggybank.storage.avro.AvroStorage(
-'input_schema_class', '$schema_input');
+'schema', '$schema_input');
 
 define avro_store_output
 org.apache.pig.piggybank.storage.avro.AvroStorage(
 'index', '0',
-'output_schema_class', '$schema_output');
+'schema', '$schema_output');
 
 input1 = load '$input_1' using avro_load_input;
 input2 = load '$input_2' using avro_load_input;
Index: modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/origin_add.pig
===================================================================
--- modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/origin_add.pig	(revision 36306)
+++ modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/lib/scripts/origin_add.pig	(revision 36307)
@@ -1,11 +1,11 @@
 define avro_load_input
 org.apache.pig.piggybank.storage.avro.AvroStorage(
-'input_schema_class', '$schema_input');
+'schema', '$schema_input');
 
 define avro_store_output
 org.apache.pig.piggybank.storage.avro.AvroStorage(
 'index', '0',
-'output_schema_class', '$schema_output');
+'schema', '$schema_output');
 
 
 inputRecords = load '$input' using avro_load_input;
Index: modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/workflow.xml
===================================================================
--- modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/workflow.xml	(revision 36306)
+++ modules/icm-iis-collapsers/trunk/src/main/resources/eu/dnetlib/iis/collapsers/union/oozie_app/workflow.xml	(revision 36307)
@@ -52,8 +52,19 @@
         </configuration>
     </global>
 
-    <start to="union_origin_fork"/>
+    <start to="generate-schema"/>
     
+    <action name="generate-schema">
+	    <java>
+	        <main-class>eu.dnetlib.iis.core.javamapreduce.hack.AvroSchemaGenerator</main-class>
+	        <arg>${schema_input}</arg>
+	        <arg>${schema_output}</arg>
+	        <capture-output />
+	    </java>
+	    <ok to="union_origin_fork" />
+	    <error to="fail" />
+	</action>
+    
     <fork name="union_origin_fork">
         <path start="union_origin_1"/>
         <path start="union_origin_2"/>
@@ -72,10 +83,10 @@
             <script>lib/scripts/origin_add.pig</script>
 
             <param>input=${input_1}</param>
-            <param>schema_input=${schema_input}</param>
+            <param>schema_input=${wf:actionData('generate-schema')[wf:conf('schema_input')]}</param>
 
             <param>output=${workingDir}/union_origin_1/output</param>
-            <param>schema_output=${schema_output}</param>
+            <param>schema_output=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
 
             <param>origin_value=${origin_1}</param>
         </pig>
@@ -95,10 +106,10 @@
             <script>lib/scripts/origin_add.pig</script>
 
             <param>input=${input_2}</param>
-            <param>schema_input=${schema_input}</param>
+            <param>schema_input=${wf:actionData('generate-schema')[wf:conf('schema_input')]}</param>
 
             <param>output=${workingDir}/union_origin_2/output</param>
-            <param>schema_output=${schema_output}</param>
+            <param>schema_output=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
 
             <param>origin_value=${origin_2}</param>
         </pig>
@@ -125,10 +136,10 @@
             <script>lib/scripts/origin_add.pig</script>
 
             <param>input=${input_3}</param>
-            <param>schema_input=${schema_input}</param>
+            <param>schema_input=${wf:actionData('generate-schema')[wf:conf('schema_input')]}</param>
 
             <param>output=${workingDir}/union_origin_3/output</param>
-            <param>schema_output=${schema_output}</param>
+            <param>schema_output=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
 
             <param>origin_value=${origin_3}</param>
         </pig>
@@ -156,10 +167,10 @@
 
             <param>input_1=${workingDir}/union_origin_1/output</param>
             <param>input_2=${workingDir}/union_origin_2/output</param>
-            <param>schema_input=${schema_output}</param>
+            <param>schema_input=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
 
             <param>output=${output}</param>
-            <param>schema_output=${schema_output}</param>
+            <param>schema_output=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
         </pig>
         <ok to="end"/>
         <error to="fail"/>
@@ -177,10 +188,10 @@
             <param>input_1=${workingDir}/union_origin_1/output</param>
             <param>input_2=${workingDir}/union_origin_2/output</param>
             <param>input_3=${workingDir}/union_origin_3/output</param>
-            <param>schema_input=${schema_output}</param>
+            <param>schema_input=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
 
             <param>output=${output}</param>
-            <param>schema_output=${schema_output}</param>
+            <param>schema_output=${wf:actionData('generate-schema')[wf:conf('schema_output')]}</param>
         </pig>
         <ok to="end"/>
         <error to="fail"/>
Index: modules/icm-iis-collapsers/trunk/pom.xml
===================================================================
--- modules/icm-iis-collapsers/trunk/pom.xml	(revision 36306)
+++ modules/icm-iis-collapsers/trunk/pom.xml	(revision 36307)
@@ -114,6 +114,8 @@
 			<version>${iis.pig.version}</version>
 			<!-- this lib cannot be set to provided -->
 		</dependency>
+		
+	    <!-- replacing hacked pig-avrostorage with original pig -->
 	    <dependency>
 			<groupId>eu.dnetlib</groupId>
 			<artifactId>icm-iis-3rdparty-pig-avrostorage</artifactId>
@@ -120,6 +122,15 @@
 			<version>[1.0.0,2.0.0)</version>
 			<type>jar</type>
 		</dependency>
+		<!-- FIXME change to version bound with CDH5 when upgrading cluster -->
+		<!--
+		<dependency>
+			<groupId>org.apache.pig</groupId>
+			<artifactId>piggybank</artifactId>
+			<version>${iis.pig.version}</version>
+		</dependency>
+		-->
+		
 		<!-- Needed to run Pig jobs } -->
         <dependency>
             <groupId>com.google.guava</groupId>
