Friday, December 21, 2007

Firefox causes Wicket to re-render page

I had a problem with my Wicket application where the page was being rendered twice, but the DOM in my browser wasn't getting updated. After much hair loss, I discovered it wasn't a wicket thing at all. Nor was it anything wrong with my application. It was something specific to Firefox.

It turns out that Firefox makes an additional page request if there is an image on the page with an empty source. I had this because my database had null values for the images to display, so this was rendered:
<img wicket:id="" src=""/>
Firefox makes two requests to the page if this is the case. The first has this in the
request headers:
Accept: text/xml,application/xml
,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
The browser then makes a second request due to the src="", with this in the request headers:
Accept: image/png,*/*;q=0.5
The result is that Wicket renders the page again, but Firefox doesn't update its DOM with the new HTML (and thus new Link URLs). So Wicket was doing what it should.

The solution was to make sure that my application does not output src="" for the images. Also, I found the same problem will take place for images defined in CSS files if the source is "".

Thursday, October 25, 2007

Postfix problems after update

One more thing to add to my last post:

After the update, I also cannot send email. The error logs show this:

Oct 25 11:55:19 mailhost postfix/smtpd[10671]: warning: SASL authentication failure: cannot connect to Courier authdaemond: Permission denied
Oct 25 11:55:19 mailhost postfix/smtpd[10671]: warning: unknown[xx.xx.xx.xx]: SASL LOGIN authentication failed: generic failure

With a quick google I found a solution:

chmod o+x /var/spool/authdaemon

That solved it for me!

Wednesday, October 24, 2007

Courier SSL problems after update

I posted this message as a comment to the HOWTO I used to configure my mail server:
http://www.howtoforge.com/fedora_virtual_postfix_mysql_quota_courier

I've been running a mail server built using this HOWTO for a while now. I recently updated the entire server with a "yum update". Email clients could no longer connect to the server via POP3 or IMAP if SSL was enabled. I was getting errors like this in the error log:

Oct 23 13:19:32 mailhost pop3d-ssl: couriertls: connect: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
Oct 24 10:36:13 mailhost imapd-ssl: couriertls: connect: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number

I was able to fix this by editing the following files:

/usr/lib/courier-imap/etc/imapd-ssl
/usr/lib/courier-imap/etc/pop3d-ssl

I changed the TLS_PROTOCOL setting from SSL3 to SSL23 in both of these files:

TLS_PROTOCOL=SSL23

Then, I restarted courier-authlib and courier-imap and things were working again:

service courier-authlib restart
service courier-imap restart

The following commands were helpful in testing things out:

openssl s_client -connect mailhost:993 -state -debug
openssl s_client -connect mailhost:995 -state -debug
openssl s_client -ssl2 -connect mailhost:993 -state -debug
openssl s_client -ssl3 -connect mailhost:993 -state -debug
openssl s_client -ssl2 -connect mailhost:995 -state -debug
openssl s_client -ssl3 -connect mailhost:995 -state -debug

I hope this helps someone else, as I spent way too much time trying to solve it.

Friday, October 12, 2007

Installing and configuring BIND/named

This Configuring DNS HOWTO was very helpful for installing a new bind server.

Also, their Linux firewall/iptables HOWTO was helpful as well.

Wednesday, October 10, 2007

Set up Apache as a reverse proxy

Since my client's VPS doesn't have enough memory to run a servlet engine with their app, and we don't have time to move to a bigger VPS, I'm looking for interim solutions. One idea is to use their Apache server as a proxy server to an external server.

Here's the situation. Their website has an SSL certificate with www.company.com in the domain. We can't move their site, and the SSL cert couldn't be used with a subdomain. So, if I set up a server somewhere else at say app.company.com, I could add the following to their SSL site's VirtualHost:
ProxyRequests Off

Order deny,allow
Allow from all

ProxyPass /app http://app.company.com/app
ProxyPassReverse /app http://app.company.com/app
This seems to work, but I haven't tested it fully yet. I am having issues with image paths and such, but that is to be expected.

Apache provides details of using mod_proxy.

There are also details about other options for connecting to Tomcat with various means, including using iptables, mod_jk2, and mod_proxy.

Finding memory usage in Virtuozzo VPS

I have a client who has a VPS at iPowerWeb. I can't say that I'm very thrilled with iPowerWeb, especially after finding javascript trojans scattered on pages throughout their site.

Anyway, I needed to figure out how much memory is available to their VPS. I found some information here about it. I've consolidated the pertinent information below:

Assuming your VPS provider is using UBC memory managment instead of SLM, use this command to get memory details:
cat /proc/user_beancounters
It's not the version, it depends on if your provider is using SLM or UBC memory management for your VPS. If SLM you'll see virtual memory available to your VPS, if UBC you'll see the memory available to the entire node. In this case, the VPS is using UBC (user_beancounters would have some parameters set to unlimited if using SLM).

privvmpages 102169 102687 131072 139264 150550
vmguarpages 0 0 67584 2147483647 0

This means you have 264MB guaranteed memory, 512MB burstable memory. You get these by dividing the number by 1024 (to convert to MB) and multiplying by 4 (as they're measured in 4KB pages on VZ). You should be concerned about the 150550 failcnt in the privvmpages parameter. This means that your VPS is running out of memory.
Here's my client's output:

[root@localhost conf]# cat /proc/user_beancounters
Version: 2.5
uid resource held maxheld barrier limit failcnt
377: kmemsize 4721767 4740068 16384000 18022400 0
lockedpages 0 0 4096 4096 0
privvmpages 63893 63930 262144 292912 1
shmpages 5935 5935 131072 131072 0
dummy 0 0 0 0 0
numproc 49 49 400 400 0
physpages 19182 19188 0 2147483647 0
vmguarpages 0 0 36864 2147483647 0
oomguarpages 19182 19188 18432 2147483647 0
numtcpsock 18 18 600 600 0
numflock 11 11 200 210 0
numpty 1 1 48 48 0
numsiginfo 0 0 512 512 0
tcpsndbuf 225836 225836 4300800 6144000 0
tcprcvbuf 351884 351884 4300800 6144000 0
othersockbuf 11180 11180 3072000 5529600 0
dgramrcvbuf 0 0 524288 524288 0
numothersock 16 16 600 600 0
dcachesize 175522 177878 4192304 4317184 0
numfile 2041 2050 8192 8192 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
numiptent 14 14 128 128 0


So, I calculate that the VPS has 1024MB of burstable memory and only 144MB of guaranteed memory. Not nearly enough to run apache, mysql, and a java servlet engine...

Now, what I don't know for sure is which of those numbers shows the current memory usage.

Friday, September 21, 2007

Easy CRUD in Wicket

I like Igor's implementation of wicketstuff-crud. Check wicketstuff svn for it. But there is also WicketWebBeans which looks interesting.

Open source solutions for a grid infrastructure?

I've been searching for the last few days for any open source tools that could help in building an infrastructure for deploying grid or utility computing services. I haven't found anything yet that does everything, but maybe it is out there.

The AppLogic product by 3Tera looks pretty cool. It uses a combination of open source and proprietary technologies, including Xen and NBD. Hosted solutions can be purchased directly from 3tera, or from Layered Technologies (thegridlayer.com) and FortressITX. I can't tell, but I think that SoftLayer may host some grids, but they may not sell the service.

My initial thoughts would be to build an IP SAN across the servers using DRBD, LVM, and GNBD. This page at gridvm.org has a good description of doing this (in fact, I should read everything on the gridvm.org site):
http://www.gridvm.org/drbd-lvm-gnbd-and-xen-for-free-and-reliable-san.html

This is where I then get fuzzy on what would need to go on next. I'm assuming Xen would be part of it, but I don't know how to make one application span over multiple servers. Need some sort of grid layer?

Maybe the AppLogic approach doesn't let a single appliance within an application span over multiple servers? Can scale to use all the CPUs on a single server, but not more than those in a single server? Not sure, need to look into this.

There is tremendous value in the AppLogic product's web based front end and CLI tools. These tools seem to be spectacular. Obviously, building a solution with OS products would not have that front-end.

I should also look into Virtual Workspaces and see what it is all about:
http://workspace.globus.org/index.html

Edit 10/7/2007:
Another player in this realm seems to be MediaTemple. Their system doesn't look nearly as sophisticated as AppLogic:
http://www.mediatemple.net/webhosting/gs/

Friday, August 10, 2007

Eclipse 3.3 configuration for Wicket with Aptana

It turns out that using Aptana as the HTML editor in Eclipse marks all the wicket tags as errors. To get around this, do this:

Go to Window->Preferences
Select Aptana->Editors->HTML Editor
Add a new filter: .*wicket:.*
Click OK

Configuring Eclipse 3.3 for wicket web development

Install software updates and plugins
------------------------------

Go to: Help->Software Updates->Find and Install
Select: Search for updates of currently installed features
Automatically select mirrors (or manually do it if you prefer)
I can't remember what I updated, but there is a minor Eclipse update available
Install this update -- I think it is needed for WicketBench to work.
When asked to restart Eclipse, say NO (not yet).
Next, go again to: Help->Software Updates->Find and Install
Select: Search for new features to install
Check Web Tools Platform (WTP) Updates
Click Finish
Select Web Tools Platform (WTP) -> Web Standard Tools (WST)
(only select the one checkbox, not the others such as SDK)
Go through install process
When asked to restart Eclipse, say NO (not yet).
Next, go again to: Help->Software Updates->Find and Install
Select: Search for new features to install
Click New Remote Site button
Name: Wicket Bench
URL: http://www.laughingpanda.org/svn/wicket-bench/trunk/wicket-bench-site
The new Wicket Bench site should be checked.
Click Finish
Go through install process
Now, when asked to restart Eclipse, say YES.

Configure workspace preferences
------------------------------------------------
Go to: Window->Preferences
Select: Java->Compiler
Make sure compiler compliance level is 5.0
Select: Java->Compiler->Errors/Warnings
Under Potential programming problems
Set Serializable class withous serialVersionUID to Ignore
Select: General->Editors->Text Editors
Set the displayed tab width to 4 (or whatever you prefer)
Uncheck insert spaces for tabs (unless you want spaces, but they bug me)
Check show line numbers
Select: General->Workspace->Local History
Set Days to keep files to 14 (or whatever you want...)
Click OK to save everything

Now, to open a Java class, right click onto the class and select Open with -> Wicket Editor. You only need to do this one time. After that, it will automatically use the wicketbench editor when you open that class. In the editor, there will be tabs at the bottom of the editor window for java, properties, css, and html. You can quickly switch between these files within one editor (for instance, HomePage.java, HomePage.properties, HomePage.html, and HomePage.css). It makes it easy for working with Wicket.

WST needs to be installed or you won't be able to edit HTML files with HTML tag highlighting. Whenever you open an HTML file, it will render it in a web browser, but it won't be editable unless you install WST. With WST, you can edit it using the "HTML editor" instead of doing a right click->open with->Text Editor. Another alternative is Aptana. I'm experimenting with it -- it does a lot more than WST, but it seems a bit too heavy and overkill for my needs. If I end up using it, I'll post here with more about it.

Also, WicketBench provides an HTML tab that automatically use WST HTML editor (I think it uses that editor). I don' t know if there is a way to get it to use the Aptana HTML editor. WicketBench also provides a Preview tab that renders the page, but it isn't the same as opening with the Web Browser.

Note that I originally I also did this, but I recommend against doing it:
Go to: Window->Preferences
Select: General->Editors->File Associations
Highlight *.java in list of File Types
Select associated editor: Wicket Editor
Click onto the Default button

When you do that, it causes a wicketbench/eclipse debugger bug to happen. I've found that the debugger in eclipse doesn't show the current line of execution in the code if wicket bench is installed and configured as the default Java editor. The debugger works, and the thread view shows the current line number, but the line isn't highlighted in the code.

At this time, Wicket Bench hasn't been officially tested with Eclipse 3.3 yet, but I understand that this same issue existed prior to Eclipse 3.3. See this FAQ:
http://www.laughingpanda.org/mediawiki/index.php/Wb-FAQ

To avoid the problem, just do not set WicketBench as the default editor for java files. Instead, use right-click, "Open With" Wicket Editor as I described above to open java classes. The next time you open them, you can just double click and it will remember to use WicketBench. And, by doing this, the debugger will open a regular Java Editor and will show the current line highlighted. Even if you have a WicketBench editor open for the same file, the debugger will open a new window with a regular Java Editor during debugging. You will have to close the extra files manually, however.

Once this is done, eclipse provides a decent environment for developing wicket apps. You might also want to add the subversive plugin to eclipse, as described in my previous post.

Next, I may look into adding a maven plugin, but no time for that right now.

Eclipse 3.3 with subversion support

Just installed Subversive plugin into eclipse 3.3. Using update feature, added new site:
http://www.polarion.org/projects/subversive/download/1.1/update-site/

In order to install, I had to remove the following feature:
Subversive Integration for the CSC Project Set

Thursday, August 09, 2007

Radio controls with ajax in wicket 1.2

I needed to have two radio controls on a form. If one was selected, one panel would show. If the other was selected, the other panel would show. This is possible in Wicket 1.3, but not using Wicket 1.2.6. Here is how I got it to work in Wicket 1.2.6.

public static final int WITH_CONFIG = 0;
public static static int WITHOUT_CONFIG = 1;

private class FileUploadForm extends Form {

private WebMarkupContainer xmlContainer;
private WebMarkupContainer enginesContainer;

/**
* Construct.
*
* @param name
* Component name
*/
public FileUploadForm(String id, IModel model) {
super(id, model);

EdiInformation ediInfo = ((EdiInformation)getModelObject());

// set this form to multi-part mode (always needed for uploads!)
setMultiPart(true);

// Set maximum size to 10M
setMaxSize(Bytes.megabytes(10));

Button saveButton = new Button("saveButton", new ResourceModel("form.saveButton"));
add(saveButton);
add(new Button("cancelButton", new ResourceModel("form.cancelButton")) {
protected void onSubmit() {
setResponsePage(new ManagerMainPage(ManagerMainPage.TAB_EDI));
}
}.setDefaultFormProcessing(false));
add(new FeedbackPanel("feedback"));

enginesContainer = new WebMarkupContainer("enginesContainer");
enginesContainer.setOutputMarkupId(true);
enginesContainer.add(new EdiImportEnginesDropDownChoice("importEngine"));
enginesContainer.setVisible(false);

xmlContainer = new WebMarkupContainer("xmlContainer");
xmlContainer.setOutputMarkupId(true);
FileUploadField xmlInput = new FileUploadField("xmlInput");
ediInfo.setXmlInput(xmlInput);
xmlContainer.add(xmlInput);

RadioGroup option = new RadioGroup("option");
setupAjaxRadio(this, option, new Radio("withConfig", new Model(WITH_CONFIG)),
xmlContainer,enginesContainer);
setupAjaxRadio(this, option, new Radio("withoutConfig", new Model(WITHOUT_CONFIG)),
enginesContainer,xmlContainer);

add(enginesContainer);
add(xmlContainer);
add(option);

FileUploadField dataInput = new FileUploadField("dataInput");
ediInfo.setDataInput(dataInput);
add(dataInput);

add(new UploadProgressBar("progress", this));

}

