Olexiy (Alexey) Prokhorenko likes to live in different places and blog about different things. Ruby, JRuby, Java, Javascript, Scala, Rails, Spring, Hibernate... just to name a few. And different aspects of product management and agile software development. On the other note, he also loves speed in form of flashy cars and sportbikes, so those topics may find their place here, too.

Thursday, June 29, 2006

JNDI Mystery

Well, this post was forced to appear initially by Websphere Application Server Community Edition. Un-intentionally. But still. The reason is WASCE's strange behaviour to EJB's JNDI names. When trying to deploy EJBs to the server, I configured properly required openejb-ejb.xml, clearly putting there jndi-name attribute. But my servlet was not able to find EJB in JNDI directory. Well, that's odd. Then I did tiny investigation process. I've created simple stateless EJB with jboss.xml, openejb-jar.xml and weblogic-ejb-jar.xml. Then I also created Web application with web.xml. Files contained the following information:

jboss.xml
...
<jboss>
<enterprise-beans>
<session>
<ejb-name>HelloSessionEJB</ejb-name>
<jndi-name>ejb/JHello</jndi-name>
</session>
</enterprise-beans>
</jboss>
...
weblogic-ejb-jar.xml
...
<weblogic-ejb-jar>
<weblogic-enterprise-bean>
<ejb-name>HelloSessionEJB</ejb-name>
<stateless-session-descriptor>
<jndi-name>ejb/JHello</jndi-name>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
...
openejb-jar.xml
...
<openejb-jar xmlns="http://www.openejb.org/xml/ns/openejb-jar-2.0" configid="com/objecty/ejb">
<enterprise-beans>
<session>
<ejb-name>HelloSessionEJB</ejb-name>
<jndi-name>ejb/JHello</jndi-name>
</session>
</enterprise-beans>
</openejb-jar>
...
Without any doubts, I pretty clearly insist on binding my EJB to ejb/JHello in all of these vendor specific deployment descriptors.
Now let's see what we have in our

ejb-jar.xml
...
<ejb-jar version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee" xsi="http://www.w3.org/2001/XMLSchema-instance" schemalocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>demo-ejb</display-name>
<enterprise-beans>
<session>
<display-name>Hello SessionFacade</display-name>
<ejb-name>HelloSessionEJB</ejb-name>
<home>com.objecty.ejb.HelloSessionHome</home>
<remote>com.objecty.ejb.HelloSession</remote>
<ejb-class>com.objecty.ejb.HelloSessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
<ejb-ref>
<ejb-ref-name>ejb/EHello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.objecty.ejb.HelloSessionHome</home>
<remote>com.objecty.ejb.HelloSession</remote>
<ejb-link>HelloSessionEJB</ejb-link>
</ejb-ref>
</session>
</enterprise-beans>

<assembly-descriptor/>

</ejb-jar>
...

It looks silly now, but let me explain. As you can see - we want our enterprise bean HelloSessionEJB to refer to itself binding into JNDI as ejb/EHello. All of the lines inside .. are required in the given example - please be accurate here. There is no too much sense in the refering from one bean to itself such weird way. But this is done only exceptionally in testing purposes, so we would be able to find out what JNDI names are accessible by EJB and our WAR classes.

So let's go ahead for now.
Here is our

web.xml
...
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
...
<ejb-ref>
<ejb-ref-name>ejb/WHello</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<home>com.objecty.ejb.HelloSessionHome</home>
<remote>com.objecty.ejb.HelloSession</remote>
<ejb-link>HelloSessionEJB</ejb-link>
</ejb-ref>

</web-app>
...


Again, it's pretty self explaining. With the help of ejb-ref we are saying that we want to refer to our enterprise bean from this Web application, and to use name ejb/WHello.

So, at this step we should have the following names binded to our entperprise bean in JNDI:
ejb/JHello - based on vendor-specific deployment descriptor
ejb/EHello - based on common spec ejb-jar.xml descriptor
ejb/WHello - based on common spec web.xml descriptor

