Bind Asterisk to my Java program via AGI - java

I am trying to bind Asterisk to my java program.
I followed this article (http://www.jcgonzalez.com/asterisk-handle-calls-with-java-example) to the letter. But I have an error once I call the 888 extention. It gives me the following error :
Dec 12, 2014 7:32:00 PM org.asteriskjava.fastagi.DefaultAgiServer startup
INFO: Thread pool started.
Dec 12, 2014 7:32:00 PM org.asteriskjava.fastagi.DefaultAgiServer startup
INFO: Listening on *:4573.
Dec 12, 2014 7:32:05 PM org.asteriskjava.fastagi.DefaultAgiServer startup
INFO: Received connection from /127.0.0.1
Dec 12, 2014 7:32:05 PM org.asteriskjava.fastagi.ResourceBundleMappingStrategy loadResourceBundle
INFO: Resource bundle 'fastagi-mapping' not found.
Dec 12, 2014 7:32:05 PM org.asteriskjava.fastagi.AbstractMappingStrategy createAgiScriptInstance
SEVERE: Unable to create AgiScript instance of type hello.agi: Class not found, make sure the class exists and is available on the CLASSPATH
Dec 12, 2014 7:32:05 PM org.asteriskjava.fastagi.internal.AgiConnectionHandler run
SEVERE: No script configured for URL 'agi://localhost/hello.agi' (script 'hello.agi')
I have just switched to UBUNTU, and I have no idea what this sentence means : make sure the fastagi-mapping.properties is in the class path or put it in the same folder as your compiled classes.
Please help.

Actually you have to put hello.agi mapping with actual java class file in fastagi-mapping.properties file , so that it can find the corresponding AGI file that u call from asterisk..

Your error have no any relation to AGI.
Your error say you have no class in path(or mistype)
SEVERE: Unable to create AgiScript instance of type hello.agi: Class not found, make sure the class exists and is available on the CLASSPATH
Dec 12, 2014 7:32:05 PM org.asteriskjava.fastagi.internal.AgiConnectionHandler run
SEVERE: No script configured for URL 'agi://localhost/hello.agi' (script 'hello.agi')
Note, class used WILL depend of url used when calling agi in dialplan.

Related

Deploying jenkins war file using java command

I am trying to deploy a jenkins war file. I executed the following command
java -jar jenkins.war
Below is the log file.
PS C:\Sites> java -jar jenkins.war Running from: C:\Sites\jenkins.war
webroot: $user.home/.jenkins Sep 03, 2014 6:09:15 PM winstone.Logger
logInternal INFO: Beginning extraction from war file Sep 03, 2014
6:09:28 PM org.eclipse.jetty.util.log.JavaUtilLog info INFO:
jetty-8.y.z-SNAPSHOT Sep 03, 2014 6:09:35 PM
org.eclipse.jetty.util.log.JavaUtilLog info INFO: NO JSP Support for ,
did not find org.apache.jasper.servlet.JspServlet Jenkins home
directory: C:\Users\Mathew.jenkins found at: $user.home/.jenkins
Sep 03, 2014 6:09:46 PM org.eclipse.jetty.util.log.JavaUtilLog info
INFO: Started SelectChannelConnector#0.0.0.0:8080 Sep 03, 2014 6:09:46
PM winstone.Logger logInternal INFO: Winstone Servlet Engine v2.0
running: controlPort=disabled Sep 03, 2014 6:09:46 PM
jenkins.InitReactorRunner$1 onAttained INFO: Started initialization
Sep 03, 2014 6:10:26 PM jenkins.InitReactorRunner$1 onAttained INFO:
Listed all plugins Sep 03, 2014 6:10:26 PM jenkins.InitReactorRunner$1
onAttained INFO: Prepared all plugins Sep 03, 2014 6:10:26 PM
jenkins.InitReactorRunner$1 onAttained INFO: Started all plugins Sep
03, 2014 6:10:26 PM jenkins.InitReactorRunner$1 onAttained INFO:
Augmented all extensions Sep 03, 2014 6:10:26 PM
jenkins.InitReactorRunner$1 onAttained INFO: Loaded all jobs Sep 03,
2014 6:10:42 PM org.jenkinsci.main.modules.sshd.SSHD start INFO:
Started SSHD at port 55062 Sep 03, 2014 6:10:45 PM
jenkins.InitReactorRunner$1 onAttained INFO: Completed initialization
Sep 03, 2014 6:10:45 PM hudson.WebAppMain$3 run INFO: Jenkins is fully
up and running Sep 03, 2014 6:11:48 PM
hudson.model.DownloadService$Downloadable load INFO: Obtained the
updated data file for hudson.tasks.Maven.MavenInstaller Sep 03, 2014
6:11:51 PM hudson.model.DownloadService$Downloadable load INFO:
Obtained the updated data file for hudson.tasks.Ant.AntInstaller Sep
03, 2014 6:11:52 PM hudson.model.DownloadService$Downloadable load
INFO: Obtained the updated data file for hudson.tools.JDKInstaller Sep
03, 2014 6:12:11 PM hudson.model.UpdateSite updateData INFO: Obtained
the latest update center data file for UpdateSource default
Can anyone tell me what does the command java-jar jenkins.war do?
WHere did it deploy my war file?
Which web server does it use and how does localhost:8080 point to jenkins application?
Q. Can anyone tell me what does the command java -jar jenkins.war do?
java -jar expects a jar file name, in this case, jenkins.war.
An executable Java program can be packaged in a JAR file, along with any libraries the program uses. Executable JAR files have the manifest specifying the entry point class with Main-Class: myPrograms.MyClass and an explicit Class-Path (and the -cp argument is ignored). Some operating systems can run these directly when clicked. The typical invocation is "java -jar foo.jar" from a command line
Reference: http://en.wikipedia.org/wiki/JAR_(file_format)
Q. Where did it deploy my war file?
In case it is a RHEL/CentOS installation, your war is deployed at /var/lib/jenkins
You can find out the location by reading the file /etc/init.d/jenkins. You will find a variable named JENKINS_CONFIG
JENKINS_CONFIG=/etc/sysconfig/jenkins
Q. Which web server does it use and how does localhost:8080 point to jenkins application?
In case it is a RHEL/CentOS installation, you will generally find the file here: /etc/sysconfig/jenkins. In this file, you define port on which Jenkins runs.
1) It executes the java arvhive jenkins.war (see http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jar.html)
2) From the output you posted yourself:
Running from: C:\Sites\jenkins.war webroot: $user.home/.jenkins
the user.home variable may refer to your ~ directory on Linux, or your Document and Settings on windows. See http://docs.oracle.com/javase/tutorial/essential/environment/sysprop.html
3) From the output you posted yourself:
jetty-8.y.z-SNAPSHOT
INFO: Started SelectChannelConnector#0.0.0.0:8080
See http://www.eclipse.org/jetty/. This is a web server that register a listener on port 8080.
it uses the Manifest.mf inside, if you open the war, you would understand how it runs
The Main class uses winstone http://winstone.sourceforge.net/
I would recommend to use glassfish, jetty or tomcat - for better control on configuration
there is a bug open for that
https://issues.jenkins-ci.org/browse/JENKINS-18366
Also see various container notes
https://wiki.jenkins-ci.org/display/JENKINS/Containers

