Using JavaSounds from tomcat - java

I'm trying to write a Java EE application that records sound from the input on the server.
My code works fine when debuging, and running on the server as myself (both ubuntu) however when it's running from the web sever I get an exception:
javax.sound.sampled.LineUnavailableException
at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openImpl(PulseAudioMixer.java:714)
at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:588)
at org.classpath.icedtea.pulseaudio.PulseAudioMixer.openLocal(PulseAudioMixer.java:584)
at org.classpath.icedtea.pulseaudio.PulseAudioMixer.open(PulseAudioMixer.java:579)
at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:95)
at org.classpath.icedtea.pulseaudio.PulseAudioTargetDataLine.open(PulseAudioTargetDataLine.java:111)
at org.classpath.icedtea.pulseaudio.PulseAudioTargetDataLine.open(PulseAudioTargetDataLine.java:130)
I've tried to add the tomcat user to the audio group (which some documentation suggested) but it's still throwing the exception. I think the only difference must be the environment, but I'm at a loss for where the problem might be.

I'm assuming that you've got the appropriate JARs in the CLASSPATH - either in your application WEB-INF/lib or in the Tomcat /lib.
The fact that you're trying to open something suggests that maybe you have a path problem. Web apps can't depend on an absolute file path, because they can't know where a WAR file will be installed. So it's better to use a relative path and get resources as streams. Perhaps there's a way to do it with this library.

I've managed to get this working now - but thank for the help.
In the end it was a OS level issue, under ubuntu only users in the audio group can access sound resources when not logged in (https://wiki.ubuntu.com/Audio/TheAudioGroup) and to connect to pulse audio it looks like you need X11 auth of some kind. After those changes it require a restart so tomcat could grab the sound device before anything else did.

Related

PHP process (started by the PHP-Java bridge) getting terminated unexpectedly

I have an application running in Tomcat 6.0.36. There was a requirement to implement CMS (content management) in our application. For this, a third party vendor is signed up to provide the static content. The CMS pages are written in PHP and hence it became necessary for us to render the PHP content using tomcat server.
To achieve this, I downloaded the “JavaBridgeTemplate621.war” (from http://sourceforge.net/projects/php-java-bridge/files/Binary%20package/php-java-bridge_6.2.1/JavaBridgeTemplate621.war/download) and deployed it in the webapps folder. Later I renamed the exploded folder and renamed it to ‘cms’ (deleted the JavaBridgeTemplate621.war file this time). The PHP files placed in this ‘webapps/cms’ folder is rendered properly by the tomcat server. This was the exact requirement.
While starting the tomcat server, the PHP-Java bridge also created a few Java processes. On the LIVE environment, these processes were killed 3-4 days after the deployment(restart) happened.
The error in the catalina log is,
PHP application terminated unexpectedly, have you started php-cgi with the environment setting PHP_FCGI_MAX_REQUESTS=5000? Error: php.java.bridge.http.FCGIConnectionException
php.java.bridge.http.FCGIConnectionException
at php.java.bridge.http.FCGIConnectionOutputStream.flush(FCGIConnectionOutputStream.java:87)
at php.java.bridge.http.FCGIConnectionOutputStream.close(FCGIConnectionOutputStream.java:71)
at php.java.servlet.fastcgi.FastCGIServlet.parseBody(FastCGIServlet.java:357)
Can someone help me understand the root cause of this issue?
The ‘memory_limit’ variable is seen to have the value 64M. Is it too low a value ? If so, what would be an ideal value that needs to be set ?
How will the setting ‘expose_php=off’ affect ?

Implementing Desktop Screenshare using red5 server

I'm trying to setup a local red5 streaming server to stream my desktop screen to multiple devices with no luck. the setup will eventually look like this.
mylaptop screen (live stream)=> red5 server <= client devices pulling the live stream
note: red5 server is ubuntu based, client devices will eventually be android tablets but any device will do just fine for now
This is what I have so far:
1) Installed red5-server and all of its dependencies using apt-get install red5-server
2) Downloaded red5-screenshare applet from http://code.google.com/p/red5-screenshare/
and followed all the steps there
3) After I start my screensharing, visiting the client link http://[my_red5_server:5080]/screenshare/screenviewer.html produces error #2032
chrome developer tools says
GET http://my_red5_server:5080/screenshare/textLayout_1.1.0.604.swz 404 Not Found
4) so I downloaded the textLayout file from adobe, placed it into the screenshare folder but I still get the same 404 not found error
Is my setup wrong? I'm not sure how to debug this since there's very few documentation on the matter and I reeeeally dont want to write my own java app and reinvent the wheel
Also if any of you happy hackers have found a different solution to locally screenshare I'm all ears
Thank you for taking the time to help.
The error your getting is because the flex "swz" files cannot be downloaded from Adobe. This was happening to us at work this week and we solved it by finding the offending files via google and placing them on our server. Download the swz files and place them in the same directory as your swf file.

Red5 server failing to start up due to java.rmi.server.ExportException: internal error: ObjID already in use

I have recently started to learn about Red5 server. I am following this tutorial to develop a simple video chat app: http://tharas.wordpress.com/2010/01/19/chat-application-with-red5-and-flex/.
I am able to create the flex client.
For the service side, I have created a Dynamic Web Project in Eclipse. Then manually copied the WEB-INF folder files and the Application.java file from the source code zip given in the above tutorial page at the bottom.
After that when I am trying to start the Red5 server, it is failing with the error: Caused by: java.rmi.server.ExportException: internal error: ObjID already in use.
I searched many forums for hours to resolve this. What I could figure out is, it is possible that the server start up script is trying to create RMI registry entry in the JVM twice, which is not allowed. One forum suggested editing the /etc/hosts file. One forum suggested commenting out the rmiregistry creation in red5.properties and delete the JMX part in red5-common.xml. But nothing worked!
I have installed Red5 version 1.0 in Windows 8. I have installed the Red5 Eclipse plugin and running the server from within Eclipse.
Any help is appreciated. If you need, I can post the detailed server log.
The issue here is that more than one instance of Red5 is being started or the RMI registry already exists. I suggest editing your red5/conf/red5.properties file and changing this entry to false:
jmx.registry.create=true
This should "hide" the error and allow you to continue; the real fix would be to prevent spawning multiple instances within Eclipse.

Servlet throws file not found excp when accessing network drive

I've a production env and test env. Production has win2k3+tomcat 6.0+ and network drive mapped to a drive letter for easy access (z:\app instead of \symba\files\app). My test env has windows xp (all the software is same including the source code for servlet) and test also has the same drive letter mapping to the network drive.
Tomcat is running with the same user id in both the systems and am able to access the file via windows explorer in the test m/c and production m/c.
Now the servlet in the windows xp m/c (test m/c) throws a file not found exception if try to access an existing file (reachable via windows explorer). The servlet in production is same as in test env and production servlet happily gives the file when i request it and does not throw any error what so ever.
I've see some posts that using drive letter is not a good idea and should use UNC paths instead and i've not tried this yet. I want to know the reason why test servlet fails to get file whereas production servlet works fine.
Thank you very much for your time and help
Bo
Are you running the application server as a service? Drive letter assignments are reliable only if you use interactive programs not services.
A couple of years ago, I tried to resolve a quite identical problem but, at last, I gave up and I used JCIFS to access the files.
If you run Tomcat with a security manager, the web app code is according to the default configuration only allowed file access to its deployment directory. If you want to change the application policies, you can do that in conf/catalina.policy or you can disable the security manager, if you want your web app code to gain all privileges.
You might want to consider running the Tomcat service as the user who has access to the mapped drive.
As pointed out by andcoz, the mappings will not apply for the SYSTEM user in Windows that I presume is being utilized for running Tomcat. You could change the service configuration to run as the user owning the drive mapping and verify if the failure continues to occur.
Related:
FileNotFoundException thrown when the file does exists.

RAD - Websphere Application server won't start

I am having issues with RAD7.
My server will not start for me today. I am working from home and connected to the VPN. Everything works except my server in RAD. It worked fine yesterday in work and had previously worked when I was at home but that was a few weeks ago.
Are there any settings that I should look out for? I have disabled my proxy settings in RAD and turned off everything in my firewall. I can ping all the DBs that the server is connecting to.
I have even removed all the projects from the server and it will still not start. It keeps trying and then times out after 300s.
Any suggestions?
I got a similar error while Starting WebSphere Commerce server v7. This error in my case was caused by me increasing the Maximum Heap size to 2096. I reduced the heap size to 1536 and it worked. None of the errors/trace files indicated this problem.
I had this problem too. Double-click on the server to open the server 'OVERVIEW' tab/view. Scroll down to the section under 'Optimize server start for development:'; uncheck 'Start server with a generated script'. This worked for me. good luck.
I have had this problem once before. I wasn't able to figure out what went wrong, but deleting that server and creating a new one (under Window -> Preferences -> Server -> WebSphere Application Server) fixed the problem.
Re the file not found exception. Make sure the directory path in Windows is of the CoRRectCase, e.g., GALFTGA342130Node01Cell-> galftga342130Node01Cell. I've encountered this on various RAD installations.
With reference to your following comment -
I looked at startserver.log and I saw a file not found exception for this file C:\IBM\SDP70\runtimes\base_v61\profiles\AppSrv01\config\cells\GALFTGA342130Node0‌​1Cell\nodes\GALFTGA342130Node01\serverindex.xml. I checked and the file exists but when I try to open it, I get told access denied.
this link may help you in understanding the problem. it says -
This is a permissions issue caused by the automatic port detection routine. If any profiles already exist and were created as a different user, the port detection routine will try to open the serverindex.xml file in each profile and will fail.
You should set appropriate permissions for your user.
after working several hours in my case I found the solution I hope it works for you ; change my JDK to alternate JRE

Categories