Monday, March 26, 2007

org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
Type mismatch: cannot convert from null to int

Generated servlet error:
Cannot cast from Object to int

Suddenly when I deployed my app I started getting the above errors on loading my jsp pages.

It took a couple of hours but I tracked it down. To do so I had to pre compile my jsps since the default output to browser and to catalina.out id not show enough details. luckily my app is based on appfuse so I was able toset precompile="true" in properties.xml and run ant compile-jsp . For other people you will have to compile your jsp using javac and setting your classpath etc on the command line. But you should be able to see where the compile error is occurring.

In my case I include a bunch of constants in my web page as attributes. They are all strings, but one of the new ones I had added,was, gasp, an int. This threw the errors above.

Sunday, March 25, 2007

Tomcat Manager

I do all my development work on a Windows 2000 machine,and my production server is a fedora core 2 linux box.

With my last project I always transfered the source files to the server and compiled deployed my apps from there. This was necessary because of some path/compiler issues and because my application interfaced with a jabber server on the same box.

But one of the projects I am working with now, doesn't have those characteristics. So I want to use my ant build script to deploy my web app using the Tomcat manager web application.

Setting up the Tomcat manager however didn't work out of the box. I added the following lines to server.xml
<context path="/manager" debug="0" privileged="true" docbase="${catalina.home}/server/webapps/manager">
</context>


I kept getting 404 errors for the HTMLManagerServlet everytime I tried to access the manager.

So eventually I removed the above lines from server.xml, and added the default manager.xml file to
$CATALINA_HOME/conf/Catalina/[hostname]

Then it worked.

After that the win2000 compiled classes had a java version mismatch with the fedora core box Java version.

so I set the target attribute of the javac ant task to target="1.5" (the version on the fedora core box) and recompiled/deployed all and it worked!

Friday, March 16, 2007

Setting up Asterisk IPKall and A2Billing

It took quite a bit of tinkering to get my ipkall numbers (DIDs) to both forward to myAsterisk box, and then for A2Billing to pick them up and forward them on to my home phone.

My extensions.conf now looks like this:

And my sip.conf looks like this.

Initially though my calls were set to forward to my sip box from ipkall, they didn't arrive. But after turning on sip debugging, I could see that they were arriving but they were not being matched in my dial plan. I had set the sip username in ipkall to "ipkall" and had created a friend entry in sip.conf with the username ipkall. That were 2 problems, that showed my lackof understanding of what I was really doing.

Firstly the dial plan as it is now, only matches numeric. So my sip user has to be a numeric username. Once I set up my username as a numeric one, the calls started to arrive.

But the problems were not over here. The DID that was called was not being matched by A2Billing so the followme functions were not working. After poring over the logs for while, I realised that the did information never arrives at all. It may just be my setup, but the dnid arrives, however that contains the numeric "username" I set up earlier. A2Billing seeks to match with the DNID.

So over at IPKall I set the numeric username to the actual DID number, which means that the DNID field will be equivalent to the DID, when it arrives at asterisk. This is then passed on to the a2billing agi script which matches, and my calls are forwarded.

In hindsight it is quite simple, but that I did not really know what I was doing , hampered me. Also I think I need to look a little more closely at the workings of that AGI script.

Sunday, March 04, 2007

AOP and appfuse

I ran into some problems trying to wire up some of the startup paramaters for my managers in applicationContext-service.xml today.

I used to use txProxy as the parent for my declarations, like this:




But in appfuse 1.9.4 references to txProxyTemplate throw not found errors. It turns out that appfuse now uses Spring 2.o and aspectJ(What?). So managers are declared transactional in an aspect oriented way (AOP).ie If their names end in manager and they are in a "service" package, those things are transactional. (Sounds like something from Rocky Horror Picture Show)

Just declare them like this:


Paypal Gateway for Appfuse

I implemented a paypal gateway for appfuse recently. So that according to subscription payments, appropriate user roles would be assigned. I think I went about it the long way. But anyway I basically created a paypalnotification POJO, and configured it with an action such that the paypal notification(IPN) when it arrives comes in like a struts form submission. ie it gets mapped straight to the paypalnotification actionform.

I then just process this like any other struts action. The good thing about this is that it really integrates well with appfuse. Setting up the POJO properly is the hard part. Testing is also a real drag.

However you can't really avoid the complexity of paypal IPN. There are a lot of fields in the paypal ipn data, and it is a bit nerve wracking trying to process all the different types of transactions. It all seems to work now anyway.