jquery

gist JS

Sunday, November 27, 2005

getting down to work

So, the real purpose of the new machine was to learn about all the cool new web frameworks work. Yeah, I know it sounds a lot like programming in my free time, doesn't it?

Goals:
1) Write web-app using Spring, Hibernate and either Spring MVC/Spring WebFlow or JSF.
2) A+++ coding practices the whole way, ie Design it in UML & fully TDD. (eep!)

So let's do it to it!

Eclipse
Eclipse SDK 3.1.1
(We'll wait on 3.2 until MyEclipseIDE supports it)

Unzip to c:\Program Files
Now download:
emf-sdo-xsd-SDK-2.1.1.zip
GEF-ALL-3.1.1.zip
JEM-SDK-1.1.0.1.zip
wtp-1.0M9.zip

From eclipse.org and extract all of them to Program Files. It's a bit weird, but just make sure that you'll overlay the eclipse directory over the existing eclipse directory so everything lines up and OK the overwrite. It won't hurt anything.


MyEclipse
MyEclipse is pretty darn nice for a lot of things although I haven't fleshed it all out yet. Primarily I like it's Hibernate features and the DBExplorer. Oh, and $29 a year is such a soothing price point. I probably struggle along if it cost $60 but for the price I'm all theirs.

Go do the myeclipseide.org download of 4.0.

Then update to 4.1m1 with the directions here.

Fire up MyEclipse and everything's good to go...


CVS
Can't do anything without CVS right?
cvsnt-2.5.03.2151.msi from cvsnt.org is the trick for Windows. Pretty easy to setup too. Only trick is putting your repository in an easily backupable place.

Open the CVS perspective in Eclipse and add the repository. I did a pserver connection although apparently there's some real security issues if you're going over the net. We're not, so bada-boom.

Postgres Database
Now a little postgres vs mysql debate... settling on postgres, mostly since we use it with success at work. More comments here...

Definitely 8.1 ...

First off it conflicts with some SSL dll's from CVSNT. Clicking ok and proceeding... We'll see if that comes back to haunt us. Now we run into a bit of confusion with the users. I've ended up with a windows services user with name postgres, but the randomly generated password has characters I can't even find in charmap.exe. Eek. We'll hopefully not a big deal.

Ok, running pgAdmin III from the start menu and I create a new DB. Darn I wish I remembered more about templates... anyway, template1 and 'go do it', but first I make a new user a\so that we're not doing everything as 'postgres'


phpPgAdmin
Sigh, but now I'd like to use phpPgAdmin. It's darn nice for viewing DB guts. Sadly this means apache and php installs as well. Such is life though, right?

Apache
apache's easy, download the most recent here, and do an easy windows install.

PHP
php. Make sure to do the zip package/manual install if you're going to use apache. Other wise no love. php-5.1.0-Win32.zip is what you're looking for. Files here.

Extract this to C:\Program Files\ and change the directory to just be PHP.

Read the install and we end up copying php.ini-recommended to just php.ini.
Apache2 looks like it'll do the PHPRC environment variable for us...

Next we add to our apache/conf/httpd.conf file right under the rest of the 'LoadModules'

PHPINIDir "C:/Program Files/PHP"
LoadModule php5_module "C:/Program Files/PHP/php5apache2.dll"
AddType application/x-httpd-php .php

Fire up apache by running cmd, and run apache/bin/apache start, and this should go off no problems.

Back to phpPgAdmin...
Now, we download the phpPgAdmin-4.0 zip, throw it in htdocs, add a little
<Directory "htdocs/phPgAdmin-4.0">
</Directory>

to the httpd.conf file...

goto http://127.0.0.1/phPgAdmin-4.0/index.php and....

404. Durnit. Clearly I don't understand apache config yet in the 2 minutes I've devoted to it.

apache/log/errors.log
[Sun Nov 27 18:37:14 2005] [error] [client 127.0.0.1] File does not exist: C:/Program Files/Apache Group/Apache2/htdocs/phPgAdmin-4.0

but it does. hmm. ahah! notepad.exe saves the day again shows us:
explorer: C:/Program Files/Apache Group/Apache2/htdocs/phPgAdmin
error.log: C:\Program Files\Apache Group\Apache2\htdocs\phpPgAdmin
silly p's.

now we get:
Your PHP installation does not support PostgreSQL. You need to recompile PHP using the --with-pgsql configure option.

hah! as if we'd even compiled it to start! fine fine, you can say we should slow down and think of these things before we start, but I say bah. Look how far we've got. (and how insecure we presumably are, but... well no but for that one really.)

Back to PHP...
So, back to the php manual install. Which talks about windows extensions here...

And we're off, back to php.ini and it's easy:
change extension_dir = "./" to
extension_dir = "c:/Program Files/PHP/ext/"

and uncomment
;extension=php_pgsql.dll
like so
extension=php_pgsql.dll

restart apache and.... wahoo! at http://127.0.0.1/phpPgAdmin/index.php PHP enabled.

Now, login as the 2nd postgres user that we created. I noticed that it said logging in as postgres or admin won't work unless you muck with the .ini more for security reasons. Worksforme.

DB/Eclipse integration
Back to MyEclipse and let's plug her in.
Window->MyEclipse DB Exloperer.
DB Browser->New DB
Driver Libraries->New @ PostgreSQL\8.1\jdbc\postgresql-8.1dev-403.jdbc3.jar
ExampleURL: jdbc:postgresql://localhost:5432/yourDB

Hmm. No love again. Can't login as my DB user. Ahah. Can login as the postgres user. That's unfortunate, but oh well. Looks like we're ready to ORM to our hearts content!


Tomcat. Since we'll surely want it.
Ok, we'll probably want Tomcat too right? Ok download 5.5 whatever. This install's pretty easy up until the 'Admin application'. If you just do what you'd expect, you end up with a big fat "Tomcat's administration web application is no longer
installed by default. Download and install the "admin"
package to use it."

So, off to the web and....

Re[5]: tomcat management and Tomcat Administration
Steve Russell, May 27, 2005 [replies:5]
Hi, I was also unable to find any instructions on how to do this, but I managed to integrate the admin package by doing the following:

1. Unzip jakarta-tomcat-5.5.9-admin.zip & copy conf\ and server\ folders and contents over your own Tomcat conf & server folders (into CATALINA_HOME folder)
2. Copy CATALINA_HOME\server\webapps\admin\admin.xml to CATALINA_HOME\webapps\admin.xml
3. Add a line to CATALINA_HOME\conf\tomcat-users.xml to allow a user to login to the manager & admin modules, e.g.:
4. Restart Tomcat

HTH.
Steve


Which fixes it very nicely thank you Steve. Frankly it confuses me a bit about how Tomcat really works, but hey.

UPDATE
Disregard the above. It works, but as with most things that work even when you don't quite think they should, it's a bad idea. The real problem is that there's a C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\ROOT\admin directory that's stealing your thunder. All you need to do is wack this guy and it'll stop taking priority over the server\admin directory. Yes!

Back to eclipse, J2EE perspective, servers... add our new tomcat server, which requires going and finding the sdk. Easy enough.

Conclusion
So what do we have now?? Well, we're just about ready to rock. Next up will be design ing the structure in eclipse and then looking at the best ways to instantiate our model in the database and within our spring framework. Hopefully it can go:

UML -> POJO -> Spring Beans -> Hibernate Mapping -> DB tables

We'll see what the state of the tools are, and how much typing this will take....

No comments: