Tuesday, July 12, 2011

Bad Version Number in .class file

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12

If you have been developing in java and have been at it for a while..you may have encountered the above exception...

Before jumping into the fix, lets first discuss the problem itself..."Bad Version number in .class file"...What does it mean?

To figure it out, run the command javap -verbose {classFileName} on the command prompt(assuming win os). Sometimes the output generated is too much, so you might want to direct the output to a file.
Now in the output of the above command, search for words such as major version and minor version and you will find something like (obviously, the numbers can be different in your case)

  minor version: 0
  major version: 50


The following table tells you that the java platform version for the combination is 1.6
major  minor Java platform version 
45       3           1.0
45       3           1.1
46       0           1.2
47       0           1.3
48       0           1.4
49       0           1.5
50       0           1.6
 
Essentially, this means that my code was compiled using java 1.6. Now your error happens when the java runtime tries to run the file and finds the version number in the .class file inappropriate. This can only happen if your runtime java version is lower than the compile time java version.

The fix: Fix the runtime java version or compile in a lower version of java as appropriate. In an ideal world, both of them should be the same but they may differ for a variety of reasons,so just make sure the runtime version is the same or higher than the compile time version...

Now, depending on how you are running your program..you will need to make changes at different places...if you were running your program in Eclipse..you will need to change the 'Run' configuration (JRE tab)..if you are dropping a library in ant by developing a custom task..you will need to make sure that ant has a suitable version of java..(to figure out which version of java ant is using..run ant in the verbose mode)..pointing  JAVA_HOME to the correct jdk/jre typically fixes the ant issue

Hope this helps..


Sunday, January 9, 2011

End of an Affair - Completing SCEA Part 2 & 3

Ever since i submitted my exam on Jan 9th, i have been following a ritual. I wake up every morning and the first order of the day is to check my gmail. This morning was a pleasant surprise when Oracle sent a terse mail that i have been certified as an Enterprise Architect on the JEE Platform.

I have never been much of a blogger but this becomes an opportune moment to talk about my experience with the exam particularly because it took me about 1.5 years to get it all done(total lapsed time) and i feel its time to give back to the community who provided me enough help to walk through my own journey.

Enough Blabber...lets talk about the assignment now..

If you have looked into the assignment in some level of detail, you will be faced with the following kind of issues/questions -
  • How much time would it take to complete the assignment? 
  • There are too many opinions about addressing a problem in the assignment, and sometimes they conflict with each other
  • The assignment is slightly vague and somethings don't seem right/don't seem to add up.
  • Which UML should i follow? - 1.x or 2.x
  • Which tool should i use?
  • What technology stacks do i use to realize the solution?
  • Some people say that they write a whole lot of stuff besides whats required by Sun in the exam?
  • Should i have one class diagram or multiple class diagrams?
  • What should be the level of detail in my sequence diagrams?
  • How do i know when i am ready and my solution is complete?
  • What do they ask in Part 3?
I am sure there are many more questions and i can't even list all of them..but the above were the kind of questions i had when i was working on my assignment..

Let me take a shot at answering the above questions with my own impressions of the exam, as usual feedback/suggestions/brick bats(softer ones) are always appreciated.

How much time would it take to complete the assignment?

It took me about 20 days to finish Part 2 and 3. I did not work on the assignment for 1 whole year and spent about 4-5 hours each day(for 20 days) towards the end of my 1 year deadline. Most of the actual time was spent in understanding the problem statement.Do not underestimate it. The technology solutions are relatively simpler but understanding the gaps in the problem statement, understanding the nuances of the problem statement is much more challenging. I had identified and informally documented the risks of a possible system even before i started documenting the solution to my assignment. How much time you take depends on your level of experience in designing solutions but 60-70 hours seems a right estimate to me.


There are too many opinions about addressing a problem in the assignment, sometimes they conflict and sometimes they conflict with each other

This is one of the biggest problems(misery?) of this exam. There are too many 'opinions' out there and they often conflict with each other. To top it all you don't know which opinion to trust. The problem is escalated because all of them seem to have qualified the exam and yet they disagree on important pieces of the solution.Sun doesn't provide exam scores (just a Pass/Fail grade) and hence you don't know whose answer was closer to the bulls eye.You can mitigate this problem with your own knowledge and experience(there is no other way). If you don't have an opinion on a particular issue (example: should you be using jms or soap?), then you shouldn't be appearing for the exam.In my opinion (and i am not a exam guru), the exam is about two things - providing an architecture solution and defending it. If you have experience providing solution architectures you will know that there are multiple ways of getting anything done and more often than not there are no clear choices.Hence develop a solution,listen to others ideas but follow your own gut.There is a time to listen to opinions and there is a time to shut them out.

