errbuddy / babel-asset-pipeline

babel.js transformation for asset-pipeline
10 stars 6 forks source link

Cannot cast object Exception while using bable-asset-pipeline on grails 3.1.6 and asset-pipeline 2.9.1 #17

Closed jgarcia241 closed 6 years ago

jgarcia241 commented 8 years ago

Hi there,

I'm getting an exception when compiling assets (gradle assetCompile or [gradle war] )

My current config is:

buildscript {
  ....
     dependencies{
       classpath "com.bertramlabs.plugins:asset-pipeline-gradle:2.9.1"
        classpath 'com.bertramlabs.plugins:handlebars-asset-pipeline:2.9.1'
        classpath "com.bertramlabs.plugins:asset-pipeline-grails:2.9.1"
        classpath 'net.errbuddy.plugins:babel-asset-pipeline:2.0.8'
      }
}

And the exception I'm getting is the following:

Processing File 1 of 1167 - common/Border.jsx
[  Envjs/1.6 (Rhino; U; Mac OS X x86_64 10.11.5; en-US; rv:1.7.0.rc2) Resig/20070309 PilotFish/1.2.13  ]
- Writing File
Processing File 2 of 1167 - common/ButtonRadio.jsx
- Writing File
Processing File 3 of 1167 - common/CodeMirror.jsx
- Writing File
Processing File 4 of 1167 - common/ColorPicker.jsx
:coreapp:assetCompile FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':coreapp:assetCompile'.
> Cannot cast object '[Digest Input Stream] MD5 Message Digest from SUN, <initialized>
  ' with class 'java.security.DigestInputStream' to class 'java.io.ByteArrayInputStream'

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':coreapp:assetCompile'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
    at
 .......
Caused by: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '[Digest Input Stream] MD5 Message Digest from SUN, <initialized>
' with class 'java.security.DigestInputStream' to class 'java.io.ByteArrayInputStream'
    at asset.pipeline.AbstractAssetFile.processedStream(AbstractAssetFile.groovy:145)
    at asset.pipeline.DirectiveProcessor.fileContents(DirectiveProcessor.groovy:307)
    at asset.pipeline.DirectiveProcessor$fileContents$0.callCurrent(Unknown Source)
    at asset.pipeline.DirectiveProcessor$fileContents$0.callCurrent(Unknown Source)
    at asset.pipeline.DirectiveProcessor.loadContentsForTree(DirectiveProcessor.groovy:129)
    at asset.pipeline.DirectiveProcessor.loadContentsForTree(DirectiveProcessor.groovy:124)
    at asset.pipeline.DirectiveProcessor.compile(DirectiveProcessor.groovy:67)
    at asset.pipeline.DirectiveProcessor$compile.call(Unknown Source)
    at asset.pipeline.AssetCompiler.compile(AssetCompiler.groovy:147)
    at asset.pipeline.AssetCompiler$compile.call(Unknown Source)
    at asset.pipeline.gradle.AssetCompile.compile(AssetCompile.groovy:221)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:227)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:585)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:568)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
    ... 60 more

I'm pretty sure it has to do with bable plugin, as removing seems to fix it and it fails when it is processing a JSX a 'require' jsx file that has been already processed.

Can it be a issue of version with the different plugins (grails asset pipeline and babeel-asset-pipeline)?

Any idea is very welcome.

Kind regards

peh commented 8 years ago

Hey,

sorry that took a while to reproduce but finally i have came across this issue too. i will come back to you as soon as i know what is going on.

any chance you could share your common/ColorPicker.jsx ??

peh commented 8 years ago

hey,

so till know i did not manage to fix it. but i found a workaround. the problems seems to occur when //= require ... .js files in .jsx files. so what i did as a workaround is "wrapping" my jsx components together in one .js file that is being packaged into one big js file with react and all that stuff in it. i will update the test-app to have a setup like this and will let you know as soon as i pushed this stuff