Bech on Enterprise Java
Thursday, February 23, 2006
  Problems with Jakarta Axis 1.3 in Oracle 10g (10.1.0.2)
Since I found the solution to this problem on a japanese site (jajakarta), and no trace of it elsewhere I better blog it. I can now only hope that google and all other search engines will index this page, and display it when someone enters the keywords "oracle.xml.parser.v2.XMLDOMException Axis"

When you atempt to deploy a web service on the Oracle 10g platorm (10.1.0.2), using Axis 1.3 straight out of the box, you run into problems with the Oracle XML parser.

I'm not sure exactly what causes this, but I've tracked it down to the class org.apache.axis.utils.XMLUtils It seems this class is not able to initialize fully with the Oracle provided XML libraries.

The result of this problem, is that if anyone try to auto generate a WSDL file by appending ?wsdl to a service

example : http://localhost/services/sampleservice?wsdl )

Axis will provide the following output

Fault - ; nested exception is: oracle.xml.parser.v2.XMLDOMException: Implementation does not support the object requested.

The soultion to this problem is to specify command line arguments to the java VM running the server during startup like this ;


-Djavax.xml.parsers.SAXParserFactory=
org.apache.crimson.jaxp.SAXParserFactoryImpl
-Djavax.xml.parsers.DocumentBuilderFactory=
org.apache.crimson.jax.DocumentBuilderFactoryImpl


As you can see, we here decide to use the crimson parser instead of the one provided in the Oracle XML library. We could also have included Xerces in our application and sepcified the parser provided there ofcourse.
 
Monday, February 20, 2006
  The top 10 Things i Love the most about IntelliJ IDEA (5.1)
Just like a carpenter needs a good saw and hammer, having a good IDE is paramount to being a productive developer. I recently upgraded from IDEA 4.5 to 5.1 and would like to tell you all how much I enjoy working with my new tool.

This is the top 10 features I use most, and that has the greatest impact on my workflow. The focus here is fast code editing, and does not take into consideration major other features like App server integration, code analysis etc.

Please feel free to comment on this entry with other nifty workflow tips !

- “Rename” (Shift+F6) with this key combo I can refactor the name of methods and members when I am about to use them. You usually discover that the name of a method is bad when you’re about to use it. Being able to rename it, without going to the declaration saves a lot of time. Bad names are a thing of the past.

- "Recent files" (Ctrl + E) this key combo displays a list of the last edited files. I Usually want to go back to one of the last three files I worked on.

- "Quick find class or file" (Ctrl-N and Ctrl-Shift-N). This feature really speeds up my workflow. Instead of using the tree-navigator to find a class, I can press ctrl+n, type in the name of a class. Matches are displayed as I type. This also works for other files using the ctrl+shift+n. In conjunction with the "recent files” I end up not using the mouse. In fact, when doing only coding with my laptop, I sometimes don't connect the mouse at all.

- “Delegate” (Ctrl+insert) this neat feature lets you expose the interface of a contained class. If you've been using the decorator design pattern/wrapper you understand the value of this neat feature.

- “Subversion Integration”. I was waiting for this. Setting up subversion was a pain in 4.5 involving copying of binaries to your windows directory. In 5.1 Subversion integration is integrated, and works very well. You can even use the IDEA file compare when you have subversion conflicts.

- Ctrl + mouse click. If I’m inside a configuration file (Struts-config.xml for example) and need to quickly go to the Action class specified in an action mapping. Hold the Ctrl key in, and the text representing the class name becomes clickable.

- "Reformat code" (Ctrl + Alt + L) I’m currently write code for a client not using the same coding standard I’m used to. Setting up intelliJ to meet their standard was very painless. I find myself pressing this key combo on reflex now.

- "Optimize imports" (Ctrl + Alt + O). Quickly removes redundant and unused class files form my imports.

- "Source health indicator" The Red/Green/Yellow light indicating the state of my code. Seeing the green light, I instantly know the file compiles.

- "Source problem tags" The Red/Green/Yellow bars indicating problems in my code. If I am editing at the bottom of my source file and my source indicator is yellow, I look for see some yellow bars at the “top” of my code, this usually means that some imports are now redundant and I press. Ctrl-Alt-O, and… Voila! The yellow bars disappear and the light is back to green.
 
