Saturday, February 02, 2008

It is hard to keep this blog thing going. Anyway I am going to do mybest to at least store tech chunks here, so that they may be usefult to someone.

I had someone fix up my bad japanese last week in a properties file for struts application that I have written. However he was a mac user and when it came to me, the tezt was encoded in unicode ascii, and probably the file itself was euc_jp. Well I used notepad++ to change it first to windows formatting (line breaks etc) from the format menu.

Then I changed it from Ansi to UTF-8 also from the format menu.

Then I used the Java SDK native2ascii tool from the command like this,
L:\"%JAVA_HOME%\bin\native2ascii" -reverse -encoding UTF-8 ApplicationResources.properties ApplicationResources-nat.properties
Les voila

Thursday, April 26, 2007

I had all sorts of problems today because my mail server was suddenly blacklisted by
cbl.abuseat.org Why ?

To quote from the transcript of their sites analysis:
There are two basic types of detections that land an IP in this page. RFC2821 section 4.1.1.1 says that there are only two legal types of HELO/EHLO a mail server can issue - either a fully qualified domain name (eg: "mail.example.com") or an "IP literal" (eg: "[1.2.3.4]").

The listings that land in this page are:

HELO "localhost", "localhost.localdomain", and other generic "unconfigured" names.
HELOs that are bare IP addresses (without enclosing square brackets).
Listings on the former are most common in UNIX-derived systems (such as Linux, xBSD


Well I have a lot of domains on that PC, and my network has several live sites going. I was in no mind to start messing with my hostname, so I added this line to my sendmail.mc file
define(`confDOMAIN_NAME',`mydomain.com') and regenerated sendmail.conf
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.conf

rebooted sendmail
/etc/rc.d/init.d/sendmail restart

And checked with cbl.abuseat.org . I seemed to be OK. So I applied to be delisted and I hope I will be. Who the frick are cbl.abuseat.org anyway?

Thursday, April 05, 2007

Postgresql problems

I have recently been battling mysterious crashes involving postgresql. Postresql has been in use on the system for more than 2 years.Though the amount of data is small and it is mainly a backend for simple web applications.

OS is Fedora Core 2. Anyway I have been experiencing intermittent system crashes, where everything locks up. The whole system goes down with no meaningful errors. At least none that I can find.

Well after one such bewildering crash, Postgresql wouldn't start. I thought that postgresql may have been my system crash culprit. Anyway I always start postgresql via
/etc/rc.d/init.d/postgresql start

But all I got was a bland [failed] and no error details. After some scouring, I learned to start postgresql manually using
su postgres
pg_ctl -D /var/lib/pgsql/data (or whatever the path to your pgsql data directory is)

Here I got the error that the server was already running, which it wasn't. It turned out that the database lockfile, on the last crash, had not been cleared. A simple
rm /var/lib/pgsql/data/postmaster.pid (to delete the lock file)
and I was back in business.

I still have system crashes though. I have tried rebooting and checking the file system
shutdown -rF now

And so far I have not had a crash. But it has only been a few minutes.

Justin

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.