Wednesday, August 26, 2009

How to solve a weird JAXB/xerces spring application context load error

I was trying to get an app working standalone a spring application context via the classpath. In eclipse it worked fine but at the command line I got:
Unable to validate using XSD: Your JAXP provider [org.apache.crimson.jaxp.DocumentBuilderFactoryImpl @148cc8c] does not support XML Schema. Are you running on Java 1.4 or below with Apache Crimson? Upgrade to Apache Xerces (or Java 1.5) for full XSD support.
I was using java 1.6 and the latest Xerces so this error message is not at all helpful. What was VERY helpful was finding the thread at http://forum.springsource.org/archive/index.php/t-21140.html which contained the answer. I need to define a couple of properties that force the factories for XML parsing. Just add the following as JVM parameters:
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl

Saturday, July 11, 2009

How to have an iPod without using iTunes

I trashed Brenda's iPod today. I eventually managed to recover it. Here's what happened:
I ripped a couple of CDs and copied them to the iPod using gtkpod. This was an experiment. I had always used iTunes before, but I am trying to escape from Windoze so I wanted to see if I could use some open source software on my Debian machine. I found that although the iPod contained the new music, once the iPod was supposedly synch'd then disconnected, the iPod reckoned the music wasn't there. As I tried various approaches eventually the iPod reckoned there was no music on there at all. Even doing a factory reset didn't fix it. On my travels I found stories of people who had managed to get iTunes up and running on their system using wine. That didn't work for. For a start, the Etch version of Debian has a version of wine that is too old. I tracked down a backport and I used winetricks to fool the system into thinking I am on XP, which the iTunes installer requires. But iTunes could not fix the iPod with the state it had gotten into, and IMHO iTunes is rubbish anyway.
Eventually I found out that the problem is caused by Apple turning the iPod against me. They want it to work only with iTunes and they keep revising the firmware to make it not work with other software. This is behaviour worthy of the Evil Empire itself. Brenda's iPod is a fourth generation nano. That means it has all the latest stuff to prevent people being able to use the device without using Apple software.
I found that some kind people have backported a recent version of gtkpod to Debian Etch. The glibpod3 library required has also been backported. I downloaded and installed the Debian packages. The next and final trick was to update a crucial file on the iPod which is used to identify the firewire device. I mounted the ipod to /med/ipod. This made the pathname of the file to be /media/ipod/iPod_Control/Device/SysInfo. Run the command "sudo lsusb -v | grep -i Serial" (without the "") with your iPod plugged in, this should print a 16 character long string like 00A1234567891231. This is the id. Put it in that file in the form:
FirewireGuid: 0xffffffffffffffff.
The leading '0x' is important.
I found this help at http://mandrivausers.org/lofiversion/index.php/t50594.html. Phew. At last, I can now use the iPod without Windoze and without Apple software.

Tuesday, June 16, 2009

managing photos without facebook or flickr

I got tired of the unreliable photo upload of facebook and found the bandwidth and size limitations of flickr too, er, restrictive, so I looked around for something else. I came across Coppermine Gallery and IMHO it is brilliant.
The online manual tells you exactly how to set it up and it worked first time. I am pleased to say it works with FastHosts (my webspace provider). There is a slight deterioation in image quality that you don't get with facebook or flickr. I think this is combination of me making smaller jpgs and the fact that Coppermine is using GD. It can use ImageMagic where available. I am not sure which one is supposed to be the best.
So, all I need to do now is add menu options to my web site to refer to the various albums.

Thursday, April 09, 2009

The pain of building subversion on solaris

I have eventually managed to get subversion 1.5.0 built on solaris (opensolaris running on VirtualBox actually). At the time of writing this, the most recent version of subversion is 1.6.0. However, I have a requirement to use an older version of subversion, 1.5.0. This is because subversion, subclipse and svnant need to all cooperate with each other. This means dropping back to 1.5.0. When I tried to build subversion 1.5.0 on solaris I got a load of link time errors to do with relocatable code in libneon.a. I eventually found a blog at http://sreekalyan.blogspot.com/2005/07/installing-subversion-on-solaris.html which gave me a hint on how to solve the problem. First, I found I had to use version 0.28.1 of neon. The subversion configure does not like a more recent version and says neon is not there! By default, libneon does not build shared libraries. You have to configure with --enable-shared=yes, an undocumented option no less! I then deleted /usr/local/lib/libneon.a so that it could not be picked up by accident. After a configure in subversion I had to hack the value for the neon library, changing it from libneon.la to libneon.so. Wow, what a pain this was!

