Tag: Eclipse
Tweets for 2010-01 and 2010-02
by Frank Kim on Feb.28, 2010, under Miscellaneous
Ruby on Rails
- Numeric data types and zerofill. Explains what all those int(11) columns are in your Ruby on Rails tables. http://bit.ly/9Tcf7q #
- undefined local variable or method "acts_as_list"? – Ruby Forum. Do ruby script/plugin install acts_as_list http://bit.ly/9kFWbG #
- ruby on rails : adding child records to an existing parent without visiting the parent – Stack Overflow http://bit.ly/cQiGSP #
- Multi-Table Inheritance in Rails – When two tables are one… This is not easy and I wish it was. http://bit.ly/9fbzgk #
- has_many :through – count vs length vs size. Use count if u don’t want to load the contents of association into memory. http://bit.ly/dtqXe1 #
- A gentle reminder about pluralizations. config/initializers/inflections.rb to customize pluralizations in Ruby on Rails http://bit.ly/bN9GO5 #
- Ruby on Rails – Rails Migrations Cheatsheet – Dizzy. Pretty helpful. http://bit.ly/9wNvRx #
- RailsGuides Migrations. Nice guide, especially about explaining the naming convention which I don’t like. http://bit.ly/cjZ7aB #
ATG
- Configuring ATG to Send Email via Comcast SMTP – betweenGo. Configuring your ATG app to use your ISP’s SMTP server. http://bit.ly/7M5bhx #
- Enabling non-XA Resources in JBoss 4.2 with ATG – betweenGo. http://bit.ly/aDN3Po #
- Combining XML in ATG – betweenGo. Combining XML files not as straight-forward as w/ properties files but more flexible. http://bit.ly/8kVwvA Jan 12 12:00 PM
Eclipse
- Debugging Applications in IBM Rational Application Developer. Page 12 for how to set up server for debugging. http://bit.ly/aaYUHb #
JavaScript
- How can I submit a form along with some parameters using JavaScript? (JSF forum at JavaRanch). Answer #3 was helpful. http://bit.ly/b17ymm #
JSP
- Testing Which Page Loaded your JSP Page Fragment – betweenGo. Simple enough to do w/ JSTL but I always forget how.
http://bit.ly/cEh7IZ #
Miscellaneous
- Cygwin 1.7.x, mounts and /etc/fstab – betweenGo. Mounts are no longer saved from session to session in Cygwin 1.7. http://bit.ly/bmaYEu #
- Git in 5 Minutes http://bit.ly/bSt3dd and Git for the lazy – Spheriki http://bit.ly/aefD17 #
- The Thing About Git. Nice article describing how flexible Git is, especially compared to SVN. I may never use SVN again http://bit.ly/bD0tuS #
- I use DreamHost and am shamelessly plugging them both for a referral and to try to win an iPad. Honestly they’re great. http://bit.ly/ctYv3Z #
How to Debug an InvalidVersionException from Updating an ATG Order
by Frank Kim on Aug.17, 2009, under Commerce
If you ever update an order outside of a transaction then the next time you update it within a transaction you will get the infamous, dreaded InvalidVersionException.
WARN atg.commerce.order.ShoppingCartModifier atg.commerce.order.InvalidVersionException: This order (o3830002) is out of date. Changes have been made to the order and the operation should be resubmitted. Order version 333, Repository item version 334. at atg.commerce.order.OrderManager.updateOrder(OrderManager.java:2557)
For example this could happen if you update your order in your JSP page.
<dsp:setvalue bean=”order.foo” value=”bar” />
To fix this problem you must always make sure to update an order within a transaction like this.
Transaction tr = null;
try {
tr = ensureTransaction();
synchronized (getOrder()) {
getOrder().setFoo("bar");
try {
getOrderManager().updateOrder(order);
}
catch (Exception exc) {
processException(exc, MSG_ERROR_UPDATE_ORDER, pRequest, pResponse);
}
}
}
finally {
if (tr != null) commitTransaction(tr);
}
In some cases you might find a method is called within a transaction by another method and in other cases it is not.
public boolean handleFoo(DynamoHttpServletRequest req, DynamoHttpServletResponse res) {
Transaction tr = null;
try {
tr = ensureTransaction();
synchronized (getOrder()) {
setFoo("bar");
try {
getOrderManager().updateOrder(order);
}
catch (Exception exc) {
processException(exc, MSG_ERROR_UPDATE_ORDER, pRequest, pResponse);
}
}
return checkFormRedirect(getSuccessUrl(), getErrorUrl(), req, res);
}
finally {
if (tr != null) commitTransaction(tr);
}
}
public void setFoo(String foo) {
getOrder().setFoo(foo);
}
In the above example the handleFoo method properly updates the order within the transaction. However calling the setFoo method directly will cause a problem since the order is not updated within a transaction. To fix this you use the same pattern again to ensure the order is updated within a transaction. It is okay to do this more than once during a request.
To debug this problem you can use Eclipse to make sure that wherever you update an order is always within a transaction. You can use the debugger to find which methods are called and/or you can use the call hierarchy to find out how methods are called.
Another way to help debug this is adding JSP code similar to the one I list below. It outputs the version of the order that the form handler has and the version that is in the repository. If there is a difference then you know that the action you took before at some point updated the order outside of a transaction.
<dspel:getvalueof bean="ShoppingCartModifier.order.id" var="orderId" />
FORM HANDLER ORDER ID: ${orderId}<br/>
FORM HANDLER ORDER VERSION: <dsp:valueof bean="ShoppingCartModifier.order.version" /><br/>
<dsp:droplet name="/atg/dynamo/droplet/RQLQueryForEach">
<dsp:param name="queryRQL" value="ID IN { \"${orderId}\" }"/>
<dsp:param name="repository" value="/atg/commerce/order/OrderRepository"/>
<dsp:param name="itemDescriptor" value="order"/>
<dsp:oparam name="output">
REPOSITORY ORDER VERSION: <dsp:valueof param="element.version"/><br/>
</dsp:oparam>
</dsp:droplet>
For further reading please see Nabble – ATG Dynamo – Commerce Assist Returns and the Transaction Management section in the ATG Programming Guide.
Spaces, not Tabs
by Frank Kim on Aug.01, 2008, under Eclipse
The holy war about spaces or tabs continues and you can see all sorts of arguments for each side raging around the internet.
I prefer spaces because it’s a consistent format that remains the same no matter what you are using. With tabs things appear differently depending on how your editor or other program is configured. Plus the worst thing is when spaces and tabs get intermixed.
Arguments for tabs such as they take up less room or it’s easier to move around are in my mind weak. In this day of terabyte disk drive, file size differences between tabs and spaces are trivial and most of your disk space is taken up by images and binary files anyway. And being able to move around and format quickly is not an issue either with modern editors.
The two editors I use most are XEmacs and Eclipse. Below I describe how to use spaces for indents for each program.
In Emacs:
(setq-default indent-tabs-mode nil) ; Use spaces for indents except
; in buffers that already have
; their own local values for the
; variable.
In Eclipse:

Eclipse Ganymede
by Frank Kim on Jul.18, 2008, under Eclipse
I was about to write a post about how much I was starting to dislike Eclipse. Two years ago I was singing the praises of Eclipse but Eclipse Europa (version 3.3) in my opinion has been a disaster. It is incredibly slow, crashes often, runs out of memory, etc. I found myself at times using XEmacs instead because it was faster.
But today I installed Eclipse Ganymede (version 3.4) and so far life has been much better. It is much more responsive, it is not crashing, things are running smoothly. You can read about what is New and Noteworthy in Ganymede. The most exciting new feature to me is the Retain case of match when replacing, just like XEmacs.
Also I noticed that in my JBoss project, hot swapping of code is again working. I am not sure if this is because I upgraded to Ganymede or because I turned on “Build Automatically”. I suspect it might be the latter.
Maven Integration for Eclipse
by Frank Kim on Jul.18, 2008, under Eclipse, Maven
Previously I was using an old Maven integration for Eclipse, version 0.0.11, which I got from http://m2eclipse.codehaus.org/update. The plugin was horribly slow and seemed to sometimes interfere with my builds.
Today I upgraded to the latest, version 0.9.4, from http://m2eclipse.sonatype.org/update/ and things are moving much more smoothly. You can learn more at Maven Integration for Eclipse.
In Windows > Preferences > Maven I only turned on Download Artifact Sources and Download Artifiact JavaDoc. Download repository index updates on startup is on by default but I turned it off after receiving this advice from a fellow developer, Bill Crook.
It’s unclear to me how the m2 plugin uses the indexes so I don’t think I can answer you.
Enabling it causes the plugin to rescan the entire repository if i remember correctly. I personally am not willing to have Eclipse do a full file scan of the local repository each time i start for unknown reasons. if you don’t mind the incurred overhead, go ahead and enable it!
The Maven plugin has a nice dependency feature which Bill Crook explains well.
There will come a time when you need to work on two projects simultaneously. Additionally, there will probably be a dependency from one project to another. The key to doing this effectively is understanding workspace resolution. Workspace resolution is a concept of the m2eclipse plugin. The way this works is that the plugin scans all projects in your workspace and analyzes the poms. Based on group and artifact ID’s the plugin will know if there are interdependencies between your projects. Once the plugin has successfully detected the dependency between projects, you can jump from one project source into another when jumping into methods (via control-click or F3).
There is one important caveat to this, versions. In addition to looking at group and artifact ID’s, the m2eclipse plugin will look at versions to determine if the project for a dependency is in the current workspace. Because of this you must make sure the versions match. Let’s take the example of projects A and B in your workspace. Assume A has a dependency on version 2.0.0.1 of B. Now, if the version of project B in your workspace is 3.0-SNAPSHOT, workspace resolution will NOT work. Can you figure out how to make this work? If you guessed, update the pom of project A to depend on 3.0-SNAPSHOT, you are correct. The moral of the story is be aware of versions when trying to get workspace resolution working.
You will know that workspace resolution is not functioning properly if you see duplicates of the same class when doing searches with control-shift-t. This behavior makes sense when you think about it as Eclipse sees two of these classes in your workspace. For example, continuing with projects A and B as above, let’s assume there is a class Foo in project B. Eclipse would find class Foo in project B source (as java source in your workspace) as well as in version 2.0.0.1 of B (as a class file in jar dependency).
Now if someone would improve the Perforce plugin…
Eclipse memory settings
by Frank Kim on Jun.13, 2008, under Eclipse
Recently I have been having problems with Eclipse running out of memory.
Previously I had as my command line argument for Eclipse.
eclipse.exe -vmargs --Xmx512m
The double dashes were a problem, preventing Eclipse to properly load the correct memory settings from eclipse.ini.
I then removed the -vmargs –Xmx512m from the command line argument and instead modified eclipse.ini which is in the top level of the Eclipse installation. This blog article, Eclipse and memory settings, explains how you should put each argument on a separate line and that you can go to Help > About Eclipse Platform and then click on the Configuration Details button to check that Eclipse is running with the correct settings.
I changed this:
-Xms40m -Xmx512m
to:
-Xms120m -Xmx1024m
but I reverted back when I realized it was my original command line argument that was the problem.
I tried to use these settings as recommended in this forum, [news.eclipse.tools.jdt] Re: How to prevent out of memory errors?
-Xms120m -Xmx1024m -XX:PermSize=256M -XX:MaxPermSize=512M
But for some reason that kept crashing the Eclipse startup.
Maven Assembly Convert Shell Scripts to use UNIX LF’s
by Frank Kim on May.09, 2008, under Cygwin, Eclipse, Maven, Perforce
In a previous post, Shell Scripts with Windows LF’s Fail in Latest Cygwin, I wrote about how to use Perforce to check out all files in UNIX format. However if you use Eclipse then this solution will not work because Eclipse always inserts Windows LF’s in any line you insert into a file leading to a mess with files that have both UNIX and Windows LF’s.
However if you happen to use Maven to generate / copy your shell scripts to their target directories you can take advantage of the lineEnding property in the Assembly Director. If you specify the lineEnding property to be “unix” then the outputted shell scripts will be in UNIX format. For example:
<file> <source>src/main/scripts/foo.sh</source> <outputDirectory>bin</outputDirectory> <lineEnding>unix</lineEnding> </file>
Eclipse does not understand MAVEN2_CLASSPATH_CONTAINER
by Frank Kim on Apr.22, 2008, under Eclipse, Maven
Eclipse was complaining in its Java Build Path panel that it did not know what MAVEN2_CLASSPATH_CONTAINER was. Searching around I realized that it was because I had not installed the Maven plugin.
After installing and restarting I went to Project > Update All Maven Dependencies to pull down all the dependencies.
Eclipse won’t start after Windows shutdown
by Frank Kim on Apr.13, 2007, under Eclipse, Perforce
My laptop unexpectedly shutdown when I had Eclipse open. After rebooting I could not start Eclipse. Instead it kept crashing with the message “An error has occurred. See the log file …” Looking at the log file I saw errors related to the Perforce plugin.
java.lang.NoClassDefFoundError
at org.eclipse.ui.internal.themes.ThemeElementHelper.installFont(ThemeElementHelper.java:101)org.osgi.framework.BundleException: Exception in org.eclipse.core.internal.compatibility.PluginActivator.start() of bundle com.perforce.team.ui.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1010)
Caused by: java.lang.ExceptionInInitializerError
at com.perforce.team.ui.PerforceUIPlugin.initializeDefaultPreferences(PerforceUIPlugin.java:284)
I saw a post about this problem which referred to another post for a solution. Basically the post suggests that stale plugin cache information is causing the problem and suggests starting Eclipse with the -clean argument. After doing this I was successfully able to launch Eclipse.
Eclipse Serial Version UID Bug
by Frank Kim on Aug.22, 2006, under Eclipse
Currently there is a bug with Eclipse and generating the serial version UID. When attempting to generate a serial version UID you will see a dialogue window which says “Computing serial version ID….” and “Starting virtual machine…”. Unfortunately this hangs and you are forced to kill your Eclipse IDE. I started seeing this bug after installing some JDBC plugins and the GEF plugin, I’m not sure if it’s related to that. I tried disabling the plugins but I still see the problem. Before I wasn’t having this problem.
I noticed that I haven’t encountered this problem on other installations of Eclipse, even w/ the JDBC plugins, so could just be that I have a bad build of Eclipse.