Thursday, February 16, 2006
  Intellij IDEA: Additional javadoc tags for xdoclet(Hibernate and ejbdoclet tasks)
I recently had the need to collect all tags used by xdoclet for the hibernate, and ejbdoclet tasks so that I could import them into the "unknown javadoc tags" of intelliJ. Since a precompiled comma separated list was hard to find for ejbdoclet, I share them just in case someone should find it useful.

Ejbdoclet tags

ejb.activation-config-property,ejb.bean,ejb.dao,ejb.data-object,
ejb.destination-ref,ejb.ejb-external-ref,ejb.ejb-ref,ejb.ejb-service-ref,
ejb.env-entry,ejb.facade,ejb.finder,ejb.home,ejb.interface,ejb.message-destination,ejb.permission,ejb.persistence,ejb.pk,ejb.remote-facade,
ejb.resource-env-ref,ejb.resource-ref,ejb.security-identity,
ejb.security-role-ref,ejb.security-roles,ejb.transaction,ejb.util,ejb.value-object,dao.call,ejb.aggregate,ejb.create-method,ejb.ejb-external-ref,
ejb.ejb-ref,ejb.ejb-service-ref,ejb.env-entry,ejb.facade-method,ejb.home-method,ejb.interface-method,ejb.permission,ejb.persistence,
ejb.persistent-field,ejb.pk-field,ejb.relation,ejb.resource-env-ref,
ejb.resource-ref,ejb.select,ejb.transaction,ejb.value-object,
ejb.ejb-external-ref,ejb.ejb-ref,ejb.ejb-service-ref,ejb.env-entry,
ejb.resource-env-ref,ejb.resource-ref

Hibernate tags

hibernate.cache,hibernate.class,hibernate.discriminator,
hibernate.jcs-cache,hibernate.joined-subclass,hibernate.joined-subclass-key,hibernate.mapping,hibernate.query,hibernate.subclass,
hibernate.any,
hibernate.any-column,hibernate.array,hibernate.bag,hibernate.collection-cache,hibernate.collection-composite-element,hibernate.collection-element,hibernate.collection-index,hibernate.collection-jcs-cache,
hibernate.collection-key,hibernate.collection-key-column,
hibernate.collection-many-to-many,hibernate.collection-one-to-many,hibernate.column,hibernate.component,hibernate.generator-param,hibernate.id,hibernate.index-many-to-many,hibernate.list,
hibernate.many-to-any,hibernate.many-to-any-column,hibernate.many-to-one,hibernate.map,hibernate.one-to-one,hibernate.parent,hibernate.primitive-array,hibernate.property,hibernate.set,
hibernate.timestamp,hibernate.version

Arne Berner provided me with these ones for Weblogic as well(http://aberner.blogspot.com/ )

(Moved from comments to main blog entry)


weblogic.allow-concurrent-calls,weblogic.allow-remove-during-transaction,weblogic.automatic-key-generation,weblogic.cache,weblogic.cache-ref,weblogic.clients-on-same-server,weblogic.clustering,weblogic.create-as-principal-name,weblogic.data-source-name,weblogic.delay-database-insert-until,weblogic.dispatch-policy,weblogic.ejb-local-reference-description,weblogic.ejb-reference-description,weblogic.enable-batch-operations,weblogic.enable-bean-class-redeploy,weblogic.enable-call-by-reference,weblogic.enable-dynamic-queries,weblogic.iiop-security-descriptor,weblogic.instance-lock-order,weblogic.invalidation-target,weblogic.lifecycle,weblogic.lock-order,weblogic.message-driven,weblogic.order-database-operations,weblogic.passivate-as-principal-name,weblogic.persistence,weblogic.pool,weblogic.pool-name,weblogic.remove-as-principal-name,weblogic.resource-description,weblogic.resource-env-description,weblogic.run-as-identity-principal,weblogic.run-as-principal-name,weblogic.transaction-descriptor,weblogic.transaction-isolation,weblogic.use-select-for-update,weblogic.verify-rows
 
Wednesday, February 01, 2006
  Spring vs. J2EE? Does Spring really suck ? - Let Google decide !!
When faced with a tough business-, architectural- or design decision, why listen to Gartner, Jupiter or any so called analysis company? The solution is as always free, and readily available.

When choosing a middleware or framework, it is crucial that there is a critical mass of users out there, finding & fixing bugs, blogging, producing tutorials etc. This is especially important with open source!

So! One could easily argue that the maturity and quality of a product can be related to the number of people that are currently building software with it. (aka People are not stupid!) One could also easily assume that the more people that are involved with a product, the larger internet footprint as more web pages are produced!

So, let's think. Who is currently number #1 at measuring this? Google is at least a good candidate. I'm therefore introducing a new measuring unit called IGP (Indexed Google pages)

Publicity and published pages and number of pages is not always positive. So let's add another factor to the equation, and introduce yet another TBF called NGP or Negative-Indexed Google pages. The NPG is a measure of how many indexed pages Google has, with the product name in the proximity of a negative word.

First, i tried one of there more obscene curse words I know, with let's say "Interesting results". I ended up using "headache" instead since it produces less explicit results, and bad frameworks often gives us developers a lot of headaches.

Now... Let's put this methodology through the test. Let us put J2EE and the Spring framework Head-to-head!

Since "Spring" is a fairly general word, I am bold enough to state that pages related to the spring framework should contain both the word "Spring" and "Java". I believe this is a reasonable assumption.

Words and Technologies IGP NGP Ratio
J2EE + (headache) 24,900,000 58,400 0,0024
Spring Java + (headache) 9,740,000 208 000 0,021


Looking closer at the table, we can easily conclude that the J2EE framework is far more mature and holds a level of quality (A factor of 10!) superior to the Spring framework! J2EE has both a higher IGP and lower NGP ratio than Spring. I guess CrazyBob was right after all!

Feel free to use this methodology to put other technologies head to head, and please blog the results!
 
  Struts 1.2 & Velocity Tools; ActionMessagesTool and ErrorsTool confusion
This is probably obvious to most experienced front end programmers. But since I spent 30 minutes digging in apache code, and 15 minutes fixing a misunderstanding in my code, I'll blogg my embarrassment.

Let's say you have a struts action with the following catch clause. Notice that we use the ActionMessages class instead of the ActionErrors class to contain error messages. The use of ActionErrors and ActionError is one of the things that have changed from Struts version 1.1 and 1.2 (See also previous blog entry)

catch (SomebusinessException e) {
ActionMessages errors = new ActionMessages();
errors.add("name", new ActionMessage("error.general.name_already_in_use"));
saveErrors(request, errors);
return mapping.findForward("input_error");
}

This might lead you to think that you should use the ActionMessages Tool in Velocity. This is (of course) not the case since we still use the "saveErrors" method in our Action subclass. So, when rendering the error message you (still) have to include the ErrorsTool in your toolbox.xml

<tool>

<key>errors</key>
<scope>request</scope>
<class>
   org.apache.velocity.tools.struts.ErrorsTool
</class>
</tool>

The ActionMessagesTool should NOT be used. ErrorsTool and ActionMessagesTool, and both are actually just very thin wrappers to the StrutsUtils class. The ActionMessagesTool class uses a method in StrutsUtils called getMessages() that does the following ;

ActionMessages errors =
(ActionMessages)request.getAttribute(Globals.MESSAGE_KEY);

The ErrorsTool uses a method in the StrutsUtils class called getErrors() that does the following ;

ActionMessages errors =
(ActionMessages)request.getAttribute(Globals.ERRORS_KEY);

So using the wrong Velocity tool (ActionMessagesTool) gives you an empty collection of messages when you have invoked the saveErrors method in your Action class. Beware!
 
I hereby promise to blog my thoguhts and views on Enterprise java, design patterns, frameworks and all other things that make life as a software developer interesting.

Name:
Location: Oslo, Oslo, Norway

www.glennbech.com

ARCHIVES
May 2005 / June 2005 / July 2005 / January 2006 / February 2006 / June 2006 / July 2006 / August 2006 / October 2006 / November 2006 / March 2007 /


Powered by Blogger