Saturday, February 14, 2009

DSpace, chemical structures, CML and jmol

I have started to put some chemical structures into my DSpace instance. They are going in as CML files. CML is Chemical Markup Language. There is an open source tool called jmol which allows structures to be viewed as 3D rotating images, given a CML file. JMol includes a servlet so that web pages can display these images. I would like to see this used by DSpace. But in the meantime I have set things up so that CML files invoke an external jmol viewer. This is a bit like putting up PDFs and getting the external acrobat reader to display them. Here's how I did it:

  • Add a mimetype for XML to the list of registered types. Make the type known (as opposed to unknown or unsupported), and the mimetype chemical/x-cml.
  • Download the jmol package from sourceforge and ensure that the script jmol.sh (or jmol.bat on Windoze) has execute permission. On Windoze the environment variable JMOL_HOME must also be defined. On Unix just add the jmol directory to your PATH.
  • Test jmol by running the standalone viewer on a CML file. When that works you should be ready.
  • Add a CML item to a collection in your Dspace. That's it. Clicking on it will now run the viewer!

It would be great if the 3D image could be in the web page directly, like PDFs can with the browser add-on. But AFAIK there is no such add-on. There is the servlet but this would involve codes changes to DSpace.

Tuesday, December 23, 2008

Customizing DSpace v1.5.1

Prior to version 1.5.1 of DSpace, customization was done using a separate project called Manakin. The name persists within DSpace, including DSpace documentation, but actually it is all integrated now and customization is done in the dspace tree, not some separate project.

Details on how to customize dspace are very thin on the ground and most talk about how to do it when it was the separate Manakin project. I have managed to find something that works for me. Here's how I did it:

  • Stop tomcat.
  • Delete the tomcat dir webapps/xmlui.
  • go to the dir in which you unpacked dspace. My dir is called dspace-1.5.1-src-release.
  • Go to the sub-dir where the themes are stored. The documentation I found leads you to the wrong place. I found I had to go to dspace-xmlui/dspace-xmlui-webapp/src/main/webapp/themes.
  • Copy the dir that is closest to the theme you want. Copy the whole dir to a new target theme name. The one I copy is Reference.
  • This next step is CRUCIAL - edit sitemap.xmap to make it refer to the new theme name. If you don't then it will still refer to Reference! You need to go to the map:components section near the start. There you will see a section that looks like this:
    <map:component-configurations>
        <global-variables>
            <theme-path>Reference</theme-path>
            <theme-name>put your theme description 
                here</theme-name>
        </global-variables>
    </map:component-configurations>
      
    Change Reference and update the comment.
  • Edit dspace/config/xmlui.xconf. Go to the end where you will see the path defined for the default theme. It is Reference/. Note the trailing slash, it is important. Change Reference for your theme name.
  • Change something in your theme dir so that the change will be visually obvious. For example you can change the style sheet to refer to a different background image.
  • Rebuild dspace with these theme changes. Use the command 'mvn package'. This builds to [dspace-src]/dspace/target.
  • Update the dspace installation (which is in c:\dspace for me). Use the command 'ant update'.
  • copy the dir dspace/webapps/xmlui to the tomcat webapps dir.
  • Restart tomcat.

Wednesday, December 17, 2008

importing into DSpace