jdbc issue on tomcat6 with birt

first and foremost, i know very little about tomcat6, and it's been a long time since i've done complex java work.
so my friends server went down, and i'm trying to get things working on a new system (Ubuntu 12.04, with Tomcat6).
his site had a link to some birt reports, but they aren't working. it looks like there is a problem with the jdbc mysql driver.
here is what i've got:
in catalina.sh, i've got
CLASSPATH=$CLASSPATH:/usr/share/java
in that directory, i've got (obviously, more in here than just these things):
mysql-connector-java-5.1.16.jar
mysql-connector-java.jar
mysql.jar
the birt stuff is deployed in /var/lib/tomcat6/webapps/WebViewerExample , and in there i see the WEB-INF/lib directory, to which i've also copied the mysql-connector jar files.
i set birt up so that it will log stuff, and this is the error it's giving me:
Sep 1, 2012 3:49:51 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadExtraDriver
SEVERE: refreshUrlsWhenFail: true
Sep 1, 2012 3:49:51 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadExtraDriver
SEVERE: driverClassPath: null
Sep 1, 2012 3:49:51 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager loadExtraDriver
SEVERE: Registered URLs:
Sep 1, 2012 3:49:51 PM org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager findDriver
WARNING: Failed to load JDBC driver class: com.mysql.jdbc.Driver
Sep 1, 2012 3:49:51 PM org.eclipse.birt.data.engine.odaconsumer.ConnectionManager openConnection
SEVERE: Unable to open connection.
org.eclipse.birt.report.data.oda.jdbc.JDBCException: Cannot load JDBC Driver class: com.mysql.jdbc.Driver.
at org.eclipse.birt.report.data.oda.jdbc.JDBCDriverManager.findDriver(JDBCDriverManager.java:782)
.... Huge stack trace...
so i don't know a lot about java and tomcat. any clue on what i can do to get this to work?
Jars like JDBC drivers should be added into global classpath. You need to put the mysql-connector-java-5.1.16.jar to tomcat's lib directory. Put it into ${tomcat.dir}/lib folder and remove mysql jar from WEB-INF/lib.

