10 Replies Latest reply: May 13, 2014 8:13 AM by Veeraprathaban Rajamani RSS

    Sound captcha - could not write audio file: file type not supported: WAVE

    Anthony Cheung Newbie

      Hi,

       

      I am migrating my application from JBoss 4.2 to JBoss 7 on the same machine.  My application involves generation of sound captcha through JCaptcha library. The deployment on JBoss 7 is successful but with the following error in the server log

       

      ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/myApp]] (MSC service thread 1-2) StandardWrapper.Throwable: java.lang.IllegalArgumentException: could not write audio file: file type not supported: WAVE

                at javax.sound.sampled.AudioSystem.write(AudioSystem.java:1306) [rt.jar:1.6.0_20]

                at com.octo.captcha.sound.SoundCaptcha.<init>(SoundCaptcha.java:42) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.sound.speller.SpellerSound.<init>(SpellerSound.java:25) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.sound.speller.SpellerSoundFactory.getSoundCaptcha(SpellerSoundFactory.java:94) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.engine.sound.SoundCaptchaEngine.getNextSoundCaptcha(SoundCaptchaEngine.java:121) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.engine.sound.SoundCaptchaEngine.getNextCaptcha(SoundCaptchaEngine.java:63) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.service.AbstractCaptchaService.generateAndStoreCaptcha(AbstractCaptchaService.java:156) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.service.AbstractManageableCaptchaService.generateCountTimeStampAndStoreCaptcha(AbstractManageableCaptchaService.java:342) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.service.AbstractManageableCaptchaService.generateAndStoreCaptcha(AbstractManageableCaptchaService.java:331) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.service.AbstractCaptchaService.getChallengeForID(AbstractCaptchaService.java:73) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.service.AbstractCaptchaService.getChallengeForID(AbstractCaptchaService.java:55) [jcaptcha-1.0-all.jar:]

                at com.octo.captcha.service.sound.AbstractManageableSoundCaptchaService.getSoundChallengeForID(AbstractManageableSoundCaptchaService.java:48) [jcaptcha-1.0-all.jar:]

       

      I have added some debug codes to check the supported audio file type of the machine

      boolean test = javax.sound.sampled.AudioSystem.isFileTypeSupported(AudioFileFormat.Type.WAVE);

      logger.info("Support WAVE = " + test);

       

      The output is different in JBoss 4.2 and JBoss 7

      JBoss 4.2:

      Support WAVE = true

       

      JBoss 7:

      Support WAVE = false

       

      I have no idea why the output is different as they are running on the same machine and even the same JAVA_HOME

       


        • 1. Re: Sound captcha - could not write audio file: file type not supported: WAVE
          Randahl Fink Isaksen Novice

          I have the exact same problem. Neither WAVE nor AIFF seems to be supported. If I run some java sound code in a desktop java application everything works fine, but inside JBoss no formats are supported. Has anyone got an idea why this is so?

          • 2. Re: Sound captcha - could not write audio file: file type not supported: WAVE
            Darran Lofthouse Master

            It sounds like it could be a classloading issue where the capabilities are not being found on the classpath - can you run a stand alone client that works with verbose logging of class loading to identify exactly what is loaded on a successful run?

            • 3. Re: Sound captcha - could not write audio file: file type not supported: WAVE
              Randahl Fink Isaksen Novice

              Thanks Darran.

               

              I just did a verbose run, but I am not certain what to look for – as you would expect, I get thousands of lines of output.

               

              As I understand it JavaSound uses the Service Provider Interface (SPI) to automatically detect the jars that add sound capabilities to the JavaSound system. But in my standalone desktop app I have not included any jars on my own, so the support for WAV and AIFF must be part of Java on my system (I am on a Mac running Java 1.6.0). – So the weird thing is, why are these capabilities invisible when running inside JBoss? After all, JBoss is running on top of the same Java installation on the same machine as my desktop app (which works).

               

              I am puzzled...

              • 4. Re: Sound captcha - could not write audio file: file type not supported: WAVE
                Randahl Fink Isaksen Novice

                Part of my output:

                [Loaded javax.sound.sampled.Port$Info from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded javax.sound.sampled.Port from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded javax.sound.sampled.TargetDataLine from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded com.sun.media.sound.AbstractDataLine from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded com.sun.media.sound.SimpleInputDevice$InputDeviceDataLine from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded com.sun.media.sound.Toolkit from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded com.sun.media.sound.HAEShutdownHook from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded com.sun.media.sound.HAEShutdownHook$1 from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded javax.sound.sampled.LineEvent from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded javax.sound.sampled.LineEvent$Type from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                [Loaded com.sun.media.sound.CircularBuffer from /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar]

                • 5. Re: Sound captcha - could not write audio file: file type not supported: WAVE
                  Darran Lofthouse Master

                  It looks like the classes you need are excluded from the modules definitions so the classloader is excluding them from view.

                   

                  I would suggest editing modules/javax/api/main/module.xml and adding an entry for javax.sound

                  Then edit modules/sun/jdk/main/modules.xml and add an entry for com.sun.media

                   

                  Also double check the output to be sure there are no other obscure packages with sound / media related classes being loaded.

                  • 6. Re: Sound captcha - could not write audio file: file type not supported: WAVE
                    Randahl Fink Isaksen Novice

                    You are probably right. However, I actually opted for changing the architecture instead so this sound conversion work is not done inside my EJBs. Thanks anyway.

                    • 7. Re: Sound captcha - could not write audio file: file type not supported: WAVE
                      Anthony Cheung Newbie

                      Thanks Randahl and Darran.

                       

                      Finally I got the solution.

                       

                      Darran is right, it requires to edit the modules/sun/jdk/main/modules.xml and add an entry for com.sun.media.

                       

                      Moreover, copy the following files to modules/sun/jdk/main/service-loader-resources/META-INF/services/

                      • javax.sound.sampled.spi.AudioFileReader
                      • javax.sound.sampled.spi.AudioFileWriter
                      • javax.sound.sampled.spi.FormatConversionProvider
                      • javax.sound.sampled.spi.MixerProvider

                      These files can be found inside /jre/lib/resources.jar of JDK, under /META-INF/services/

                      • 9. Re: Sound captcha - could not write audio file: file type not supported: WAVE
                        Rocco Ilaria Newbie

                        The entry to add in modules/sun/jdk/main/modules.xml is com.sun.media.sound [jBoss 7.1]

                        • 10. Re: Sound captcha - could not write audio file: file type not supported: WAVE
                          Veeraprathaban Rajamani Newbie

                          Hi,

                            I'm also having same problem with jboss-as-7.1.1-final.  But its working fine with Jboss-as-5.1.0 .

                            As you mentioned before tried supported format its returning FALSE. I have resource.jar inside jre/lib can give some suggestion about this,

                           

                          javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input stream

                          17:27:39,220 ERROR [stderr] (http--192.168.1.65-8080-1)     at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1119)

                          17:27:39,221 ERROR [stderr] (http--192.168.1.65-8080-1)     at amazonupload.util.ConversionUtil.decodeAudioFile(Unknown Source)

                          17:27:39,221 ERROR [stderr] (http--192.168.1.65-8080-1)     at amazonupload.AmazonAudioUpload.amazonUpload(Unknown Source)

                          17:27:39,222 ERROR [stderr] (http--192.168.1.65-8080-1)     at com.musicnotes.apis.controllers.UploadController.audioUpload(Unknown Source)

                          17:27:39,223 ERROR [stderr] (http--192.168.1.65-8080-1)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                          17:27:39,223 ERROR [stderr] (http--192.168.1.65-8080-1)     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

                          17:27:39,224 ERROR [stderr] (http--192.168.1.65-8080-1)     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

                          17:27:39,225 ERROR [stderr] (http--192.168.1.65-8080-1)     at java.lang.reflect.Method.invoke(Method.java:606)

                          17:27:39,225 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)

                          17:27:39,226 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)

                          17:27:39,227 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)

                          17:27:39,228 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)

                          17:27:39,229 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)

                          17:27:39,229 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)

                          17:27:39,230 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)

                          17:27:39,231 ERROR [stderr] (http--192.168.1.65-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)

                          17:27:39,232 ERROR [stderr] (http--192.168.1.65-8080-1)     at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                          17:27:39,232 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)

                          17:27:39,233 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                          17:27:39,234 ERROR [stderr] (http--192.168.1.65-8080-1)     at com.musicnotes.apis.filter.ResponseFilter.doFilter(Unknown Source)

                          17:27:39,234 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:280)

                          17:27:39,235 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)

                          17:27:39,237 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)

                          17:27:39,237 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)

                          17:27:39,238 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153)

                          17:27:39,239 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155)

                          17:27:39,240 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)

                          17:27:39,241 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

                          17:27:39,241 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368)

                          17:27:39,242 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)

                          17:27:39,243 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671)

                          17:27:39,244 ERROR [stderr] (http--192.168.1.65-8080-1)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930)

                           

                          Thanks in advance.

                           

                           

                          Regards,

                           

                          Veeraprathaban.R