I finally managed to import a text file into DSpace today. It was "Decline of Science in England" by Charles Babbage. Here's how I did it:

  • create an import directory. I called mine test-import.
  • Create a directory below the import directory. I named it decline, after the book.
  • Put the text file into the directory 'decline'.
  • Create the file dublin_core.xml, in the 'decline' directory. The file looked like this:
    <dublin_core>
        <dcvalue element="title" qualifier="none">
            Decline of Science in England
        </dcvalue>
    
        <dcvalue element="subject" qualifier="none">
           science
        </dcvalue>
    </dublin_core>
    
  • Create a file called content. The file contains a list of filenames, one per line. In this case I had body (which was the name of my text file) and preface, which was a separate preface file I created.

To import the item I then created a community and a collection under it, and gave this command:

bin\dsrun org.dspace.app.itemimport.ItemImport -a -e emailAddress
-m mapfile.out -c 125050010/1469 -s test-import

Wednesday, November 26, 2008

setting up DSpace and tomcat on windoze

My attention has turned to digital repositories. I looked at Greenstone but had enough problems with even a simple setup (admittedly trying to build from source) that I gave up. So I am now looking at DSpace. I had terrible trouble getting it to work on Windoze with Tomcat. I got it working eventually. Here is the tale of my voyage of discovery.

Prerequisites

Postgres.

goto http://www.postgresql.org/download/ and click on link for windoze. this will take you to a one-click installer for 8.3 the one-click install runs a nice setup wizard. database superuser = postgres,1gandalf. listening port=5432 (default). locale = English, United Kingdom I got the popup "A non-fatal error occured during the cluster initialisation. Please check the installation log in /tmp for details." There did not seem to be a log in either c:\temp or c:\windows\temp. The wizard then went on to completion. The service says it is starting for quite a while then stops. this seems wrong. The windoze event log has a timeout waiting for server startup, preceeded by a fatal error "could not create lock file 'postmaster.pid', permission denied. Went into c:/Program Files/PostgreSQL/8.3 and did a recursive chmod 777. Then restarted the service. this fixed it.

tomcat.

download binary distro for tomcat 5.5 core, windows installer. connector port = 8030 (default is 8080). u,pw=admin,1gandalf service fails to start. turn on debug in tomcat configuration panel, then restart. catalina logfile shows a bind error, address already in use. this was because there was a leftover process that interferred. I found the process using tcpview. need to put tcpview on my web pages. it is much better than netstat. after the kill tomcat restarted just fine.

maven.

it does not seem to come with anything ready for windoze. I unpacked the binary zip and found it is an installation directory. mvn can be run from the bin directory. Add the full pathname of the bin dir to the PATH using the control panel.

postgres (continued)

