Sound issues with tomcat - ubuntu 14.04 set up

123 views
Skip to first unread message

Geir Amund Svan Hasle

unread,
Jan 19, 2017, 5:51:31 PM1/19/17
to owlcms
Hi! 

I am having some issues with the sound on my set up. The owlcms system is running just fine but it will not play any sound ever. No time signals, no down signals no nothing. I am wondering if I am missing some settings in my set up or if this is a known issue with Java Sound on linux. I have tried setting the output device for the platform under Administration and then selecting this platform for the test group, but there is no devices to chose from the menu. This seems a little suspicious to me, but all other sound on my laptop is working just fine. I have used both OpenJDK 6 and 7, with the same result. See the attached file for a sample of my catalina.out when I run a competition and let the time run out on the lifters 

Any pointers will be much appreciated!

Regards,
Geir Amund
catalina.out

Jean-Francois Lamy

unread,
Jan 19, 2017, 9:50:12 PM1/19/17
to Owlcms
I have no easy way to investigate this at present -- sounds certainly worked a few years back when I did the port. Only glitch I remember was that the final "no more time" buzzer being occasionally cut a tiny bit short because of its parent thread being stopped.
I have a vague reminiscence of using Oracle's JDK due to lack of documentation regarding sound support on OpenJDK, so that could be something you might want to try.

The drop-down shows the list of available mixers as returned by AudioSystem.getMixerInfo() -- if there are none listed, this would tend to indicate a configuration issue, or incomplete support in OpenJDK.

jfl


--

---
You received this message because you are subscribed to the Google Groups "owlcms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owlcms+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Jean-François Lamy

Geir Amund Svan Hasle

unread,
Jan 20, 2017, 4:20:30 AM1/20/17
to owlcms
If i compile and run (javac CheckMixerInfo.java; java CheckMixerInfo) the attached CheckMixerInfo.java it gives the output provided in mixerinfo.out. The call to AudioSystem.GetMixerInfo() clearly returns a non-empty list on my system. I get the same output with both openJDK 6 and 7.  I will configure wit oracle java to see if there's any change in behavior then.

Geir A.
To unsubscribe from this group and stop receiving emails from it, send an email to owlcms+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Jean-François Lamy
CheckMixerInfo.java
mixerinfo.out

Geir Amund Svan Hasle

unread,
Jan 20, 2017, 6:30:08 AM1/20/17
to owlcms
So, i set it up with oracle java 7 and at least got JavaSound working. The attached SoundClipTest.java successfully compiles and runs on my system and plays the correct sound. Now, I have set JAVA_HOME=/usr/lib/jvm/java-7-oracle in /etc/environment and also set JAVA_HOME=/usr/lib/jvm/java-7-oracle explicitly in /etc/default/tomcat7. Now, when I run a test comp and call a lifter the clock starts running, but the clock just stops when it's time to play the warning sound (clock freezes at 31s). See the attached  catalina-after-timer-stop.out for the catalina.out directly after this happens. If I no go to Administration -> Platform and press "Edit" I get an "Internal Error" message on screen. If i hit "click here" it takes me to the previous screen with the red message box saying "Mixer not supported: null". See the attached screenshots for the on screen errors. catalina.out directly after this is included in catalina-after-platform-access.out.

With oracle java 6 it simply runs with no erros (but also with no sound, just as with openJDK 6 and 7). The SoundClipTest.java also compiles and runs with these settings, but no sound is played. 

Any thoughts on this? Let me know if I can provide you with any other information.

Geir A.
catalina-after-platform-access.out
catalina-after-timer-stop.out
internal-error.png
mixer-null.png
SoundClipTest.java

Jean-Francois Lamy

unread,
Jan 20, 2017, 7:15:10 PM1/20/17
to Owlcms
This is rather puzzling, since the test I use to include the mixer in the list is exactly the ability to generate the Tone used at 30sec.
If there are several mixers listed can you try the others ?