private void setupAjaxRadio(final Form form, final RadioGroup radioGroup,
final Radio radio, final WebMarkupContainer visibleContainer,
final WebMarkupContainer hiddenContainer) {
radioGroup.add(radio.add(new AjaxEventBehavior("onchange") {
protected void onEvent(AjaxRequestTarget target) {
radioGroup.processInput();
hiddenContainer.setVisible(false);
visibleContainer.setVisible(true);
target.addComponent(form);
}
protected CharSequence getEventHandler() {
return getCallbackScript(new AppendingStringBuffer(
"wicketAjaxPost('").append(getCallbackUrl()).append(
"', wicketSerialize(document.getElementById('"
+ radio.getMarkupId() + "'))"), null, null);
}
}));
}

Thursday, June 07, 2007

Xen statistics

This looks interesting for xen statistics:
http://skaya.enix.org/wiki/XenStats

Also, xentop from the command line looks useful too.

Monday, June 04, 2007

Updating config in Cisco 2600 router

I've got a Cisco 2600 router and don't know much about how to configure it. I figured some things out today that I'm sure I'll forget again.

To login:
telnet router
(enter password)
enable
(enter password)
To show runtime configuration:
show run
To configure an interface's settings:
configure
int FastEthernet0/1
To turn off arp timeout:
no arp timeout
To turn on arp timeout:
arp timeout 300
To exit configuration mode press CTRL-Z.

To save running configuration for use at startup:
copy run start
Or:
copy running-config startup-config