Selenium, what a great tool

Whilst trying to write some code which would rollover Blackboard courses automatically, year in year out.

We where looking for an answer to using a ‘value’ or piece of ‘text’ which was next to a checkbox rather than the ‘id’ (which is the usual way Selenium handles checkboxes), as the ‘id’ in our case was being dynamically generated so it couldn’t be relied upon being the same number, as it depended how many checkboxes where on that particular screen.

Here’s how we solved it :

selenium.click(”//input[@value='users']“);

where ‘users’ is the value from within the code, rather than ‘Users’ which is just some text after the checkbox, which display next to it, so not really that connected, actual code from within Blackboard (yuck) follows :

<input type='checkbox' name='area' id="area_14" value="users"> <label for="area_14"><font class="fnt0"><b>Users</b></font>

* Note, this only seems to work with Selenium using Firefox 3 as the browser rather than IE.

Glassfish v2.1.1 site redirect

Simple to do, hard to locate the information on how to.
Hopefully you’ll find this a lot easier..

Navigate to :

Configuration, HTTP Service, Virtual Servers, server

Scroll to bottom of page :
Add Property

Name :
redirect_1

Value :
from=/{name of webapp to redirect} url={URL to redirect traffic to}

(dont include the ‘{‘ ‘}’ brackets)

It should look something like this :
from=/mywebapp url=http://www.google.co.uk

Click ‘Save’ button.

Done!

Alfresco community 4.0 installation on Glassfish 3.1

PLEASE NOTE:

The following worked only on Alfresco 3.4d – We tried to get it to work on version 4.0 but it will not.
We have now resorted to using the Tomcat Bundled version of 3.4d as our server is 32bit linux.

Follow the below instructions if you still want, but be it on your own head 🙂

1. Get alfresco war files for deployment in existing application servers package file  alfresco-community-4.0.a.zip from https://process.alfresco.com/ccdl/?file=release/community/build-3755/alfresco-community-4.0.a.zip

2. MySql setting

mysql>create database alfresco;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’%’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’localhost’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

3. Create alfresco documents and index folder

mkdir /usr/local/alfresco

4.Unpack alfresco-community-4.0.a.zip

unzip alfresco-community-4.0.a.zip

5. Configure Alfresco before deploying to glassfish

5.1 alfresco-global.properties

Since alfresco 3.3, all the settings now based on alfresco-global.properties. This file can be found from the alfresco package file alfresco-community-4.0.a.zip. Copy this file from the unzip location to  glassfish lib folder.

cd /alfresco-community-4.0.a/extensions/extension

cp alfresco-global.properties /usr/local/glassfish/domains/domain1/lib/classes/alfresco-global.properties

if Glassfish is installed at /usr/local/glassfish.

5.2 Modify alfresco-global.properties so alfresco can find database and index folder created before

Set alfresco folder
dir.root = /usr/local/alfresco

Set dababase username and password

db.username=YOUR_ALFRESCO_USERNAME
db.password=YOUR_ALFRESCO_PASSWORD
db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco

6. You need a ‘glassfish-web.xml’ for “useMyFaces” for alfresco. *ONLY needed if your using Glassfish 3.1 * – If using Glassfish 3.0 or below Skip to step 7/7.1 as that needs ‘sun-web.xml’.

7. sun-web.xml:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE sun-web-app PUBLIC “-//Sun Microsystems, Inc.//DTD Application Server 8.1 Servlet 2.4//EN”  “http://www.sun.com/software/appserver/dtds/sun-web-app_2_4-1.dtd”&gt;
<sun-web-app>
<class-loader delegate=”false”/>
<property name=”useMyFaces” value=”true”/>
</sun-web-app>

You can also get this file from http://blogs.sun.com/mandy/resource/sun-web.xml

7.1 Add sun-web.xml to alfresco.war

Go to the unpacked directory created from alfresco-community-4.0.a.zip, create a new directory named WEB-INF and put sun-web.xml on it.

cd /alfresco-community-4.0.a/

mkdir /WEB-INF/

cp /temp/sun-web.xml /WEB-INF/sun-web.xml

jar -uvf alfresco.war WEB-INF/*.xml

The alfresco.war should be edited.

8.  Increase glassfish memory heap setting
Log in as administrator of glassfish from http://glassfishHost:4848/
Application Server->JVM Settings->JVM Options
Change -Xmx256m to -Xmx512m or more.

9.  Deploy the new war file to glassfish.
Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy alfresco.war.
After a few minutes, alfreso can be visited by hppp://glassfishHost:8080/alfresco

10.  Deploy share

Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy share.war from the unzip package.

There is a bug in share.war, so you will get the “No ‘login’ page type configured – but page auth required it.”  error message if go to  http://glassfishHost:8080/share.

Solution is download the latest spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar from alfresco SVN

wget http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/3rd-party/src/spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar

cp spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar /usr/local/glassfish/domains/domain1/applications/j2ee-modules/share/WEB-INF/lib/

Restart glassfish, go to http://Glassfishhost:8080/share

Should work!

You can also add the spring-surf-core-configservice-1.0.0.CI-SNAPSHOT.jar to the share.war and deploy it.

Jinitiator working on Windows 7

We need ‘Jinitiator 1.3.1.13’ to use a core application. The applications in-house team havent managed to get it working with JRE, which is the replacement to Jinit. They insist that you must use Jinitiator 1.3.1.13 & windows XP! Joy! We also know that Jinit is no longer supported by Oracle & refuses to work with Windows 7.

So how do you get around this ?

Install Jinitiator as normal, if your having problems actually getting it to install, just use the Win7 ‘compatibility mode’ to get it to stay on your machine instead of it annoyingly uninstalling itself at the end of a failed install process.

Now

Replace the ‘jvm.dll’ in jinitiator directory (C:\Program Files (x86)\Oracle\JInitiator 1.3.1.13\bin\hotspot\) with this file jvm.dll.

Restart IE* and try again, Windows 7 should reduce your colour scheme and your app should now work.

See post repaint blog post on how to fix the repaint screen issues, if they are happening to you.

*Note, I would never normally recommend Internet Explorer, it’s just that this process doesn’t work for me using Chrome or Firefox, my preferred browsers.

.jar file associations and Windows 7

Has your .jar associations ever been hijacked ?

Mine too, after spending far too long following suggestions of people on forums of how to get it back, using your command prompt ‘assoc’ & ‘ftype’ commands and manually editing your regedit etc…

Forget it, grab yourself this handy util ‘jarfix

Jarfix has existed since 2002, so can be trusted to correct the .jar association & put back the following -jar flag, so when you launch a .jar file it runs correctly. On typing ‘ftype jarfile’ in your Command Prompt you should see the following.

jarfile=”C:\Program Files (x86)\Java\jre6\bin\javaw.exe” -jar “%1” %*

Alfresco community 3.2 installation on glassfish

1 Get alfresco war files for deployment in existing application servers package file  alfresco-community-war-3.2r2.tar.gz from http://wiki.alfresco.com/wiki/Community_Edition_file_list_32r2

2. MySql setting

mysql>create database alfresco;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’%’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

mysql>grant all privileges on alfresco.* to ‘YOUR_ALFRESCO_USERNAME’@’localhost’ identified by ‘YOUR_ALFRESCO_PASSWORD’;

3. Create alfresco libray folder on glassfish

mkdir /usr/lcoal/glassfish/domains/domain1/lib/classes/alfresco

4.Unpacke alfresco-community-war-3.2r2.tar.gz

tar vzxf alfresco-community-war-3.2r2.tar.gz

5. From the directory in which you unpacked the Alfresco bundle, copy the entire contents of the extensions directory to the glassfish domain library /usr/lcoal/glassfish/domains/domain1/lib/classes/alfresco

cp -rf extensions/*  /usr/lcoal/glassfish/domains/domain1/lib/classes/alfresco

6. Create alfresco documents and index folder

mkdir /usr/local/alfresco

7. Modify alfresco config files for glassfish (/usr/local/glassfish/domains/domain1/lib/classes/alfresco/extension)so alfresco can find database and index folder created before

two files should be edited

custom-repository.properties

custom-hibernate-dialog.properties

cd /usr/local/glassfish/domains/domain1/lib/classes/alfresco/extension
vi custom-repository.properties

Set alfresco folder
dir.root = /usr/local/alfresco

Set dababase username and password

db.username=YOUR_ALFRESCO_USERNAME
db.password=YOUR_ALFRESCO_PASSWORD

Comment out the lines for derby and uncomment the lines for MySQL

#db.driver=org.apache.derby.jdbc.EmbeddedDriver
#db.url=jdbc:derby:data/derby_data/alfrescocreate=true


db.driver=org.gjt.mm.mysql.Driver
db.url=jdbc:mysql://localhost/alfresco

In custom-hibernate-dialog.properties, comment out the line for Derby and uncomment the line for MySQL

8 The Alfresco war file has a WEB-INF/web.xml deployment descriptor that doesn’t comply with the DTD, you need to replace this file and add a Glassfish specific deployment descriptor that will allow Alfresco to use MyFaces instead of JSF.

Get these two files from http://blogs.sun.com/mandy/resource/web.xml, http://blogs.sun.com/mandy/resource/sun-web.xml

Change to the unpacked directory created from alfresco-community-war-3.2r2.tar.gz, create a new directory named WEB-INF and copy the above two files into it. Now update the alfresco.war file using the Java jar command

jar -uvf alfresco.war WEB-INF/*.xml

The alfresco.war should be edited.

9 Increase glassfish memory heap setting
Log in as administrator of glassfish from http://glassfishHost:4848/
Application Server->JVM Settings->JVM Options
Change -Xmx256m to -Xmx512m or more.

10 Deploy the new war file to glassfish.
Log in as administrator of glassshfish from http://glassfishHost:4848/ and deploy alfresco.war.
After a few minutes, alfreso can be visited by hppp://glassfishHost:8080/alfresco

Useful links:
http://blogs.sun.com/mandy/entry/alfresco_on_glassfish_revisited

Sendmail did not send mail instantly but queued it

Sendmail did not send mail instantly but just queued it.

Testing sendmail by

#mail test@host.com

System didn’t show any error but just queued the mail

#mailq

Showing that the mail message has been put into the queue.

Queue message  “host map: lookup (domain): deferred”

#/sendmail -q

Can force server sent mail successfully. It means the DNS setting should be correct.

Check sendmail configuration files

#/etc/mail/sendmail.cf

DeliveryMode is not  “deferred”

O DeliveryMode=background

#/etc/hosts

#/etc/resolv.cf

#/etc/nsswitch.conf

Both files have the same setting as another server which can send mail instantly.

Try to stop and restart sendmail

#/etc/init.d/sendmail stop

#/etc/init.d/sendmail start

Problem solved.

Create Oracle DataSource in Glassfish

1 . Copy JDBC Oracle driver to GLASSFISH/lib, for example, copy ojdbc14.jar to /usr/local/glassfish/lib.

2. Restart Glassfish, log on to Glassfish admin interface, create a new JDBC Connection Pool.
Delete all properties, and add following properties:
user – set this to Oracle userid
password – set this to Oracle password
URL – set this to the URL, Format : jdbc:oracle:thin:@HOSTNAME:PORT:SID.

Test the connection pool by clicking the “ping” button to get the verify  message.

3. Create a JDBC DataSource using the JDBC Connection Pool.

Full details for creating an Oracle connection pool in Glassfish2.1.1 can be found from the link below:

http://mariosgaee.blogspot.com/2009/12/oracle-connection-pool-in-glassfish.html

Full details for creating MySQL connection pool in Glassfish can be found from the link below:

http://www.albeesonline.com/blog/2008/08/06/creating-and-configuring-a-mysql-datasource-in-glassfish-application-server/

NetBeans 6.8 IDE comes with JavaFX Composer

The JavaFX Composer is a plug-in for NetBeans IDE 6.8. It provides:

  • Visual editor for a form-like UI using components in JavaFX 1.2.1 SDK
  • Dynamic design editing based on states
  • Data access to Web Services, databases and local storages
  • Support for JavaFX binding
  • Simple animation editor
  • Multi-screen-size editing

Install:

From NetBeans 6.8 IDE, Tools — PlugIns — Available PlugIns, select JavaFX Composer, and click Install and go through the rest of installation wizard.

To use JavaFX Composer, you need to create a new JavaFX project, and use either JavaFX Desktop Business Application or JavaFX Mobile Business Application. You can’t use JavaFX Composer to open previous created JavaFX projects.

Usability:

Source/Designer views, but the generated code can not be modified in the editor manually. You need to edit it from the designer view properties editor.

Links:

http://wiki.netbeans.org/JavaFXComposer



CHKCONFIG

A unix command line tool for maintaining the /etc/rc[0-6].d directory hierarchy by relieving system administrators of the task of directly manipulating the numerous symbolic links in those directories.

Usage:
chkconfig --add NAME
Add new symbolic links in /etc/rc[0-6].d
chkconfig --del NAME
Removed from chkconfig management, and any symbolic links in /etc/rc[0-6].d which pertain to it are removed.
chkconfig [--level LEVELS] NAME
Specifies the run levels an operation should pertain to. levels between 0 – 7. For example, –level 56 specifies level 5 and 6.