The assignment is slightly vague and somethings don't seem right/don't seem to add up.

On Javaranch, someone posted a reply from Sun Microsystems that the assignment is deliberately vague and i couldnt agree more. If choices were simple and Romeo could marry Juliet , everyone would be an architect. So, make assumptions(logical ones) around the aspects which you feel are vague, tell the examiner how the assumption has influenced your architecture and move on. Two different people can give two different assumptions and end with radically different architectures. All you have to ensure is that the assumption is logical and makes sense in context to the problem. For example, in an e-Commerce application you can't assume that there is no authentication/authorization module but you can assume that such a module is outside the scope of the solution you are presenting.There is a difference in both assumptions and i think it's important.

Which UML should i follow? - 1.x or 2.x

I followed a mix of both (Class and Sequence diagrams were 1.4 compliant while Component Diagram and Deployment diagram was 2.0 compliant) and i passed. I know people who have used 1.x and passed and i know people who used 2.x and passed.So, anything is fine as long as you are UML compliant. The assignment which i downloaded never mentioned anything about a version of the UML but just expected UML compliance.

Which tool should i use?
I used StarUML and Astah Community Edition.Both were free but depending on your operating platform and taste and willingness to spend - there are a bunch of UML tools out there which can be used. A tool does not make you pass/fail an exam,the solution does. Just make sure that you know your tool is UML compliant and the version to which it is compliant.

What technology stacks do i use to realize the solution?
This is an area where you will find a vast difference of opinion. Depending on the JEE version you use (1.4 or 5 or beyond), your technical choices will change. I know people who have used Struts/Spring and while in the real world i would probably nominate 'spring' as my defacto choice ,the examiners are paid by sun/oracle.I wouldnt go to the extent to say that a non JEE stack will offend them(the same has been said on JavaRanch) but i would recommend to play it safe..so stick to the standard JEE stack.

Some people say that they write a whole lot of stuff besides whats written in the exam?

This was one of my major issues while i was done with my assigment, people actually write reams of text ranging from architectural overview to a note on 'meeting the QoS requirements' although sun doesnt ask for it.I think writing a bit about your architecture makes sense but do understand that the questions in part 3 are related to defending your architecture and hence everything you are writing is probably redundant . However, i would recommend that you write about your contentious architecture decisions and a brief solution overview to allow the examiner to connect on your frequency.

Should i have one class diagram or multiple class diagrams?
Again, there are multiple opinions on this one. I submitted one class diagram but i know people who have split the class diagram. I think its ok that you split the class diagram but i would recommend that you split it by feature and not by layer. The latter would require the examiner to jump between multiple diagrams to understand one feature of your solution. Splitting them by features is rather logical.But if you can, try not to split it and let the class diagram by the looking glass into your whole solution.


What should be the level of detail in my sequence diagrams?
 Some people include method signature and some don't. I did include method signatures in my sequence diagrams. From an exam perspective, i would recommend that you stick to the 'Cade' style of showing JSP's,etc.

How do i know when i am ready and my solution is complete?
I would recommend what Cade does, get your solution peer reviewed.It helps


What do they ask in Part 3?
Part 3 is a 2 hour exam(minus the survey time) and all about defending your architecture. Search in JavaRanch and you will get plenty of hints.As an overview, some questions were about non functional requirements(how does your solution achieve them?) while others were explaining why certain alternatives weren't better.

My Advice for this part: Read all questions before you start answering them, as some questions are similar and you will need to choose which part of your explanation fits where.

My References(for part 2 and 3)

My Advice:
  1. As far as possible, keep it simple. When in doubt think , Occam's Razor
  2. This solution doesn't need you to think outside the box. If you think it is simple and routine, yes it is. Do not think outside the box because someone said so.
  3. Know basic UML . The UML standard is pretty intense and during my preparation i could never search to confirm if the UML i was using was valid. So, i stuck to what i know is valid. Martin Fowler is a good reference, keep it handy.
  4. Follow the  JavaRanch SCEA Forum.It helps to debate ideas to fine tune your own and it also helps to know that you aren't alone
  5. Think more about the business solution (and problem statement) and lesser about technology(as the tech stack is pretty defined in JEE).
  6. Document your assumptions and risks while you are developing the solution(and not at the end), this helps you capture details which you might miss at the end.
  7. Keep the assumptions sensible and ensure that they do not radically alter the intent of the problem statement in the assignment.