HTTP Status 404 while trying to run my servlet

I have a dyanmic web project with a DAO FileDao in package de.vogella.wtp.filecounter.dao; and a servlet FileCounter in package de.vogella.wtp.filecounter.servlets; packages respectively.
I was trying to run the servlet and changed the ports 8088 since my 8080 is already occupied with some other application. When I run this servlet I get the below error in console:
Jun 1, 2012 2:39:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting propert
y 'source' to 'org.eclipse.jst.jee.server:de.vogella.wtp.filecounter' did not fi
nd a matching property.
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8088"]
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8010"]
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 380 ms
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8088"]
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8010"]
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 260 ms
This is the error:
HTTP Status 404 - /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter
--------------------------------------------------------------------------------
type Status report
message /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter
description The requested resource (/de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/7.0.27
Any guesses on what went wrong?
HTTP Error 404 means page or resources not found.
So you just typed incorrect URL. just check URL in web.xml and the URL typed in browser.
Here, maybe FileCounter class is misplaced. check it too.
I was doing the same tutorial and had the same problem. I guess it's a pretty common tutorial, so I'll leave my answer here.
In my installation, Eclipse does not create a web.xml by default. When creating a Servlet, Eclipse uses annotations for mapping. I accidentaly erased the annotation when copying the tutorial's code. I guess you did the same.
To solve it I included a #WebServlet annotation before the class. Like this:
#WebServlet("/FileCounter")
public class FileCounter extends HttpServlet {
...

Tomcat auto unpack WAR file changed the last modified time of files

I experienced an issue when I tried to deploy a WAR file to tomcat.
While the auto unpack process from tomcat, the last modified date of unpack files were being modified.
The date of unpack web app. files became 12 hours faster, and this results several miscellaneous errors.
I tried to unpack manually via jar -xvf, the last modified date of files remain unchanged.
I also tested in a local tomcat (same timezone with dev. env.), nothing changed in last modified date.
It seems the tomcat timezone issue, does setup on tomcat I can do to solve out this issue?
Great thanks for any help.
Environment:
Tomcat 6 on linux, with GMT-4 timezone both set in server and tomcat
the WAR file created by machine with GMT+8 timezone set
In my case, the application was setting the default timezone from within Tomcat as the application was being initialized. The difference introduced by the change in timezones matched the offset in the file modification times.
I was surprised that any code within the app could run before being unpacked, but the Tomcat container does give the application an opportunity to run initialization code prior to all files being unpacked.
Look for an occurrence of TimeZone.setDefault() and try removing the call or moving the call later in the initialization sequence.
Helpful clues:
This JSP told me that the application was always running with a specific timezone regardless of the environment settings:
<html>
<body>
<h2>Current Timezone</h2>
<% java.util.Date date = new java.util.Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("zzz"); %>
<%=sdf.format(date)%>
</body>
</html>
In the log files, I could see the instant the timezone was changing (four hour jump). It happens at the time the app is loaded.
Note: Once set, the timezone will stay set until Tomcat is restarted.
Sep 18, 2015 2:34:26 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8443
Sep 18, 2015 2:34:26 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 285 ms
Sep 18, 2015 2:34:26 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
Sep 18, 2015 2:34:26 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.24
Sep 18, 2015 2:34:26 PM org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive myWebapp.war
Sep 18, 2015 6:34:30 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok)
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: struts: []: Verifying ModuleConfig for this module
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: struts: []: Verification of ModuleConfig has been completed
Sep 18, 2015 6:34:34 PM org.apache.catalina.core.ApplicationContext log
INFO: struts: []: Verifying ModuleConfig for this module

An incompatible version 1.1.12 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17

I downloaded Apache Tomcat 7.x. When I add this Tomcat in Eclipse I get this error:
Jan 25, 2011 3:21:05 PM org.apache.catalina.core.AprLifecycleListener init
SEVERE: An incompatible version 1.1.12 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17
Jan 25, 2011 3:21:05 PM org.apache.catalina.core.AprLifecycleListener init
SEVERE: An incompatible version 1.1.12 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17
Jan 25, 2011 3:21:05 PM org.apache.catalina.core.AprLifecycleListener init
SEVERE: An incompatible version 1.1.12 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17
Jan 25, 2011 3:21:05 PM org.apache.catalina.core.AprLifecycleListener init
SEVERE: An incompatible version 1.1.12 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17
Jan 25, 2011 3:21:05 PM org.apache.catalina.core.AprLifecycleListener init
SEVERE: An incompatible version 1.1.12 of the APR based Apache Tomcat Native library is installed, while Tomcat requires version 1.1.17
Jan 25, 2011 3:21:08 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 25, 2011 3:21:08 PM org.apache.coyote.AbstractProtocolHandler init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 25, 2011 3:21:08 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 3054 ms
Jan 25, 2011 3:21:08 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 25, 2011 3:21:08 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.6
Jan 25, 2011 3:21:08 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 25, 2011 3:21:08 PM org.apache.coyote.AbstractProtocolHandler start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 25, 2011 3:21:08 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 251 ms
How can I solve this problem?
When I open the localhost:8080/manager/html it shows the following error:
HTTP Status 404 - /manager/html
type Status report
message /manager/html
description The requested resource (/manager/html) is not available.
Apache Tomcat/7.0.6
The first error certainly sounds like a version mismatch. The APR library is a library linked in at runtime based on your path (which itself can be based on where you execute Tomcat from). It sounds like you have the APR library for Tomcat 6. It's possible that Eclipse is providing this APR library.
Tomcat ships with an APR library but in order to ease installation Tomcat doesn't automatically modify the path to point at the APR library. The Eclipse Tomcat integration may (I'm not sure on this one, haven't used the integration before) include the APR libraries to make it easier to use Tomcat.
Check and make sure that Eclipse isn't configured to use an earlier version of Tomcat and if it is, either upgrade Eclipse to Tomcat 7 or downgrade Tomcat to the version specified in Eclipse.
If you can't figure it out then you don't necessarily have to worry about it at the moment. Tomcat should work anyways without the APR libraries. The only benefit you will get from the APR libraries is increased performance and since this is probably the start of your project that doesn't have to be worked out right away.
The second issue, the /manager/ page, could be Tomcat configuration. Tomcat won't actually display the manager page (and it will give you that error) unless users have been configured with manager permissions.
Try going to just / (i.e. http://localhost:8080), that page should load regardless of user configuration.
In my case I had inadvertently installed the APR library when I install once Tomcat locally on my Linux using the package manager. On Debian/Ubuntu this installed the APR package for a different Tomcat version (the one bundled with your distribution) which caused this error.
After simply
sudo apt-get purge libtcnative-1
The error was gone.

Categories