run PG Admin III (start->PostgreSQL 8.3->pg Admin III. double-click on localhost to connect to the db, enter the password for the postgres user. double-click on loginRoles then rightMouse. Select 'New login role...'. u,pw=dspace,dspace, check 'can create database objects' and 'can create roles'. double-click on databases then rightMouse, select 'new database...'. name=dspace,owner=dspace, UTF8 encoding. privilege properties, add user/group public with connect rights.

dspace.

edit dspace/config/dspace.cfg.
change pathnames so they work for Windoze, e.g /dspace => c:/dspace
change port number to 8030, i.e the one used by tomcat.
db.name = postgres
db.driver = org.postgresql.Driver
db.username = dspace
db.password = dspace
mail.server=mail.company.co.uk
mail.from.address = amarlow@company.com
feedback.recipient = amarlow@company.com
handle.prefix = 123400009
authentication.password.domain.valid = company.com

create c:\dspace cd to where dspace was unpacked. mvn package. this starts by doing lots of downloading and takes a *long* time. it takes over 77 minutes! cd dspace/target/dspace-1.5.1-build.dir. ant fresh_install

using a DOS cmd window:
cd c:\dspace
bin\dsrun org.dspace.administer.CreateAdministrator
email: amarlow@company.com
first name: andrew
last name: marlow
password: 1gandalf

shutdown tomcat. cd to tomcat conf dir edit context.xml putting in the dspace stuff. the context file is new to tomcat v5. restart tomcat. http://localhost:8030/jspui does not work! could not get this to work. tried to copy webapps/jspui to tomcat webapps dir but this also failed, but for a different reason. this gave an error in the tomcat log because it couldn't find ${dspace.dir}\config\dspace.cfg also get a NPE trying to use log4j when not properly configured. problem seems to be to do with the config directory not being copied over. but where to put it?

See http://mailman.mit.edu/pipermail/dspace-general/2008-July/002103.html for someone else who had exactly the same problem as me.

There seems to be a servlet LoadDSpaceConfig that is supposed to manage this and presunably report if there are any problems. But it seems that this is not working. I found this little nuggest in the DSpace manual on page 111, way after the installation instructions!:

The org.dspace.app.webui.servlet.LoadDSpaceConfig servlet is always loaded first. This is a very simple servlet that checks the dspace-config context parameter from the DSpace deployment descriptor, and uses it to locate dspace.cfg. It also loads up the Log4j configuration. It's important that this servlet is loaded first, since if another servlet is loaded up, it will cause the system to try and load DSpace and Log4j configurations, neither of which would be found.

I removed the context stuff from context.xml. This is to pursue a working configuration using the jspui that is copied into the tomcat webapps dir.

I edited webapps/jspui/WEB-INF/web.xml, replacing the dspace.dir param value with the DOS path (C:\dspace.....). This did have an effect. this gave the following error:

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
INFO: Loading provided config file: c:\dspace\config\dspace.cfg
INFO: Using dspace provided log configuration (log.init.config)
INFO: Loading: c:/dspace/config/log4j.propertieslog4j:ERROR setFile(null,true) call failed.
java.io.FileNotFoundException: c:\dspace\log\dspace.log (Access is denied)
        at java.io.FileOutputStream.openAppend(Native Method)
        at java.io.FileOutputStream.(Unknown Source)
        at java.io.FileOutputStream.(Unknown Source)
        at org.apache.log4j.FileAppender.setFile(FileAppender.java:289)
        at org.apache.log4j.RollingFileAppender.setFile(RollingFileAppender.java:167)

to fix this I did cd dspace;chmod -R 777 .

this gave

log4j:WARN No appenders could be found for logger (org.apache.commons.digester.Digester.sax).
log4j:WARN Please initialize the log4j system properly.
INFO: Loading provided config file: c:\dspace\config\dspace.cfg
INFO: Using dspace provided log configuration (log.init.config)
INFO: Loading: c:/dspace/config/log4j.properties
this looks alot healthier. Now when I visit http://localhost:8030/jspui/ I get the page I expect. Wow!

Saturday, November 22, 2008

ant, ivy, archiva, maven

I have been looking into how to use ivy to manage dependencies during an ant build. And this caused me to look at apache archiva. It is possible to use ant without archiva but unless one has a local maven mirror this will involve ivy going to an internet maven repo, which can consume alot of network bandwidth. I think this is the point of archiva, to have it as a local maven mirror when ivy finds the jar is not in its cache. Apparently, it can all be configured so that archiva is dynamically updated with missing components by takening them from a maven repo.

I tried and tried to get archiva working but I just could not do it. I've no idea what I am doing wrong. I got so cheesed off that in desperation I set up a jar+pom repo on my own workstations web pages. Ivy has no problem reaching those. This seems to make archiva redundant. Given that once the jar has been located ivy can be configured to put it in a cache, this does make me wonder what the point is of archiva.

Another weirdness I found, whch has got me really cheesed off with archiva and maven, is the state of the poms in the maven mirrors that I found. The mirrors seem to be a complete mess, with most things in the wrong places. For example xstream from thoughtworks is at the top level, and in org/codehaus and com/thoughtworks. Also the pom files always have a group name with dots instead of slashes. This tends to cause the download to give a flat directory structure. I manually set up structures for my web pages that keep the package structure in the jars. This meant I had to hack the poms to fix the group names. Of course this would not work with archiva since these changes would require a recalculation of the sha1 values. I'm glad I don't have to do that.

So, I've got something that works for me. It does involves alot of manual work to find the right jar file in a maven repo, given all the redudant copies in other parts of the tree. And I have to edit practically every pom file I download to avoid getting a completely flat directory structure. But this is price I am willing to pay to have a web space structure that follows the java package structure exactly for all the jars I have.

Friday, November 14, 2008

how to mount an ISO image on Windoze

Every now and then I need to mount an ISO image on Windoze. This saves having to burn a CD/DVD. Here's how to do it:

Go to http://www.tech-recipes.com/rx/62 /xp_small_free_way_to_use_and_mount_images_iso_files_without_burning_them

and click on the download link, winxpvirtualcdcontrolpanel. This is a ZIP that you need to 'run'. It is a self-extracting archive. It contains readme.txt, VCdControlTool.exe and VCdRom.sys.

Installation instructions
=========================
1. Copy VCdRom.sys to your %systemroot%\system32\drivers folder.
2. Execute VCdControlTool.exe
3. Click “Driver control”
4. If the “Install Driver” button is available, click it. Navigate to 
   the %systemroot%\system32\drivers folder, select VCdRom.sys, and click Open.
5. Click “Start”
6. Click OK
7. Click “Add Drive” to add a drive to the drive list. Ensure that the drive added is not a local drive. If it is, continue to click “Add Drive” until an unused drive letter is available.
8. Select an unused drive letter from the drive list and click “Mount”.
9. Navigate to the image file, select it, and click “OK”. UNC naming conventions should not be used, however mapped network drives should be OK.

Thursday, November 13, 2008

Using ActiveMQ and JNDI

I am using JMS again, this time via ActiveMQ. The difference is that time time there is no admin department to set up the queues for me and tell me what property names are needed for the various attributes, such as connection queue factory. Also I need to set up JNDI myself. On Windoze I wanted to set up the ActiveMQ server as a service. This was not documented but luckily it comes with a simple batch service installer. After a bit of digging around I found that once AMQ is running you can connect to a web-based admin facility via http://localhost:8161/admin. This includes the ability to browse the queues. Hermes may not be needed after all! There does appear to be some JNDI stuff inside ActiveMQ. Some help is given in http://activemq.apache.org/jndi-support.html but it is very short on detail. Dynamic queues lets us test things easily. Another little gotcha I found was that the binary install of ActiveMQ does not install the XStream jar bu that jar is needed to examine the contents of queue messages via the web-based queue browser.

Thursday, November 06, 2008

I am learning how to drive eclipse at last!

At long last I have taken the plunge! I am also using ivy in my ant build so I found I need to tell eclipse about this. The Ivy and IvyDE eclipse plugins need to be installed. But I wasn't sure how to proceed from that point. I found a tutorial at http://jira.red5.org/confluence/display/docs/Ivy+setup+with+Eclipse which helps.

Wednesday, August 06, 2008

xemacs and key mapping problems

For some time now I have got a warning when starting xemacs. The warning causes the window to be split into two, with the warning in the lower window. The warning is something to do with the keyboard mapping having mod1 and mod3 defined to the same key. I googled for answers but they all said the same - fix it using xmodmap. I tried it and it didn't work. So in the end I added the following to the end of my .emacs startup file:
(when (featurep 'xemacs) 
;; Don't warn me about nonsensical X11 modifier issues. I don't care 
;; if Alt is simultaneously Mod2 and Mod5 on this machine; I don't 
;; press it anyway. Yay separate Meta keys. :) 
(setq display-warning-minimum-level 'error) 
(setq log-warning-minimal-level 'info)) 

Monday, May 12, 2008

Windoze, php and mySQL

At PHP5 the windoze installation no longer enables mySQL by default. Here's what you have to do: you need to edit php.ini, adding the following lines:
extension_dir = c:\Program Files\PHP\ext
extension=php_mysql.dll
extension=php_pdo_mysql.dll
Now restart Apache. A simple php page with the phpinfo command should reveal that the mySQL extension is now present.

Sunday, April 13, 2008

How to fix corrupt Windoze registry permissions

For some unknown reason my Windoze machine got the registry all screwed up. Hey, it's Windoze, every Windoze user has this done to them eventually. The effect was that I could not reinstall Micro$oft Office coz it gave a fatal registry error during the de-install. All the Micro$oft knowledge base articles were as useless as each other. Shareware registry cleanup utilities didn't clean it up either. Eventually I found out how to do this. You need a tool called subInAcl. Download it from http://www.microsoft.com/downloads/details.aspx?FamilyID=e8ba3e56-d8fe-4a91-93cf-ed6985e3927b&displaylang=en Then create a DOS batch file, let's call it fix-office-perms.cmd, containing the following:
cd /d "%programfiles%\Windows Resource Kits\Tools"
subinacl /subkeyreg HKEY_LOCAL_MACHINE /grant=administrators=f /grant=system=f
subinacl /subkeyreg HKEY_CURRENT_USER /grant=administrators=f /grant=system=f
subinacl /subkeyreg HKEY_CLASSES_ROOT /grant=administrators=f /grant=system=f
subinacl /subdirectories %SystemDrive% /grant=administrators=f /grant=system=f
subinacl /subdirectories %windir%\*.* /grant=administrators=f /grant=system=f
Start a DOS command window, cd to where you put this script, then run it. Watch it repair the permissions. It takes several minutes to run. Strewth, what a hassle! But at least there is a way out. The corrupt registry seemed to be triggered by an error that happened during an attempted install of Visio. Towards the end of the install it said:
Could not open key: UNKNOWN\MsoHelp.HtmlHelp\CLSID.
Verify that you have sufficient access to that key,
or contact your support personnel.

Wednesday, March 26, 2008

Apache and skype conflict over port 80

I added apache to my Windoze setup recently. My windoze machine also has skype. This is when a discovered a nasty interaction. I found it on a forum at http://forums.devarticles.com/programming-tools-11/os-10048t-11921.html. Skype uses port 80! Yes, it even uses 443 (the https port) as well. Luckily these are the default settings and can be changed. And change them you must otherwise apache mysteriously fails to start. The Windoze event log reveals nothing. I eventually found it was a port conflict by trying to start httd from the DOS prompt.

Saturday, August 11, 2007

Getting jacORB working

I am back in the land of CORBA once more but with an ancient buggy version of Orbix. In an attempt to escape I thought I would try using jacORB then I could argue that we either use jacORB or a more recent version of Orbix. The great thing about jacORB with it being open source is that I thought it would be easy to try it out and get some basic development. Well that was the theory. The trouble is jacORB has a few wrinkles that caused me a bit of trouble setting things up. I did get it working eventually and it is just great now. Here's what I did:

Mistake number 1: I tried to use the binary distribution. It doesn't work. There are a few essential components missing. Apparantly some other developers have also been hit by this. The ant build of jacORB proceeds quite quickly and painlessly so the lesson here is just use the source distribution and build it using a top level ant build. Problem solved. See bug 765 at http://www.jacorb.org/cgi-bin/bugzilla/show_bug.cgi?id=765 for the problems with the binary distribution.

Multiple java SDKs: On machines with multiple java SDKs, where the default one may be an old one, you will need to hack jaco script to avoid this error: http://forum.java.sun.com/thread.jspa?threadID=651418&tstart=0. Hack the script to force the complete path of a Java 5 compiler.

Edit orb.properties to specify filename of NS OIR (you have to pick a path).

./ns -Djacorb.naming.ior_filename=

run grid demo:

jaco -cp 
"/export/apps/open_image/amarlow/work/JacORB/classes:$CLASSPATH:." 
demo.grid.Server
 jaco -cp 
"/export/apps/open_image/amarlow/work/JacORB/classes:$CLASSPATH:." 
demo.grid.Client

Now it works! Just remember to run your own app using jaco or setting up your own CLASSPATH manually to include all the jacORB jars that are needed.

trouble with xemacs and other X11 apps on solaris

I recently found out the cause for some strange problems on solaris when connecting to it via ssh and then trying to use X11 applications. This was when I tried to get xemacs working on solaris. The problem was that all was well until I tried to use cut-n-paste, including deleting characters or lines in xemacs. As soon as the function was invoked an X11 error message appeared and the application froze. It was necessary to kill xemacs (or whatever the X11 app was) using kill -9. For quite a while I thought it was because somehow I built the app wrongly. Eventually, I found this link with an explanation for cygwin users: http://x.cygwin.com/docs/faq/cygwin-x-faq.html#q-ssh-no-x11forwarding It is an FAQ where the question is: X11Forwarding does not work with OpenSSH under Cygwin. This turns out to be generally applicable for users of X11 apps when connected to machines via ssh. It is not specific to cygwin. Just remember to always ssh using the -Y option. Then all will be solved!

Sunday, June 17, 2007

Getting eclipse working on solaris

Why is it so painful to set up eclipse on solaris? I have recently started working with java and although java on MicrosoftWindows is very nice I have to have java working on Solaris. Hence I thought, "let's get eclipse on solaris so I can use its great debugging facility". I put a request in with the helpdesk and left it at that. A couple of weeks later eclipse still hadn't arrived so I thought, "I'll do it myself, how hard can it be?". I have an ancient Ultra5 at home running Solaris 7 so I thought I would install it on that and bring it in on a small USB drive. It turns out the eclipse executable you download from the sun website has all sorts of library dependencies that take a while to get sorted out. But even when those are sorted there are still pitfalls. You would think that with solaris and java being invented by Sun Microsystems the company would find ways to get the things to work together. Well I say, "where's the evidence?". I tried to get eclipse working on my Ultra5 for a couple of weeks now. I just succeeded this weekend. Here is the long and painful story of how I did it: 1) The first step had to to be to abandon using solaris 7. The version of X11 that comes with solaris 7 is just too old. Eclipse has all sorts of problems using the so-called ready-built installs that are around, so there is some build from source needed. However, it turns out that this is just too hard to do on older versions of solaris due to X11 differences. It is easier said than done to get an alternative version of X11 installed. I tried building the latest X11 release 7.2 from source and it will only build with the very latest GCC. Unfortunately there are eclipse components that currently won't build with that version of GCC. So after a week of trying to build X11, install the right version of GCC and build the various parts of GTK that eclipse depends on, I gave up and installed solaris 9. This was also a painful experience but more due to bad luck than anything else. The machine threw a wobbly during the solaris install. I'll admit there was a thunderstorm at the time. Solaris managed to get itself in a state where it tried booting in CPR mode, then shutting down, then rebooting again, only to shutdown again. Apparently, this is rare condition with a very esoteric escape route. On the reboot, type STOP+A to get to the ROM prompt, then enter the command:- set-default boot-file This broke the CPR boot cycle and the system eventually booted normally. It was then I found the file system was corrupt. One very tedious fsck later I was up and running again. 2) Use the famous Freeware for Solaris website, http://sunfreeware.com. I used to take a macho pride in building all the GNU tools I needed from source, and from knowing about the dependencies between the packages. But the trouble is some packages have become so big and complex that all the components required for a successful build have to be at particular versions, requiring particular versions of the GCC compiler. I can't cope any more. I made heavy use of this wonderful website. I wrote a little shellscript that used wget to suck all the pkgadd packages over in one go. Phew! Then the installs started. Here are the steps I took: a) create /usr/local, create other transfer dir someplace else. b) ftp the unzippd gzip package to the transfer dir from my linux machine (no openssh yet, so have to initiate ftp from linux to solaris). c) pkgadd -d gzipPackage to install into /usr/local/bin. d) ftp all the other packages to the transfer dir e) use gzip to unpack them all. f) Did selective installs of these packages. Started with bash (phew), bzip, gcc, zlib, tar, bison, flex, automake, autoconf, binutils and make. Installed many others that I won't mention here. g) Installed some of the packages eclipse requires, such as glib, atk, libtiff, pango and gtk. h) Tried to start eclipse and found a few libraries still missing, e.g. libglib-2.0, libgmodule-2.0 and libgobject-2.0. Installed glib-2.13.0 which made this problem go away. At last, doing an ldd on the eclipse executable says that all libraries are found. 3) Build gtk+-2.2.4 from source. This step was necessary because it turns out that the version of gtk on the sun freeware site has been built wrongly. Some of the symbols have internal linkage instead of external linkage. This problems shows up as a fatal relocation error, symbol gdk_font_equals not found when you try to run eclipse. The first thing to realise is that when you have to build a GTK component from source, do not make the mistake I did, which was to try to use the most recent version. Use the one closest to what you already have instead. I already tried using the latest GTK components when I was on solaris 7 and there are just too many problems. So I downloaded v2.2.4. It failed to configure. I had pkgadd'd glib1.2.10 but gtk+-2.2.4 requires at least glib-2.1.4. So I pkgadd'd glib-2.13.0 on top which seemed to work. The next problem was configure did not spot that I had installed freetype 2.3.1. This is because freetype changed the way you have to include their header files. I had to hack the configure script to cope, changing the include code to: #include #include FT_FREETYPE_H Next the X11 check failed. This was because the test app was failing to find gethostbyname but the configure script assumed it must be failing to find the X11 symbols. I hacked configure again to force -lsocket -lnsl. Next, it failed to find libexpat. I pkgadd'd it and then, eventually, configure succeeded. At last! Doing a make at this point also failed but the failure was in one of the demo programs. The libraries built so I did a 'make install' and tried to run eclipse. Eclipse said there were no fonts, but at least it ran. 4) Set up X11 fonts. At first I thought the problem was do with the fontconfig install, so I did a build from source of that. But it made no difference. Eventually, I realised that the fontconfig configuration was not being installed in the proper place and was not referring to the X11 fonts that come with solaris. The tipoff is to use the command "xlsfonts", which lists the fonts solaris-X11 knows about, then give the command "fc-list" which gives the fonts fontconfig knows about. The former gave a reasonable list, the latter gave an empty list. The fontconfig install creates the directory /usr/local/etc/fonts. This needs to be symbolically linked to /etc/fonts (which didn't even exist at this point). Then fonts.conf needs to be edited. The command "xset q" shows where the solaris standard X11 install puts its fonts. But beware! Do not add all of these to fonts.conf! Only add the dirs that contain compressed pcf files. Do not mention the directories with the TrueType fonts. If you do then fc-list will hang and so will eclipse. 5) Get JDK1.5.0. At this point eclipse ran but immediately produced an error saying that the JRE is too old. Solaris 9 comes with JRE1.4. This is not recent enough. Come on Sun! Eclipse is THE number 1 java development environment, so please make sure that your downloadable solaris installs support it. Tracking down suitable versions of the JDK is harder than I thought it would be, thanks to sun's confusing website, their mandatory registration proceedure, and the confusing plethora of java environment names (jdk, sdk, j2ee, standard edition, enterprise edition, java studio etc etc etc). Eventually, after a number of false starts, I got hold of jdk-1_5_0_12-solaris-sparc.sh which installed ok. 6) Take the rest of the day off. That's it! With the right sun freeware packages installed, with gtk+-2.2.4 built from source, the X11 fonts configured and JDK1.5.0 installed, eclipse is now up and running.

Friday, March 09, 2007

What to do when grub gets in the way of windoze

When you've put linux on a machine it tends to use grub during the boot. This can pose a problem if you decide to revert to windoze. Most windoze install procedures leave the MBR alone. This causes problems because a windoze install usually means at least one reboot during the installation process. If grub is still on the MBR this causes a problem because grub will then try to boot linux but will fail because the windoze install that is partway through overwrote it. At this point the boot tends to hang. Heres how to get around it: and save to a USB flash drive.Download MbrFix (http://www.ambience.sk/fdisk-master-boot-record-windows-linux-lilo-fixmbr.php) Whilst linux is still there use the following grub commands: grub> rootnoverify (hd0,0) grub> makeactive grub> chainloader +1 grub> boot Now you can install windoze. When it gets to the boot you will be put into grub again. Use the commands above to let the boot carry on and it will boot windoze. Once windoze has fully installed you need to run a MbrFix . Get it from the flash drive you prepared earlier. Help is builtin. Now grub will be gone and reboots will behave normally!