Some other blogs i liked (Obviously, i ain't the only one who likes to talk...)
I am sure there are many more blogs out there(maybe even better ones) but i liked them for their honest assessment of the exam.


Due to Oracle's exam policy i cannot talk about my Assignment or the specifics of my solution but i hope this post helps someone complete the exam successfully.
 
   




  

Sunday, October 11, 2009

SCEA Part 1 - An Affair To Remember.....

I took my SCEA 5 Part 1 exam today....about six months of 'on again off again' preparation finally culminating with a grand finale..of 64 questions appearing on the screen one after the other, as i clicked through...

Contrary to what i had heard from my friends at javaranch..the exam was not tough..but yes it was tricky...tricky not because the answers were close or confusing..but because the human brain tends to miss the obvious words masquerading between the lines of the question...

I owe a lot to my friends at Javaranch whom i have always trusted in the course of my preparations for sun certifications..straight from taking those first steps when I begin exploring about the course content to getting into heated debates about particular aspects of JEE development..it often becomes the hub of all activity..

I believe i owe it to my fellow ranchers and to all others who will prepare for SCEA 5 Part 1, a few tips to help through the exam..[did i mention i scored 92% :) ]... this is undoubtedly the toughest exam sun offers...and just when you are searching for something to make this exam easier...you find out that there is no study guide available for the recent version of the exam..most of the material is outdated...and someone recommends you going through a shelf of books ..but how do you know you have got it all handled? How do you know if you will pass the exam with the level of preparation you have...?

In this post, i will list some of the books i followed and why you should read them .(and no the authors aren't  paying me but i think they should :) ).

In this post i would also include DO's and DONT's - a must for the exam..

Let's begin with the books you absolutely MUST read -

  1. Design Patterns - Elements of Reusable Object Oriented Software (GoF) - You should read this book if you haven't..this is the holy grail which offers you so many insights which no other book does (and yes i am a big fan of Head First Series too)..but this book develops in you an insight which makes you look at OO Design differently..if you want to be a successful architect..this is the place you start..
  2. Head First Design Patterns - Read this one for kicks..its as good as it can get and makes for lucid reading..although if you are comfortable with GoF , feel free to give this one a skip..
  3. EJB3 in Action - The fastest you can learn about EJB's, no hoopla..and the writers mean business..from an exam perspective..look at the opening chapter..and look for chapters where they compare EJB to its ancestors..the point i making is that after this book..you should have a fairly good idea of what does EJB 3 offer  and when should it be used? How does it differ from its ancestors?
  4. Java Security (Scott Oaks) - A lot of people get stumped in security, so i seriously suggest that you check this one out.It's written with great style and makes for an easy read. Now, all the concepts might not be relevant for the exam but it gives you a great deal of confidence for the exam. I didn't make any mistakes in security and i owe it to this book.
  5. JEE tutorial - Read this one selectively based on your fluidity with the relevant JEE API.
  6. Core JEE Patterns(Better Explanation)
  7. Newer Edition of Core JEE Patterns
  8. Java Web Start : Refer the Sun Article here.More than enough to sail you though.
  9. Integration and Messaging - I liked the Paul Allen and Joseph Bambara guide on this aspect (Specially for JCA , since I couldn't find anything better yet brief on the subject). I also liked MZ's study guide on this subject.
  10. For all other objectives refer Mark Cade's study guide and MZ's study guide..they are more than enough
One question which i often read in forums about SCEA Part 1 is in regards to the detail of the exam - Should we know API's ? Does hands on experience in a technology help?

Yes, hands on experience does help you do the job as an architect but in my opinion it doesnt help much in the exam..in this age when technology comes a dime a dozen...its difficult to do everything..an Architect's job is to know the choices..and make the correct choice given the situation at hand...the exam tests you for just that...

I did not see a question pertaining to API level knowledge/method signatures...relax people..all you need to know is the capabilities of the technology and be in a position to recommend...(isnt that what you are supposed to do as an architect?)...

I absolutely hated Paul Allen and Joseph Bambara's study guide...its an incoherent book..which looks as a copy paste of material from various articles/books..there is absolutely no flow..of thought and its just a big bucket of random material..

I liked Mark Cade's study guide..precise and brief..thats how study guides for such an exam should be..

Mock Exams:
  I took ePractice and scored 87 and 80 in the tests.However, ePractice is way too easy , maybe the questions are not that easy but the answers are so obviously incorrect that the right one often stands out..know what i mean ?
I have heard similar remarks about Whizlabs so i guess you are on your own here..but do take a few mock tests..specially if you are one of those people who have a problem sitting at a place for more than 10 min(looking at the mirror here)..

Read a few reliable articles (IBM/Javaworld,etc) on Firewalls, DMZ, JAX WS and security concepts to increase your comfort level

Oh and drink lots and lots of water..when you prepare for the exam...it helps...(thank you kathy)...and when in doubt there's always Javaranch or you could join any other SCEA prep group to your liking..but do join one..it helps to know that you arent the only one slugging it out...

Cheers..
P.S > Any questions/suggestions/brickbats, just drop a comment..