Now, here is the list of our application servers. Meet them: IBM Websphere Application Server Community Edition 1.0.1.2, JBoss 4.0.4.GA and BEA WebLogic 9.1. Terrific band. :-) Everything is running on Mac OS X (even if there is no official support for that) and with JDK 1.5 (WASCE does not have official support of it either). Because of so many "unsupported" options I cannot insist that this is vendor nuance, but it does exist, so you need to be aware of it no matter what.

Take a wild-wild guess. Which JNDI names will be accessible from EJB and from Web Application in each of these three ASs? Write it down. Then go ahead and check how it is in real-life (Please note, that you can access only these names which I will mention nearby. Other modifications of them by adding/cutting java or comp. or env, or whatever else will not give you a positive result. Keep this in mind).

JBoss did a pretty fine job. From EJB we are able to access java:comp/env/ejb/EHello and ejb/JHello. From WAR we are able to access java:comp/env/ejb/WHello and again ejb/JHello. That means that even without having ejb-ref in ejb-jar/web XML files we still are able to access our JNDI binded enterprise bean by name ejb/JHello.

WebLogic
was great as well. Actually results are the same (as JBoss), and names which are accessible from EJB and WAR are the same as well. That's pretty universal and standard. That's fine.

Now WASCE (Geronimo is the name). Here I see big difference. I was not able to find out how I can access ejb/JHello. Neither from EJB nor from WAR. No way to do that. The question - why do we need and use this jndi-name attribute in openejb-jar.xml is jumping in my head, but I do not have an answer. However, something still does work. We can access java:comp/env/ejb/EHello from EJB and java:comp/env/ejb/WHello from WAR. So ejb referencing does work and that makes sense.

Isn't it funny? So to be able to have standard application, where we are able to access JNDI binded EJB by one common name - the name should be "java:comp/env/ejb/TheName" and in all and every of these deployment descriptors (in all ejb-ref, in all jndi-name, etc.) we do need to have "ejb/TheName". This way, when we will port our application, we will not get into some stupid situation. However, this makes everything pretty confusing. We kinda define JNDI name in three different places. Weird, is it?

Tuesday, June 27, 2006

Other WAS CE installation

After I blogged about my experience installing WAS CE I found a link to IBM's forum where this topic (WebSphere Community Edition installation on Mac OS X) was discussed. They mentioned a bit other way (not what I did) but still possible and working. Some will think that it is easier. Anyway, it works too.

WAS CE on Mac OS X (PowerPC)

This post is about my experience installing and launching WebSphere Application Server Community Edition on Mac OS X. As mentioned in post's title - I tried everything on PowerPC, but I believe everything will be working almost the same way on Intel.

Disclaimer: There is no official support for Mac OS X platform for IBM. There is no official release of WASCE for Mac OS X. So there is no way one can be sure that something will be or even could be working. I just tried and it worked fine for me - who knows how it will be for somebody else? ;-)

To begin with, I'll advise you to download WASCE first. The version we need is Server for Unix. (By the way, the version of WASCE which I tried was 1.0.1.2, just in case if you need that). It's kind of small one, around 40mb, so you'll be pretty fast with having it on your disk.
Next step will be some tricky installation procedure. Change directory where you download the file. Now you need to extract installer files. It can be done pretty easy with command
./wasce_setup-1.0.1.2-unix.bin -is:extract -is:log wasce_extract.log
as shown below:


Be attentive - the path which was displayed upon finishing this execution will play it's role in our next command. In our case it is istemp12124178165241. Ugly, man! ;-) Let's try not to type it to many times and optimize the next command a little bit
TMPINST=your_displayed_path_with_files ; export TMPINST ; /System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/bin/java -cp . :$TMPINST/setup.jar: -Dtemp.dir="tmp" -Dis.jvm.home="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home" -Dis.jvm.temp="0" -Dis.media.home="$TMPINST/setup.jar" -Dis.launcher.file="wasce_setup-1.0.1.2-unix.bin" -Dis.external.home="." run 1>>wasce_install.log 2>>wasce_errs.log
and you can see how it worked out for me below