Since I take it you have a CS background, here's what is going on... The test I use to determine the mixers is as follows

    public static List<Mixer> getOutputs() {
        List<Mixer> mixers = outputs(AudioSystem.getMixer(null), AudioSystem.getMixerInfo());
        return mixers;
    }

    protected static List<Mixer> outputs(Mixer defaultMixer, Mixer.Info[] infos) {
        List<Mixer> mixers = new ArrayList<Mixer>();
        for (Mixer.Info info : infos) {
            Mixer mixer = AudioSystem.getMixer(info);

            try {
                if (!mixer.getMixerInfo().toString().startsWith("Java")) {
                    AudioFormat af = new AudioFormat(8000f, 8, 1, true, false);
                    if (AudioSystem.getSourceDataLine(af, info) != null) {
                        mixers.add(mixer);
                    }
                }
            } catch (IllegalArgumentException e) {
            } catch (LineUnavailableException e) {
            }
        }
        return mixers;
    }

and the code that generates the Tone (and most likely generates the exception you are seeing), is as follows
(the red boxed exceptions are "brute-force" converted to RuntimeExceptions so they percolate all the way up to the UI.

        af = new AudioFormat(8000f, 8, 1, true, false);
        try {
            sdl = AudioSystem.getSourceDataLine(af, mixer.getMixerInfo());
        } catch (LineUnavailableException e) {
            throw new RuntimeException(e);
        }


My suggestion is to take the code for determining the output and figuring out which AudioFormat parameters work on your system.
I could then make them into configuration parameters or figure out something more robust.


Thanks for your persistence.

jfl

Geir Amund Svan Hasle

unread,
Apr 18, 2017, 8:18:07 AM4/18/17
to owl...@googlegroups.com
Hi!

I've finally been looking into this again. I've played around with the snippets you gave me in your last answer and I have found the following: The program in SoundTestJF.java generates the output in SoundTestJF.out. I getMixerInfo() gives me four mixers on my system. The code above eliminates all but one of these. Only the default mixer is left. If we now take a look at the code in SoundClipTest.java, this code performs the above tests and tries to play the final warning sound on each of the mixers that are left (only one). The code is successful in doing so and I can hear the sound play on my system. I still see no audio output options under the Administration -> Platform tab. If I run a program that simply loops through all the available mixers and tries to play the sound on each of them, only the default mixer is successful. The remaining mixers throws exceptions shown in Exception.out. 

I don't know if this is of any help. If you need me to try anything else, let me know. 

Geir A. 

--
SoundClipTest.out
SoundClipTest.java
TestSoundJF.out
TestSoundJF.java
Exception.out

Geir Amund Svan Hasle

unread,
Apr 18, 2017, 10:31:54 AM4/18/17
to owl...@googlegroups.com
I now have sound working on ubuntu 14.04 with tomcat7 and java 1.8 by doing the following three steps
  1. Add tomcat7 to audio group by sudo adduser tomcat7 audio
  2. Add the following line to each of the classes in /var/lib/tomcat7/conf/policy.d/03catalina.policy (see attached file for example): permission javax.sound.sampled.AudioPermission "TomcatSound", "play";
  3. Insert external speaker. 
  4. Sound works. I can now select default mixer from the menu under Administration -> Platforms.

Geir A. 
03catalina.policy

Geir Amund Svan Hasle

unread,
Apr 24, 2017, 5:33:38 AM4/24/17
to owl...@googlegroups.com
It seems that I did something wrong when testing and it turns that step 1 in the previous mail is sufficient. Adding the tomcat7 user to the audio group ensures that the webapp can access the audio system on the machine without being logged in (https://wiki.ubuntu.com/Audio/TheAudioGroup). After adding the tomcat7 user to the audio group with the command "sudo adduser tomcat7 audio", reboot the system and then go to Administration -> Platforms in the webapp. Choose edit and select the proper output device to the correct platform. This approach should hold for all debian based linux distros, but I have only tested it with ubuntu 14.04 myself. 

I hope you will consider adding this small alteration under the linux section of the install manual. It may save some poor soul from some frustrating trial and error in the future :) 

Thanks!

Geir A.

Jean-Francois Lamy

unread,
Apr 24, 2017, 7:14:07 AM4/24/17
to Owlcms
Will do.   

But I am currently (slowly) rewriting owlcms to avoid the issue entirely -- modern browsers now have a proper sound API and the framework I used in 2009 has a new version that makes many things much simpler, including remote procedure calls from the browser.  The next version handles sound and refereeing buttons in JavaScript in the browser, so no more running of long cables, and no lag.

To unsubscribe from this group and stop receiving emails from it, send an email to owlcms+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

---
You received this message because you are subscribed to the Google Groups "owlcms" group.
To unsubscribe from this group and stop receiving emails from it, send an email to owlcms+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages