In my previous post I showed the basics of a new analysis that I originally introduced in the JDT compiler as of 3.8 M3 and improved for M5. This post will give yet more insight into this analysis, which should help you in writing code that the compiler can understand.
An advantage of implementing leak analysis in the compiler lies in the synergy with the existing flow analysis. We can precisely report whether a resource allocation is definitely followed by a close() or if some execution paths exist, where the close() call is by-passed or an early exit is taken (return or due to an exception). This is pretty cool, because it shows exactly those corner cases in your implementation, that are so easy to miss otherwise.
However, this flow analysis is only precise if each resource is uniquely bound to one local variable. Think of declaring all resource variables as final. If that is possible, our analysis is excellent, if you have multiple assignments to the same variable, if assignments happen only on some path etc, then our analysis can only do a best-effort attempt at keeping track of your resources. As a worst case consider this:
Reader r = new FileReader(f); Reader r2 = null; while (goOn()) { if(hasMoreContent(r)) { readFrom(r); } else { r.close(); // close is nice, but which resource exactly is being closed?? } if (maybe()) { r2 = r; } // at this point: which resource is bound to r2?? if (hasMoreFiles()) { r = new FileReader(getFile()); // wow, we can allocate plenty of resources in a loop } } if (r2 != null) r2.close();
This code may even be safe, but there’s no way our analysis can keep track of how many resources have been allocated in the loop, and which of these resources will be closed. Which one is the resource flowing into r2 to be closed at the end? We don’t know. So if you want the compiler to help you, pretty please, avoid writing this kind of code
So what rules should you follow to get on terms with the compiler? To understand the mentioned limitation it helps to realize that our analysis is mostly connected to local variables, keeping some status bits for each of them. However, when analyzing variables the analysis has no notion of values, i.e., in the example the compiler can only see one variable r where at runtime an arbitrary number of Reader instances will be allocated, bound and dropped again.
Still, there are three special situations which the analysis can detect:
1 2 3 4 5 6 7 | Reader r = new FileReader("someFile"); r = new FileReader("otherFile"); r = new BufferedReader(r); Reader r2 = getReader(); if (r2 != null) { r2.close(); } |
r is first wrapped into a new BufferedReader and indirectly via that wrapper it is still reachable.r2 is either null or closed, so all is safe.You see the compiler understands actually a lot of the semantics.
My fundamental advice is:
Still not every method lacking a close() call signifies a resource leak. For an exact and definite analysis we would need one more piece of information: who owns any given resource?
Consider a group of methods happily passing around some resources among themselves. For them the same happens as for groups of people: diffusion of responsibility:
Well, no, I really thought that you were going to close this thing?!!?”.
If we had a notion of ownership we’d simple require the unique owner of each resource to eventually close that resource. However, such advanced concepts, while thoroughly explored in academia, are lacking from Java. To mitigate this problem, I made the following approximations of an ownership model:
In this list, green means: the compiler is encouraged to report anything fishy as a bug. Blue means, we still do the reporting, but weaken the message by saying “Potential resource leak”. Red means, the compiler is told to shut up because this code could only be checked by whole system analysis (which is not feasible for an incremental compiler).
The advice that follows from this is straight-forward:
In this regard, unclean code will actually cancel the leak analysis. If ownership of a resource is unclear, the compiler will just be quiet. So, do you think we should add a warning to signal whenever this happens? Notably, a warning when a resource is stored in a field?
Contrary to naive thinking, the art of good static analysis is not in reporting many issues. The art is in making yourself heard. If the compiler just rattles on with lots of uninteresting findings, no one will listen, no one will have the capacity to listen to all that.
A significant part of the work on resource leak analysis has gone into making the compiler quieter. And of course this is not just a matter of turning down the volume, but a matter of much smarter judgment of what the user might be interested in hearing.
By way of two recently resolved bugs (358903 and 368546) we managed to reduce the number of resource leak warnings reported against the sources of the Eclipse SDK from almost 100 down to 8. Calling this a great success may sound strange at first, but that it is.
At the level we reached now, I can confidently encourage everybody to enable this analysis (my recommendation: resource leaks = error, potential resource leaks = warning). The “Resource leak” problems indeed deserve a closer look, and also the potential ones could give valuable hints.
For each issue reported by the compiler you have three options:
@SuppressWarnings("resource") to tell the compiler that you know what you are doing.But remember the nature of responsibility: if you say you don’t want to here any criticism you’d better be really sure. If you say you take the responsibility the compiler will be the humble servant who quietly forgets all worries.
Finally, if you are in the lucky position to use Java 7 for your projects, do the final step: enable “Resource not managed with try-with-resource” analysis. This was actually the start of this long journey: to let the compiler give hints where this new syntax would help to make your code safer and to make better visible why it is safe - with respect to resource leaks.
Final note: one of the bugs mentioned above was only resolved today. So with M5 you will still see some avoidable false positives. The next build from now should be better
I’ll be back, soon, with more on our favorite exception: NPE.
Last night I dreamed seemingly all night about NetBeans 7.1, the JavaFX 2.1 Developer Preview, the JDK 6 and JDK 7 installations on my CentOS Linux system, Java threads, the JDK 7 Fork/Join framework, closures... and probably a few more things were in there too. That kind of thing happens to me sometimes after a late night of programming or development-related brainstorming.
Now, if these dreams happen when I have looming deadline, I usually consider it a nightmare -- because I'll often "work" all night "solving" some problem that doesn't exist in my day world. But I'm hoping last night's dreams will ultimately prove to have been at least a little bit productive. There were plenty of curious ideas mixed in there. I'll find out if any of it's useful over the next several days...
Day work: JavaFX 2.1 Developer Preview on Linux
It's daytime now, so I'll get down to some practical work. First, there's some good news for developers who want to try out JavaFX 2.1 Developer Preview on Linux: Linux Release Notes and installation instructions are now available (that wasn't the case when I wrote my Getting Started (Very Preliminarily)... blog post a couple weeks ago). Also, the 2.1 Developer Preview is has advanced to build b11 (I originally downloaded build b9).
The instructions for JavaFX 2.1 on Linux identify the following system requirements:
I'm running CentOS 5.5, not Ubuntu; my current JDK 6 is prior to update 26; and rpm -q gtk2 tells me that I have gtk2 Version 2.10.4-20.el5. Not the perfect starting point... But, my guess is that likely I'll be able to get a proper configuration in place.
The latest GTK2 that's available via yum for CentOS 5.5 is still in the Version 2.10 sequence. So, I downloaded the last stable GTK2 (Version 2.24.9), and tried installing it. The result of ./configure was a bunch of missing dependencies (too old a version of GLib, and missing atk, pango, cairo, and gdk-pixbuf-2.0). Using yum to see what prepackaged versions of these are available for my CentOS system, I found that in all cases the available packages predate the required versions.
Stepping back to GTK+ 2.18 would help some, but still the dependencies could not be met by simply using the yum package manager.
So, it's a dilemma. I'd like to try out the JavaFX 2.1 Developer Preview on my CentOS system, but there's a pretty big gulf between the CentOS 5.5 packages and what's required for JavaFX 2.1. Attempting big jumps in package versions can break a stable Linux system, in my experience. And the idea of upgrading to a newer operating system isn't all that appealing (that means downtime, and I do have development deadlines to meet). In addition, there are other things I'd like to be working on as well (such as experimenting with the performance differences between various strategies for efficiently utilizing multicore computers -- all that non-JavaFX stuff I was dreaming about last night).
I'll have to think about this for a while... Or, perhaps another night of Java-centric dreaming will provide a solution!
Since my last blog post, several people have posted new java.net blogs:
Our current java.net poll asks Under JCP 2.8, EC members lose their voting rights if they miss two consecutive meetings. Your view on this?. Voting will be open until Friday, February 17.
Our latest Java.net article is Michael Bar-Sinai's PanelMatic 101.
Here are the stories we've recently featured in our Java news section:
Our latest java.net Spotlight is Heather Van Cura's JCP 2.8 Spec Lead Materials & Adopt-a-JSR update:
Following the upgrade to the JCP 2.8 Program, the Program Office has made available the following materials for Spec Leads on the Multimedia page of jcp.org: -Transparency (December 2011 call) -JCP 2.8 Overview (October 2011 call)...
Previously, we featured Jasper Potts' Curve fitting and styling AreaChart:
I was experimenting today with extending AreaChart to do curve fitting for some example code I was hacking on. It is also a example of what can be done with styling JavaFX charts with CSS. Here is the result...
Subscriptions and Archives: You can subscribe to this blog using the java.net Editor's Blog Feed. You can also subscribe to the Java Today RSS feed and the java.net blogs feed. You can find historical archives of what has appeared the front page of java.net in the java.net home page archive.
-- Kevin Farnham
Twitter: @kevin_farnham
Note: if you're reading this using a feedreader, please make sure you've updated to the updated TheAquarium feed.
Recent Tips and News on Java, Java EE 6, GlassFish & more :
It’s my first out of two days at FOSDEM 2012. It took us quite a ride to get from the hotel to the ULB. We tried to order a taxi but the people at the reception told us that it would take at least 1.5 hours till a taxi arrives. Luckily, Mike and Andrew know someone who has been at FOSDEM a couple of times before. He guided us safely to ULB using a combination of walking, metro, tram and more walking.
We quickly setup an Eclipse stand over there and Mike, Andrew and myself are showing demos and talking to people. BTW, thanks to the FOSDEM organizer to have it well prepared so that we just needed to setup our banner and our notebooks for the demos.
So far we have a great mixture of questions from developers using Eclipse for their day-to-day work, programming questions of Eclipse plug-in developers and people interested in Orion. There are also people stepping by that have no questions – they introduce themselves as happy Eclipse users and appreciate what the committers of the various projects have built over time. Thanks for those kind words folks!
During the Juno cycle a lot of work in the JDT has gone into more sophisticated static analysis, and some more is still in the pipe-line. I truly hope that once Juno is shipped this will help all JDT users to find more bugs immediately while still typing. However, early feedback regarding these features shows that users are starting to expect miracles from the analysis
On the one hand seeing this is flattering, but on the other hand it makes me think we should perhaps explain what exactly the analysis can see and what is beyond its vision. If you take a few minutes learning about the concepts behind the analysis you’ll not only understand its limitations, but more importantly you will learn how to write code that’s better readable - in this case for reading by the compiler. Saying: with only slightly rephrasing your programs you can help the compiler to better understand what’s going on, to the effect that the compiler can answer with much more useful error and warning messages.
Since there’s a lot of analysis in this JDT compiler I will address just one topic per blog post. This post goes to improvements in the detection of resource leaks.
Right when everybody believed that Eclipse Indigo RC 4 was ready for the great release, another blocker bug was detected: a simple resource leak basically prevented Eclipse from launching on a typical Linux box if more than 1000 bundles are installed. Coincidentally, at the same time the JDT team was finishing up work on the new try-with-resources statement introduced in Java 7. So I was thinking: shouldn’t the compiler help users to migrate from notoriously brittle handling of resources to the new construct that was designed specifically to facilitate a safe style of working with resources?
So, how can the compiler know about resources? Following the try-with-resources concept, any instance of type java.lang.AutoCloseable is a resource. Simple, huh? In order to extend the analysis also to pre Java 7 code, we also consider java.io.Closeable (available since 1.5).
The expected life cycle of any resource is : allocate—use—close. Simple again.
From this we conclude the code pattern we have to look for: where does the code allocate a closeable and no call to close() is seen afterwards. Or perhaps a call is seen but not all execution paths will reach that call, etc.
With Juno M3 we released a first analysis that could now tell you things like:
Resource leak: “input” is never closed
Resource leak: “input” is never closed at this location (if a method exit happens before reaching close())
If the problem occurs only on some execution paths the warnings are softened (saying “potential leak” etc.).
Good, but…
It turned out that the analysis was causing significant noise. How come? The concepts are so clear and all code that wouldn’t exhibit the simple allocate—use—close life cycle should indeed by revised, shouldn’t it?
In fact we found several patterns, where these warnings were indeed useless.
We learned that not every subtype of Closeable really represents a resource that needs leak prevention. How many times have you invoked close() on a StringWriter, e.g.? Just have a look at its implementation and you’ll see why this isn’t worth the effort. Are there more classes in this category?
Indeed we found a total of 7 classes in java.io that purely operate on Java objects without allocating any resources from the operating system:
StringReaderStringWriterByteArrayInputStreamByteArrayOutputStreamCharArrayReaderCharArrayWriterStringBufferInputStreamFor none of these does it make sense to warn about missing close().
To account for these classes we simply added a white list: if a class is in the list suppress any warnings/errors. This white list consists of exactly those 7 classes listed above. Sub-classes of these classes are not considered.
Another group of classes implementing Closeable showed up, that are not strictly resources themselves. Think of BufferedInputStream! Does it need to be closed?
Well? What’s your answer? The correct answer is: it depends. A few examples:
1 2 3 4 5 6 7 8 | void wrappers(String content) throws IOException { Reader r1, r2, r3, r4; r1 = new BufferedReader(new FileReader("someFile")); r2 = new BufferedReader(new StringReader(content)); r3 = new FileReader("somefile"); r4 = new BufferedReader(r3); r3.close(); } |
How many leaks? With same added smartness the compiler will signal only one resource leak: on r1. All others are safe:
r2 is a wrapper for a resource-less closeable: no OS resources are ever allocated here.r3 is explicitly closedr4 is just a wrapper around r3 and since that is properly closed, r4 does not hold onto any OS resources at the end.r1, why is that a leak? It’s a wrapper, too, but now the underlying resource (a FileReader) is not directly closed so it’s the responsibility of the wrapper and can only be triggered by calling close() on the wrapper r1.EDIT: We are not recommending to close a wrapped resource directly as done with r3, closing the wrapper (r4) is definitely cleaner, and when wrapping a FileOutputStream with a BufferedOutputStream closing the former is actually wrong, because it may lose buffered content that hasn’t been flushed. However, the analysis is strictly focused on resource leaks and for analysing wrappers we narrow that notion to leaks of OS resources. For the given example, reporting a warning against r4 would be pure noise.
Summarizing: wrappers don’t directly hold an OS resource, but delegate to a next closeable. Depending on the nature and state of the nested closeable the wrapper may or may not be responsible for closing. In arbitrary chains of wrappers with a relevant resource at the bottom, closing any closeable in the chain (including the bottom) will suffice to release the single resource. If a wrapper chain is not properly closed the problem will be flagged against the outer-most wrapper, since calling close() at the wrapper will be delegated along all elements of the chain, which is the cleanest way of closing.
Also for wrappers the question arises: how does the compiler know? Again we set up a white list with all wrapper classes we found in the JRE: 20 classes in java.io, 12 in java.util.zip and 5 in other packages (the full lists are in TypeConstants.java, search for “_CLOSEABLES”).
Yes, a leak can be a stop-ship problem.
Starting with Juno M3 we have basic analysis of resource leaks; starting with Juno M5 the analysis uses the two white lists mentioned above: resource-less closeables and resource wrappers. In real code this significantly reduces the number of false positives, which means: for the remaining warnings the signal-to-noise ratio is significantly better.
M5 will actually bring more improvements in this analysis, but that will be subject of a next post.
by Roy Ganor (noreply@blogger.com) at February 04, 2012 06:55 AM
Wow! The Eclipse C/C++ IDE, including the Linux variant, has passed 750,000 downloads for Indigo SR-1, in only 4 months.
— Doug Schaefer (@dougschaefer) February 3, 2012
by Doug Schaefer (noreply@blogger.com) at February 03, 2012 06:29 PM
Maven Integration for Eclipse WTP 0.15.0, a.k.a m2eclipse-wtp, a.k.a m2e-wtp is available.
This release contains mostly bug fixes, but a few improvements managed to slip in. The complete release notes are available here.
m2e-wtp 0.15.0 is compatible with the JavaEE distributions of Eclipse Helios and Indigo, requires at least m2e 1.0 (works with 1.1) and mavenarchiver plugin >= 0.14.0 (0.15.0 should be automatically installed).
As usual, m2e-wtp can be installed from :
So let's see what are the highlights of this new release :
For war project, previous m2e-wtp versions used to use <packagingIncludes> and <packagingExcludes> attributes from the maven-war-plugin config to enable (or not) the deployment of project dependencies to WTP servers. In 0.15.0, the same level of support has been added to EAR projects using maven-ear-plugin 2.7+. However, the problem with this approach is, other resources (web pages, classes ...) are not properly excluded (using the <*SourceInclude> and <*SourceExclude> attributes).
In order to address this problem, Rob Stryker, committer on WTP and lead of JBoss AS tooling in JBoss Tools, provided an implementation for JBoss AS servers that might be generalized to other WTP server adapters (if they decide to do so). Basically, some new metadata is added to the project's .settings/org.eclipse.wst.common.component like :
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="webOrEar">
...
<property name="component.inclusion.patterns" value="pattern1,pattern2"/>
<property name="component.exclusion.patterns" value="pattern3,pattern4"/>
</wb-module>
</project-modules>
The patterns are separated with a comma and exclusions take precedence over inclusions : resources matching one of the exclusion patterns are not deployed, even if they match one of the inclusion patterns. That solution is not maven-bound so any other kind of project can benefit from it.
Now all m2e-wtp 0.15.0 does is map the maven patterns to their equivalent component metadata. This gives :
In the example above, a warning is displayed as both <warSourceIncludes> and <packagingIncludes> are defined. Since both patterns could overlap, it might lead to some weird behavior where WTP would actually deploy more files than a maven CLI build. In order to minimize (we can not totally solve) that potential discrepancy we only keep the packaging patterns in the component files and recommend using <packagingIncludes> only.
Currently, this feature only works in combination with the JBoss AS Tools from JBoss Tools 3.3.0.Beta1 (nightly builds available from http://download.jboss.org/jbosstools/updates/nightly/trunk/), but we'll try to make other WTP Server adapter vendors support it in the future (as part of WTP core API).
As of today, if a project depends on another workspace project of type ejb-client or test-jar, that specific dependency will not be packaged properly by WTP, as Maven would do in command line. Moreover, you'll experience some class leakage on the compilation and test classpaths in Eclipse (ex: non client classes being visible). The only known workarounds to this issue are to disable workspace resolution, or close the dependent project and rely on the dependencies from the local maven repository.
Ideally, in order to make the deployment part work, we would need to introduce new WTP components, but the current WTP API doesn't support it, yet. So, until this is fixed, warning markers are added whenever a project depends on such "unsupported" types. That should hopefully give users an idea of the problem and how to circumvent it.
Previous m2e-wtp versions had, in some use cases, some outstanding issues with regard to dependency management of war projects. In particular,
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<outputFileNameMapping>@{artifactId}@-@{version}@@{dashClassifier?}@.@{extension}@</outputFileNameMapping>
</configuration>
</plugin>
If you had a java utility project, that you wanted to upgrade to an EJB project for example, a constraint violation would be raised upon project configuration update (EJB and Utility facets can't be both installed).
This has been fixed by removing all conflicting facets when you change the packaging of a Java EE project, making that conversion completely transparent.
m2e 1.1 introduces a new Eclipse to Maven project conversion API. It means that, in m2e-wtp.next, we will be able to automatically convert existing WTP project configuration to maven's. Dependencies will still need to be set/translated manually but that's a pretty good start IMHO.
I would like to thank the m2e-wtp community at large for their support and contributions, that's what make this project move forward and make it one of the most popular projects on the eclipse marketplace.
Contributions can take the form of :
Keep it up.
Fred.
by Fred Bricon (do-not-reply@jboss.com) at February 03, 2012 06:01 PM
Two releases of the Eclipse EPP packages today:
The packages for Indigo SR2 RC2 (the second release candidate for the second service release of the Indigo release, based on Eclipse Platform 3.7.2) and the packages for this year’s Simultaneous Release Juno M5 (the 5th milestone based on Eclipse Platform 4.2) are available:
http://www.eclipse.org/downloads/index-developer.php
Please test and report any issues in Bugzilla. Especially the Eclipse 4.x team needs your help! The sooner bugs are found, the sooner they can be fixed!
One of the changes is the addition of Eclipse Code Recommenders to the Eclipse for RCP and RAP Developers package.
|
GlassFish 3.1.2 has never been so close to a GA/FCS release with promoted build b19 now available as Release Candidate (RC) 1. In fact you might as well go straight to RC2 (build 20), also now available from the promoted builds page. |
|
If you're not sure which archive to use, try this one. Another RC build (RC3) is planned in the next few days. Hopefully it'll be the last one before the product ships.
So make sure you test your applications work properly with the latest promoted build and check out recent blog posts on 3.1.2 if you're wondering what to expect from this release. See you in a short while for a stable public release!
Now you know what to do over the week-end! :)
|
Cumulogic is another PaaS provider offering Java as a platform and specifically GlassFish 3.1.1 as of their December 2011 release. |
|
CumuLogic PaaS has a dual public and private cloud strategy and support for Amazon EC2, OpenStack, Citrix-CloudStack, Eucalyptus, and VMware vSphere. It also offers RESTful APIs to manage the application lifecycle, and PaaS administration APIs to manage and monitor the platform.
For more details, you can read their data sheet, one where you'll learn that James Gosling is one of the company's advisors.
by Denis Roy (noreply@blogger.com) at February 02, 2012 09:39 PM
I am very pleased to announce the release of SwingX 1.6.3. While the release notes contain many fixes, I wanted to take a minute to highlight some of the major changes.
First and foremost, we have more fully adopted Maven. The project is now a collection of smaller modules. This will make it easier for clients to use only the pieces of SwingX that they need or want. To enable us to break SwingX into smaller modules, some classes have been moved or reorganized. Don't worry, we've left a deprecated copy in the original location in all instance but one (I'm looking at you JXBusyLabel.Direction).
Secondly for Maven, we needed to rename our groupId. Per discussions with the maven.java.net folks, we are now using org.swinglabs.swingx as the groupId. This is a change from org.swinglabs. Doing so allows us to use the maven.java.net facitilities for automatically updating Maven Central with our releases. Future releases should be a lot easier for us in that regard.
The third Maven-related change is that swingx-core no longer contains a copy or dependency on all SwingX classes. The swingx-graphics package is not used by any of our components. To suppliment the need to have an all-in-one jar, we have created the swingx-all module which provides all SwingX content as a single JAR file.
To highlight some non-Maven changes, we have:
If anyone is experiencing any issues with out latest release, please let us know over in the forums. Any feedback, especially about how we divided the code into modules, is always welcomed.
Thanks and enjoy!
Just a small reminder, the Eclipse Community Awards is currently open for voting. Please vote: http://eclipse.org/org/press-release/20120130_awardsvote.php
I’m also nominated, as Eclipse Top Newcomer Evangelist
Hi,
Ed and I are organizing the Modeling Symposium for EclipseCon North America (see here). Thank you for all the interesting submissions so far. To notify people early enough about the acceptance of their submission, we need to set a final deadline to February 8th. Please make sure to send me your submission before this deadline.
Looking forward to your submissions!
Jonas
by Blaise Doughan (noreply@blogger.com) at February 02, 2012 09:46 AM
A few months ago my colleague, Ralf Sternberg, wrote an article on “how to access a huge dataset with the web browser“. Now, if it’s possible to access very large datasets with a browser, wouldn’t it be really cool to access it in the same way with mobile devices?
As you may have heard, we launched RAP mobile two days ago. And, we did just that. With RAP mobile you can access exactly the same dataset with exactly the same code as in Ralf’s post. The dataset contains over 500,000 emails totaling over 2GB of space. Check out the screencast below and the source code on github.
What I find intriguing about this framework is that it is fast. There is no data on the phone. The information displayed in the UI is retrieved asynchronously from the server while the user is scrolling through this enormous set of data. The native iOS client takes care of the proper preloading, caching and memory management.
by DevX - Java (editorial@devx.com) at February 01, 2012 10:08 PM

|
@ColumnFamilyValue
public class Photo {
@KeyValue
private String name;
@ColumnValue
private File picture;
//getter and setter
}
|
|
public class PhotoDao {
private Persistence persistence;
public PhotoDao() {
persistence = EasyCassandraManager.getPersistence("exemplo", "localhost", 9160);
}
public void criar(Photo bean) {
persistence.insert(bean);
}
@SuppressWarnings("unchecked")
public List<Photo> listarTodos() {
return persistence.findAll(Photo.class,ConsistencyLevelCQL.ALL);
}
}
|
|
|
Table 3; Command for run

Reference:
Easy-Cassandra: https://github.com/otaviojava/Easy-Cassandra/
Example program with Eclipse and Netbeans: https://github.com/otaviojava/Easy-Cassandra/downloads
As part of Virgil's ability to deploy ruby scripts to a remote Hadoop cluster, we needed to package gems' into that Hadoop jar. After a bit of monkeying around, we got it.
This is the key piece of information:
"Because the operation of Java's classpath and Ruby's load path are so similar, especially under JRuby, they are unified in JRuby 1.1. This results in a number of unified capabilities:...
First thing you need is to actually get your hands on the gem. To do this, you can run jruby to grab the gem.
java -jar jruby-complete-1.6.0.jar -S gem install -i rest-client rest-client --no-rdoc --no-ri
This will fetch the gems and install them into the current directory under the directory "rest-client". In that subdirectory you'll find: bin, cache, doc, gems and specifications. The actual code for the gems is found in the gems directory. In the case of rest-client, you'll find two directories that contain the code: mime-types-1.17.2 and rest-client-1.6.7.
This is what you need to bundle into the jar. We copied those two directories into our java project under src/main/resources/gems/.
One approach would be to simply include those directories on your classpath. Another approach is to programmatically adjust the loadpath to include those directories. You can do this with the following lines:
List paths = new ArrayList();
paths.add("gems/rest-client-1.6.7/lib/");
paths.add("gems/mime-types-1.17.2/lib/");
this.rubyContainer = new ScriptingContainer(LocalContextScope.CONCURRENT); this.rubyContainer.setLoadPaths(paths);
Then, when using this.rubyContainer you'll be able to run ruby files that require the rest-client.
Since the ruby scripts are actually loaded via the classpath (from the loadpath), jruby is happy loading them from within a jar. In our case, we built the jar using maven and the gems were included in the jar because we put them under src/main/resources/gems.
|
Arun has a blog reminding folks about the Java EE 6 samples that ship with the SDK. The list of code samples is pretty long and a good complement to the Java EE 6 Tutorial. |
|
Note you can also access these samples from any GlassFish install (not just from the SDK) by adding the missing repository using :
% <install-dir>/bin/pkg set-authority -O http://pkg.sun.com/javaeesdk/6/release/ JavaEE6SDK
% <install-dir>/bin/pkg list -a | grep samples
javaee-samples-build (JavaEE6SDK) 1.0-4 known ----
javaee-samples-full (JavaEE6SDK) 1.0-4 known ----
javaee-samples-web (JavaEE6SDK) 1.0-4 known ----
Firefox 10 was released yesterday, and the release announcement highlighted developer tools such as the Orion-based Scratchpad as key features in the release. At the same time, Firefox 11 moved into their Beta channel. The Mozilla developer tools team released a cool video last week showing upcoming features in Firefox 11, such as a 3D Page Inspector, and a new Orion-based Style Editor. Scratchpad and Style Editor are the result of many months of close collaboration between the Mozilla dev tools team and the Orion Editor team. Congrats to Mihai, Kevin, and the rest of the Firefox team on another great release!
|
As we constantly improve the java.net infrastructure you might experience some downtime on Wed, Feb 1, 2012 @ 6-8pm PT. Hopefully, this one should only really be a short one. |
|
by Jens v.P. (noreply@blogger.com) at February 01, 2012 11:29 AM
|
With this new "Glassfish – Vertical clustering with multiple domains" blog by Alexandru, there seems to be no shortage of GlassFish configuration posts. Surely, that must say something about the popularity of GlassFish for highly-available apps. |
|
While it uses mod_jk like most others, this one is multi-domain, uses JMS topics and spends some time looking at different JVM settings and their impact on response time and GC activity.
|
The Java EE 7 expert group has been defining transactional interceptors and there are a few issues it came across for which your developer feedback would be useful. |
|
Bill Shannon has described the issues of :
• how to handle exceptions that are thrown out of a
transactional method and
• how the new JTA transactional interceptor should interact with EJBs.
... and offers possible solutions.
If you care about these, please take a little bit of time to read through the above descriptions before you provide feedback. The best place for feedback would be the mailing list (subscription required first) but we'll also consider comments posted to this entry.
This coming weekend is FOSDEM in Brussels, Belgium. It will be my first FOSDEM and I’m really looking forward to it. Lots of my fellow Red Hat, JBoss, and Fedora colleagues will be there, too (list of talks by Red Hatters as a PDF and as HTML). Eclipse content this year includes:
“FOSDEM is the biggest free and non-commercial event organized by and for the community.” There’s no registration required, so if you’re in the area, swing by! There are a lot of people that I’m looking forward to seeing and having a beer with this weekend but I’m especially looking forward to seeing the ever-awesome Alex Kurtakov again and to meeting my new teammate Krzysztof Daniel in person for the first time.
Safe travels and see you in Brussels!
Update: Gregoire de Hemptinne pointed out his talk on an EMF-based declaritive UI system, Wazaabi.
A little bit later than scheduled here’s the next release. This time the number of new features is smaller than in previous releases but there still some small nice additions. Let’s look into it.
The new release comes with Eclipse 4.2M5. I also looked into up-dating the subclipse integration but at the moment the newest version is only provided for win32/64 and so I’m waiting until I can consume it from upstream. All other components (xtext, egit and mercurial) are unchanged.
As promised since the beginning. At the very moment the JavaFX 2.0 team provides builds for Linux e(fx)clipse will provide all in one downloads (one was able to install from the p2-site since the beginning). The JavaFX 2.0 Linux build provided is for 32bit and so is the e(fx)clipse all in one version you can download.
The linux support though is still a bit limited – the live preview (JavaFX-SWT-Integration) crashed my Eclipse instance.
I’ve added support for CSS 3 selectors as the screenshot below shows:

I’ve added support for the newly introduced LCD Text support which is done in CSS using “-fx-font-smoothing-type”
It’s not really easy to follow which CSS-Attributes are added and sometimes the docs are not correct so if you encounter an attribute you definately know is working but the CSS-Editor marks it as an error file me a ticket.
I’ve added 2 things when it comes to colors inside the CSS-Editor. You can use a color picker instead of entering the rgb-value manually:


Thanks to Sebastian Zarnekow’s blog this was a piece of cake.
And for already existing colors the hover will display it:

Elements who mark one for their properties as the @DefaultProperty are now respected and you can omit the attribute-name for them making your the file more readable in many situations – whether you make use of this feature is up to you.
The syntax has been expanded to allow referencing of script values:

In this release it only received bugfixes. If you want to help with it file bugs, send me patches, … .
I’ve started working on SVG and FXG to FXML-Converters as I already outline in one my last posts my plan was to add them to e(fx)clipse to allow you converting those external formats to JavaFX 2.0 representations. You should not expect a lot for it as of now because they are in a very very early stage and as outlined in the above post JavaFX 2.0/2.1 (at least for SVG which I looked a bit closer) won’t provide enough API to implement a fully compliant convert as of now.
The main purpose to add them already today into e(fx)clipse is to receive feedback from you on problems you encounter. I hope you share the source SVG and FXG drawings with me or even provide a patch?
An interesting sidenote on this is that technically I’m transforming the source formats into an EMF-Model (there’s a specific one for SVG and one for FXG) and then do the conversion using xtend (a Eclipse and Java-Developer should get started with xtend within 30 minutes because the tooling feels so similar to your JDT-Editor).
Just one final sentence on FXG: Adobe if this is really the spec of a format I’m happy I never had work with your stuff – take a look at SVG-Spec on how I expect someone to define a (graphic) format.
I’ve been receiving more and more mails to my private account and I’m always grateful to help but to not only put the burden on me I decided to open a google-group where people can ask questions, others can help too, … . I’ll try to update the fxgraph-reference as well but you know I’m doing this in my spare time and so things take time.
If e.g. you mastered the first steps in fxgraph and want to share your findings, don’t hesitate to send a message to above group. I’ll plan to add an extra page to http://efxclipse.org so that people have a central place to find informations. I’m happy for reviews in blogs (even if there are things you don’t like about e(fx)clipse I want to know them).
You can find the new group at: http://groups.google.com/group/efxclipse. Come, join and bring up ideas to make e(fx)clipse a success.
It has been another blockbuster milestone for the Orion project. This milestone brings extensive tooling improvements, including global search and replace, content assist for HTML, template completion for JavaScript, and CSS outline and error checking. The user interface has also had a major facelift with an eye toward giving more pixels to the most important content, and optimizing for mobile devices and touch displays. There is also a brand new user settings page, and a completely redesigned Git user interface. As always, you can give it a spin on OrionHub (sign up), or download your own copy. Read on below for more details.
You can now replace matches across multiple files from the Search Results page. After performing a search, click Replace to open a slideout where the replacement text is entered. After entering the text, click Preview Changes to open a preview of all the matches to be replaced. From this page you can check or uncheck individual files or matches, and use next/previous diff buttons in the compare editor to cycle through your changes. Finally, click Commit to perform the replace.

You can now navigate through search results using the Up and Down arrow keys on your keyboard. Push Right arrow to open a popup showing additional lines surrounding the search result, and Left arrow to close the popup.

There have been several improvements to the Find File dialog, accessed via Ctrl+Shift+R in the editor or by pressing ‘t’ on other pages:
JavaScript content assist in Orion now provides templates for common control structures. Simply invoke content assist with Ctrl+Space, and select from among the available templates that match your current cursor position. Templates have been added for:
Some templates require you to fill in certain variables such as conditions or other values. Use Tab to iterate through the fields to be completed, and Enter to finish the template.

JavaScript content assist will now propose matching local variables and function arguments from all enclosing functions in the current script.

Content assist has been added for HTML files. Invoking content assist in an empty file will produce a basic well-formed HTML 5 document. Completion is offered for all elements supported in HTML 5. Closing element tags are inserted where appropriate.

For lists and tables, completion will also insert the first list item or table row for you:

Orion CSS Lint integration, previously available as a separate plugin, is now included by default in the set of plug-ins distributed with Orion. In addition, this plug-in now provides an outline view for CSS files.

A new Settings page has been introduced. The JavaScript Editor tab allows customization of fonts and colors in the JavaScript editor. Note that changes take effect immediately across all editors you currently have open in the current browser.

The Plugins tab shows the set of installed plugins, and supports adding and removing plugins. This page will evolve to show further details about each plugin as well.
A new command has been added to the Navigator page, allowing you to quickly navigate up to the parent of the current folder. Simply click Go Up, or use Alt+Up on your keyboard.

Orion can now report progress on multiple background operations at once, and even report progress on operations occurring in other frames and pages. This sounds simple, but anyone who has tried to do this on the web will realize how amazing this is. Click the progress button in the top right corner of the page to drop down a list of current and recent operations. From this list you can also visit a separate page showing a longer operation history.
A new Related Pages menu has been added to the page header. This allows you to quickly navigate between multiple pages that deal with the same file or folder you are currently viewing. For example, from the editor page you can now quickly jump to the Git Log page showing commits involving that file.

The header at the top of each Orion page has been overhauled and cleaned up. Highlights include:
For more information on the Orion UI design philosophy and direction, see the Orion Page Layout wiki page.
Orion styling has been tweaked to work much better on mobile devices. When using a display of 1024 pixels or less, we now pad the checkbox and twistie icons with more hittable breathing room.It is now much easier to check/uncheck boxes and invoke commands on a small touch screen. In addition, an editor problem with automatic uppercasing introduced with a recent iOS update has been addressed. The Orion editor now functions well again on iPad.

Orion now uses URI templates to invoke commands on an Orion page using a URI. These commands are limited to altering the page layout such as opening input fields and dialogs. For example, you can now create a URL to initiate a clone operation on a particular repository. To see this in action, click Fork me on OrionHub to clone the Orion client code in your OrionHub account. Note you still need to manually click “Submit” after visiting the URL before the clone operation actually starts.

A completely new Git Repositories page has been introduced in this milestone. This replaces the previous deep tree structure with a flatter, more web-like presentation. Most basic commands are available at a glance without having to drill down, making the page much easier to use on touch and mobile devices. The Working Directory section shows at a glance what changes you have made that require staging or committing. The Commits sections shows all incoming commits that require merging, and all outgoing commits that have not been pushed to the current branch’s remote repository. There are further sections listing all branches, tags, and remotes for the current repository.

A new Git Commit page has been introduced to accompany the new repositories page. Simply click on any commit from either the Repositories or Git Log page to open the commit details page. From here you can see all information about the commit, including author/committer, link to parent commit, associated tags, and diffs of all files modified by the commit. You can also tag or cherry-picka commit from this page.

You can now save unstaged changes as a patch to be reapplied later. From the Git Status page, simply select the files to be saved, and click Save Patch.

Saved patches can be applied later, or by another user, by clicking Apply Patch on the Git Repositories page. A patch can be applied either from an uploaded file, or from a URL (such as a bugzilla attachment).

Git tags can now be removed. From the Git Repositories page, find the tag you want to remove and click Delete. Tag deletions can be pushed to a remote repository using the Push All command on the same page.

You can now associate an email address with your Orion account from your Profile page. Once the address is confirmed, it can be used to automatically reset your Orion password if you forget it in the future.

We have upgraded the neolithic Jetty version we previously shipped with the Orion Server. We are now running and delivering the most recent Jetty 8.1 from eclipse.org.
Enjoy!
This email came into our site feedback alias this morning, and I thought this would be a great topic to ask the community. I'm a big believer in using the right tool for the job, even if it's not Java at the moment. I asked his permission to post it here, so please meet Mike:
To whom it may concern,
I need your advice. Back in 2000 I was a post-doctor at the University of Caledonia in Berkeley. While there, I became ill with a type of brain cancer called a medulloblastoma, and was forced out of research.
After release from the hospital, I started programming rehabilitation games similar to the ones used in brain injury rehabilitation. I decided to do this because these types of games, although a medical tool, are quite expensive. I wanted to produce my own version of these games that were free. The results of my efforts can be seen at http://www.msty-neurotraining.com and are registered at the Brain Injury Association of America (http://www.biausa.org/) as a rehabilitation tool.
However, I have a serious problem. These programs were made using Microsoft’s Visual Basic 6, and the programs made with it will soon become obsolete and no longer run modern versions of Windows computers. Therefore, I am looking for an alternative. Preferably one which is open source (like Java) to keep in spirit that the games are a free medical tool. Do you have any suggestions as to what open source programming language would be appropriate for my needs? I need something that can produce programs capable to manipulate 2D graphics, save and retrieve files and use a joystick. I am not restricted to using a programming similar to Visual Basic; I can also program in C++ (the programming language we predominantly used at Berkeley).
Would Java be a good alternative to Microsoft’s Visual Basic? If not, what other programming tool would you advise using?
Also, how do I go about starting an Open Source project to create a rehabilitation tool like the one the I created with VB6? Starting such a project would be preferable to working alone, because I feel that a team working together always gets better results than an individual working alone.
Sincerely,
Michael Tarsitano (PhD)
Bruchsal, Germany
Today is my last day working for PetalsLink.

Working for PetalsLink was a quite interesting experience:
On the technical side, I enjoyed moving all the XML-based tooling of PetalsStudio to a more powerful EMF-based approach for Petals JBI editor – for those who don’t know JBI, it is a standard that allows to define SOA artifacts in your ESB. Moving to EMF allowed us to provide better tooling faster, because most of the complexity in manipulating JBI can be removed with very few efforts leveraging EMF ExtendedMetaData. That was the first time I faced this part of EMF, and I got pretty impressed of how well it works (working with EMF always gives this impression of “being well”). I also improved the ability to plug new JBI components into the Studio, which is a critical point when you have to deal with connectors for almost everything – Mail, SFTP, Talend, XSLT…. So that was an interesting challenge in term of conception and development.
Petals Studio was also the pretext to start using Git, GitHub and Sonar. I am pretty happy to have learnt these 3 tools that clearly improved the way I work.
Also, I had the great opportunity to work closely to several Eclipse projects:
The only thing I wish I would be able to do here is to push ahead the usage of Sonar at Eclipse, at least for GMF Tooling and Nebula.
But I probably learnt even more things from PetalsLink by discovering another company organisation that is very different from what I could experiment before (OpenWide and BonitaSoft): PetalsLink is focused on the Research about SOA and agility of Systems of Information. It is a wide topic! Petals products are quite good compared to other alternatives in the SOA landscape, but they don’t meet the success they deserve, it was a bit frustrating for a developer.
I enjoyed working for PetalsLink, all the expectations are fulfilled, so it is time for me to go ahead, to find a new experience, a new team, new challenges, new issues… I love discovering new things!
That’s why I’ll start working for JBoss|Red Hat tomorrow, as part of the team developing JBoss Tools and JBoss Developer Studio.
I’ll have the opportunity to work with a great team! My main occupation for the next monthes will be to assist Nick Boldt in making JBoss Tools CI and build infrastructure better and better. I’d also like to open the road towards efficient QA for JBoss Tools, including -among other- usage of Jacoco and Sonar. Then I’ll also work on developing nice stuff for some JBoss Tools modules, most probably on the SOA/BPM part.
That’s gonna be a lot of fun! I’m eager to be tomorrow and actually get started for this new team/employer/project/product/users.
Let’s keep in touch via this blog and twitter
ftp-bku.sh ~/bin ~/docs ~/etc ~/utils
FTPURL=ftp://User@192.168.1.24:2121
FTPBASEDIR=MyDir
TIMESTAMP=$(date +"%d%m%y-%H%M%S")
BACKUPDIR=backup_`hostname`_$TIMESTAMP
# Perform the actual FTP backup
function backup {
PNAME="$1"
DNAME="$2"
ftp -i -V $FTPURL<<EOF
bin
cd "$FTPBASEDIR"
mkdir "$BACKUPDIR"
cd "$BACKUPDIR"
lcd "$PNAME"
mkdir "$DNAME"
cd "$DNAME"
mput *
quit
EOF
if [ "$?" == "0" ]; then
echo Backup succeeded: "$BACKUPDIR"
else
echo Backup failed: "$BACKUPDIR"
fi
}
# Backup the directory specified as $2 recursively where the base directory is $1
# So to backup /Users/david/etc/tmp as etc/tmp you pass in
# /Users/david/etc/tmp etc/tmp
function backup-dir {
cd "$1"
if [ -d "$2" ]; then
BASE="$1"
DIR="$2"
BASELEN="${#BASE}"
SUBDIR="${DIR:BASELEN}"
TARGET="`basename "$1"`$SUBDIR"
backup "$2" "$TARGET"
fi
cd "$2"
for dir in *
do
if [ -d "$2/$dir" ]; then
backup-dir "$1" "$2/$dir"
fi
done
}
# Staring point, backup all directories specified on the command line
for directory in "$@"
do
backup-dir "$directory" "$directory"
done
by davidb (noreply@blogger.com) at January 31, 2012 11:59 AM
Those who cannot remember the past are condemned to repeat it (George Santayana). I've always felt ambivalent about that quote. History never ever repeats itself exactly. In computer science on the other hand, it applies very well. In all our collective software applications, we recalculate the same results time and time again and are therefore faced with constant question to remember or not to remember. In this blog series, I'm going to talk about a cache for Xtext resources that we've developed over the past year.
OpenChrom breaks the 500 download mark today! It’s the first time that OpenChrom has been downloaded more than 500 times in a month since its start in April 2010. Jippie!
by Doug Schaefer (noreply@blogger.com) at January 31, 2012 07:03 AM
|
DaliCore is a new project announced by Johan Vos on java.net to offer users and social networks on top of Java EE. It is the open-sourcing of LodgON's technology developed for the past few years and used in a number of social websites. |
|
You can think of this as twitter, Facebook, or social network-enabling your applications using Content, User, Group, and Authorization APIs. DaliCore is a logical extension to the the Java Enterprise specification (specifically to Java EE 6).
As with any Java.net project, you can start playing with the source code, engage on mailing lists, file bugs, but also get further details in this short presentation.
Good luck to Johan and team on this project!