Important - as you can see we are using 1.4.2 Java, even if I am running 5. It's kinda important during installation - but later you still we'll be able to launch server with Java 5 (even if it's not supported).

Now, let's continue. It will be a little easier now - so enjoy my screenshots.




We are almost done, at least all the stuff is installed. It really is - see:


Unfortunatelly, there is some problem. It is small and fixable, but it exists and we need to get rid of it before we can go ahead and play with server. So the problem is that for some reason installer does not set up properly directory and scripts attributes. We need to fix it by getting into our installation directory and do that manually with command
cd /Where/Is/It/Installed
chmod a+x bin/ config-store/ graphics/ lib/ repository/ schema/ var/
chmod a+x bin/*.sh

tt is shown on the screenshot below


Now, hold on breathing. We are about to start the server. (Can you believe that?! :-)
That is unbelieable simple - sh /Where/Is/It/Installed/bin/startup.sh and we are in process:



Wow, here it is. Let's check it online:



It is really running on a Mac. Looks nice and interesting. Enjoy the fun now! When finished, don't forget to stop it :-)


P.S. Important note - default access login is system and password is manager. (You can find this in official documentation, thought).

WebSphere Communities

Actually I though there is no one. But while Googleing around, I found Southern California WebSphere User Group. Their site states that last meeting was in January, but hopefully they are active in their mail lists. ;-)
By the way, I also found WebSphere Global User Group community as well. Great!

Friday, June 23, 2006

And again reviews

Yeah, and two more reviews. And it's about buzz-wording books. First one is:

"Real World Web Services" by Will Iverson

Well, this book is just O.K. It will give you basic and essential understanding of what all this buzz about, and probably you will even understand why we need to enjoy advantages of Web Services. You definately will find an examples of companies who are using them. But if you'll think if this book will help you to get a hands on experience developing Java code for Web Services, and especially getting deeply into technical details of such code - you will be wrong. That's a disapointment. I see this book like an intro now - but nothing more. Ooops! ;-( I do not suggest you this book if you are going to dig into Java Web Services development. As for me, I grabbed much more help in that from numerous articles on the java.net (I am not even talking about whole Web), and even from official documentation from Axis and JAX-RPC.

And next one is:

"Java Web Services in a Nutshell" by Kim Topley

Of course I compared it (for myself) to the previous one. And yeah - this one looks better. It's like a detailed documentation on using JAX-RPC. Very in details, covering pretty much of it's components. Nevertheless, there is almost no single word about Axis there. No real-world examples. Nothing like that. So, well, if you want to have reference manual, which you probably would never read from cover to cover, but in which you want to seek answers for your questions while developing code for Web Services - this book is for you. And it's a pretty nice manual. But do not expect to get more. Personally I liked this book, no matter what it misses. It's good in other way. Just other kind of book ;-)

Review of requirements

Title of this post sounds strange, but do not pay too much attention to it. I am just playing a bit around book's title which I am reviewing below:

"Mastering the Requirements Process" by Suzanne Robertson, James Robertson

The book is not about Java development, but about software development process - requirements gathering. The first thing I noticed in it is that it contains pretty much of quotes from other books. From Agile-about books. And I really liked the way how authors pointed out pros and cons. Great - there is no silver bullet, and agile processes should not be used blindly.
I also liked that this book has some example of specifications template, which can be followed when preparing your own requirements. Also, every section of the process is clearly stated and given with different examples, and detailed explanation. May be too detailed, but this goes next :-)
What I don't like is that there are few diagrams which looks funny and easy, but not strictly clear and official. Sometimes I wish things to be more standard. I.e. they showed formal SDLC process in too funny way. No good, no good... And I didn't like that it's too big. I mean book. Well, you can minimize given material at least 1.5 times. But may be it's only my preference?

And the overall picture - one thumb up, and half thumb up. Well, it is 4 of 5 stars. I think this is the best book covering requirements gathering topic I ever read till date. Cool!

SQL*Plus and Mac OS X

Recently had a necessity to access remote Oracle database from my laptop, without logging in via different "mediators" shells, etc., so I decided to find out if there is a possibility to use SQL*Plus client on Mac OS X. And you know what? I succeed. :-) If you would like to repeat my unbelievable success follow the next simple steps. You need to download Instant Client for Mac OS X from Oracle's website. (By the way, there are versions of Instant Client for other OSes also there. :-)
What exactly you need is Basic package and SQL*Plus package. Of course, you can get more, but the mentioned ones were enough for my needs. So, download all these stuff, unpack into one directory and next step is right ahead.
You will need to change a little bit environment variable DYLD_LIBRARY_PATH. I prefer to ease everything I can, so I just did that in my Bash's profile, so it will be easier to work with the client everyday. Here is what I have:


You'll had to re-login (if you did the same) so Bash will reload your profile. Now, everything will be even simpler. To connect to our remote database I wanted to use so funny called feature "TNS Easy Connect", which I believe appeared in Oracle 10g, but anyway. It is describe a little bit more in details in this blog entry, but in my case I'll just give you a simple self-explaining example. Here it is:


Simple and easy, like 1-2-3. Have no idea why there are a lot of questions on forums how to do that. :-) Hope this helps as well.

Monday, June 19, 2006

Chapter review

My Oracle knowledge is kind of weak one, so I am trying to sharp it even a little bit more. While doing that, I found very enjoyable book:

"Oracle Database 10g SQL" by Jason Price

It's very nice and pretty understandable for such beginner as I am. I really not too much an Oracle guy, but very interested in it. This book contains a lot of common material on SQL (which is definately not new for me :-) but keeps itself on track with a lot of Oracle-related stuff. But my favourite chapter happened to be "Chapter 11: Introducing PL/SQL programming". Like from the well-known movie the popular phrase "I see dead people" - I screamed "I see BASIC"!!! :-) Yeah, PL/SQL looks pretty much of BASIC for me. But it's interesting and definately helpfull. And speaking about the book again, I should notice that it's explained very nice, very understandable. No deep details, it's just an introduction - but I was satisfied. And still am.

Monday, June 12, 2006

One more book review

Today's book is

"Enterprise Messaging Using JMS and IBM WebSphere" by Kareem Yusuf

The way this book started, I thought it will be a little bit watery and too WebSphere-related. But I was pleasanty surprised being absolutely 100% wrong! Now I can describe this book in few simple words - awesome, professional, detailed. I found in this book a lot of interesting material about JMS, MDB, WebSphere servers, transactions, etc. Can spend all day just listing that - but it's all in this book. I always was looking for some JMS book, but almost all of the books missed something, but that one is just 100% what I need. I do not know if it will fulfill your needs and requirements, but it does fulfill mine! Highly advisable. (I never worked with WebSphere's servers professionally, but after reading this book I regret that very much ;-) Wish IBM to have some free developers licenses now)

Thursday, June 08, 2006

LIMIT/OFFSET in SQL

I want to write this down, cause I have a lot of chances to forget it. ;-)

As all of us know we do have LIMIT/OFFSET features in MySQL and PostgreSQL. But do not have them in Oracle. The following code can help us:


where "0" - is an offset, "4" - is a limit, and "select * from dept" is a query to execute. It does not sound right if you will compare it to what we can have with usual LIMIT/OFFSET, but it does work.

By the way, I found very usefull this "Comparison of different SQL implementations" link. Even kind of enjoyable reading. :-)

Just noticed that...

There are Oracle's 10g server and SQL developer available as downloads at Apple. That's pretty nice. Shame on me that I didn't notice that earlier.

Wednesday, June 07, 2006

Mac files encryption

I did small research on what kind of encryption for files do we have here on Mac OS X and here is what I got. We can encrypt files (correctly said - disk image) with default Disk Utility tool which every Mac user has. There we are using AES-128 encryption, which is kind of reliable and good one. As a result we will get DMG file, which can be easily opened on any Mac, but... Windows users are not the ones who have this priveledge. But well, I do not know if I should care about this that much. I am Mac user, and still in Windows world there are some DMG to ISO converters, and burners, so probably it could be solved.
Okay, and the second thing I found was Mac GNU Privacy Guard which is a Mac port of GnuPG. There are few docs & tutorials about it - "Configuring GunPG on Mac OS X" and "Using GnuPG encyption with Mac OS X Mail". Probably there are few others, but these were the first I found. All information is there, but I believe I am personally just a pretty lazy human - so I prefered first variant. For me it's just easier. Pack, set password and upload.

Shortest review

Finished new book, and my shortest review is for

"Java Thread Programming" by Paul Hyde

Do you feel that your knowledge of Java threads is weak? Do you have only basics understanding of it? Do you think that you want to learn more? This book is for YOU. Really, I think this book solves any your problem with Java threads. Answers any question. I like how deep is explanation, I like code examples, I like the style of book, and I like all topics, no exclusions! MUCH MUCH advisable.

Box.net service

Recently I found terrific service - Box.net. It offers 1Gb of FREE storage space, where you can keep all you files, all you backups, everything you need - it's a real alternative to iDisk. I really really suggest everybody to give it a try. Awesome - I found it's interface just brilliant and very intuitive. This stuff just works. Use this link to register with Box.net - it's under my refferal, and I hope if 5 people will register via it I'll get free upgrade for my account.


I don't know how this service will feel itself when Google GDrive will appear (when? how? will it?...) - but for now it's the best which I saw. Really good. The only thing I am interested in at the moment is finding some tool for Mac OS X for files encryption. I care about my privacy, no matter what service claims. (More about this in my future posts).

Tuesday, June 06, 2006

Bookmarking!..

Finally, I found this feature from Google -- Bookmarks! Actually, it's not a new one, but being here for a while, it was just me who missed it all the time. Pretty nice. However, interface definately needs more work, but it seems to be working pretty stable and fulfills my needs. Now I can have my bookmarks online too, without backuping them all the time. ;-) Even if they claim to have ability to add bookmarks with their Google Toolbar, unfortunately it's not true for Firefox version of it yet. But we have two different plugins by third-party developers - Google Bookmarks extension and Google Bookmarks Button (I like the second one more, and using it). Cool!

Update: yeah, these extensions do not work too good -- slowing down Firefox pretty much...

Monday, June 05, 2006

One more review

Continuing my book reviews, here comes another one.

"Programming Jakarta Struts" by Chuck Cavaness

Usually, I am not a big fan of O'Reilly books. Sometimes their quality (I mean in technical meaning, in the meaning of information putted into these books) are not enough satisfactory for me. But, always there are tastiest exclusions from this rule, like Head First series.. and this book by Chuck Cavaness is one of such exclusions! I used to own first edition of this book before, until it was lost/or stolen, and I really enjoyed it. I like this second edition even more. In general, I like how this book is written, which material does it have, and that it covers except plain Struts - also related things -- of course not in details, but it gives an overview, and some notes. Without any doubt, for myself I should say that it's the best Struts book I was able to read. There are few dozens of other "about Struts" books, but none of them is even close to that one. But, it's only my preferences - few people which I know consider it just O.K., without being that excited as I am. But again, personally I - can highly recommend this book to anyone.

Thursday, June 01, 2006

Two reviews

Recently I ordered a bunch of used books to add them to my personal library and to test how this service of Amazon works. Everything works just great, and books are very nice too. My short one sentence reviews are below.

"Java Transaction Processing : Design and Implementation" by Mark Little, Jon Maron, Greg Pavlik
Book is just great, very detailed explanation of all in and outs of this not the easiest thing in Java world. I really found a lot of interesting and new for myself. Never expected to see so many details. It covers also real-world applicability of transactions in Java practice, and that's a nice thing to have. I very very suggest this book to everybody - must have. Both thumbs up!

"Java(TM) Performance and Scalability, Volume 1" by Dov Bulka
Nice but kind of outdated book. Still it does a pretty nice stress on many moments in real life Java applications where developer can loose perfomance and even not thinking why it happens. Some parts are okay, some are so-so - in general book is nice to read, but unfortunatelly (again) it's a pretty an old one. If you have extra couple of dollars and like to read technical books - you can buy it and enjoy it. Afterall, it's not that expensive if you buy used copy! Nevertheless, otherwise, you'd better try to get some more specific or newer book on Java tricks. Half thumb up. :-)

I still have few books more to read, and few of them still didn't arrive yet. So more reviews to come :-)

Tiny Mac-widget toy :-)

I do not like to drop a lot of things on my table (because I prefer small tables) - so I decided to go with virtual photo frame, instead of usual. And I really liked VirtuFrame - which is free and cool.

Update: Decided to go back with Dashboard and utilized pretty widget Frame Up!. Cooool...