Tuesday, September 24, 2013

JavaOne 2013 - Starting Off Strong

The past two days have been packed with great sessions, and I believe that this year's JavaOne is going very well so far.  After my initial visit to the Schedule Builder, I knew this conference was going to be good.  I found it nearly impossible to choose which sessions to add to my schedule, and which ones to pass up.  There are so many good sessions to choose from, that I am hard pressed to find a time slot that does not contain at least one session that peaks my interest.  

Each of the sessions that I have attended thus far have been packed with excellent information.  It is clear that JDK 8 is a very hot topic this year.  With many sessions covering new features, such as lambda and Nashorn, JDK 8 is everywhere.  Java EE 7 is also a hot topic at this year's conference.  Sessions covering features such as JSF 2.2, JAX-RS 2.0, JMS 2.0, WebSockets, and more...the benefits of using Java EE 7 are clearly being advertised.  Perhaps some of the most widely discussed buzz around EE 7 is the HTML 5 integration.  It is also nice to see some great PrimeFaces coverage at this year's JavaOne.

NetBeans is also getting a lot of coverage this year.  I have attended sessions covering EE 7 tips and tricks with NetBeans, Project Easel, and several sessions on Java EE that demonstrated how powerful the NetBeans and GlassFish combination can be.  I enjoyed the demos of NetBeans and Project Easel being used to develop apps that scale nicely on mobile devices...complete with live debugging on an iOS device.

JavaFX is looking excellent, and the FX team is doing a great job of showing off it's power.  There are many sessions on JavaFX 8, and some great coverage of FX on Raspberry Pi.  HTML5, CSS, MultiTouch...there are countless sessions demonstrating the use of JavaFX with various technologies.

Overall, the most important part of the conference is the community.  The community is stronger than ever this year.  I've met up with so many great faces in Java over the past couple of days.  The Taylor Street cafe is a great place to meet up, and the GlassFish party at the Thirsty Bear was excellent...thanks to the GlassFish team!  The Exhibition Hall and OTN Lounge are always packed...lots of great demos and discussions.

I have the next three days packed solid of excellent Java content...looking forward to many more great sessions!  Java and the community are strong, and it is a great time to be a Java developer.

Keep up with the latest by visiting OTN at oracle.com/technetwork/java


Friday, June 07, 2013

Java EE 7 Books: Java EE 7 Recipes & Introducing Java EE 7

I have been working hard for over a year now on my most recent publication entitled 'Java EE 7 Recipes: A Problem-Solution Approach', published by Apress (May 2013).  This book covers the Java EE stack from the ground-up, and it includes coverage of EE 7 specific features, such as JSF view actions, WebSocket API, and Concurrency Utilities for Java EE.  Therefore, I feel that the book will be a good read for beginner, intermediate, and advanced Java Enterprise developers.

The first chapter begins by walking readers through recipes regarding the setup of a Java Enterprise environment, including specifics on how to install and configure Glassfish v4, a fully Java EE 7 compliant application server.  It then quickly delves into the development of Java Servlets, including coverage of newer concepts such as registering servlets without WEB-XML, and non-blocking I/O.  

Chapter 2 covers JSP from the ground-up.  Although JSP is no longer the preferred option for enterprise application development, it is still a very viable and widely used technology.  Therefore, this chapter will be handy especially for beginner and intermediate level developers so that they can have a better understanding of how JSP technology works, and where it may be the most useful.

Next, the book delves into JavaServer Faces technology, with in-depth coverage that spans four chapters (Chapter 3 - Chapter 6).  Keeping with the theme of the book, readers will learn how to develop applications with JSF, including useful tips and techniques, as well as integration with third-party libraries such as PrimeFaces.  The JSF 2.2 release (which is new with the release of EE 7), includes useful features such as the ability to invoke managed bean actions on life-cycle phase events (viewActions), and better integration with HTML5.  This book will show seasoned JSF developers how to use these new features so that they can begin integrating them into new and existing applications.

No enterprise application would be complete without database access, and Chapters 7 and 8 provide coverage for JDBC and Object-Relational Mapping via the Java Persistence API (JPA).  Chapter 7 provides coverage for utilization of JDBC technology for database access.  The chapter covers everything from obtaining a connection, to handing errors, simplifying connection management, performing CRUD operations, and execution of database stored procedures.  For those developers more interested in utilizing server-side database connection pools, etc., Chapter 8 covers the Java Persistence API.  The chapter contains vital information for working with underlying data stores via JPA including data mapping and entity creation.  It also hits upon EE 7 specific updates, including schema generation support.

Chapter 9 covers EJB technology, along with its new features via the release of EJB 3.2.  Readers will learn how to utilize EntityManagers, differences between Stateless and Stateful Session beans, how to utilize EJB via JSF, and more.  The new features covered include asynchronous message-driven beans (MDB), explicit designation of remote and local interfaces, and opting out of stateful session bean passivation.  In Chapter 10, readers will learn how to query entities using the most up-to-date features in JPQL.   

If you want to work with Java EE 7, you will most likely utilize GlassFish 4 application server since it is the first EE 7 compliant server.  Chapter 11 includes content on how to get up-and running with GlassFish v4, utilizing the administration console for application and datasource management, and setting up authentication.

One of the most popular features of Java EE beginning with the release of EE 6 has been Contexts and Dependency Injection.  Chapter 12 covers CDI in full detail, including recipes on injection, using CDI beans via JSF views, and more.  It also covers new features such as the injection of bean metadata and the new @Veto annotation for marking classes as ignored by CDI.

Have you heard about the simplification of Java Message Service (JMS) in the new 2.0 release?  Readers will learn all about the new simplified JMS API in Chapter 13, along with other JMS basics such as creation of resources, creating/sending messages, and the new message delivery delay.

Chapter 14 is a bit of an extension on Chapter 11, as it covers authentication and security for Java Enterprise applications, specifically those deployed within a GlassFish container.  Almost every enterprise application requires a login form, and this chapter covers how to create one, and also how to utilize LDAP authentication for producing single-sign on solutions.

SOAP and RESTful web services have become significant technologies for the Java EE stack.  Chapter 15 covers web services, both SOAP and REST-based services using JAX-WS and JAX-RS.  Readers will learn how to create each type of web service, and utilize the new features of JAX-RS 2.0 such as the new client API.

Java is not the only language on the block any longer (or JVM, that is).  It is not uncommon to see different languages being utilized to create entire enterprise applications for the JVM, or even for integration with existing Java EE applications.  Chapter 16 includes a few short recipes showing how one may integrate Groovy or Jython into an EE application.

Since HTML5 and the new era of web applications is upon us, the new WebSockets and JSON-P APIs for EE 7 have become of major importance.  Chapter 17 covers these new APIs, demonstrating how to create and utilize WebSockets for full-duplex communication.  The chapter includes an example calling out to a WebSocket from JavaScript.  It also demonstrates how to utilize the new JSON-P API for creating and parsing JSON.

Chapter 18 covers the use of JavaFX for creation of enterprise applications.  It demonstrates how to develop JavaFX front-end applications, and bind them to EJBs for use with data.  There is also a recipe covering the use of JavaFX with RESTful web services.

Finally, both the Concurrency Utilities for Java EE and Batch Applications APIs have been added to EE 7.  These APIs provide a standard for developing concurrent and batch applications for the enterprise. Coverage includes the creation of server-side resources (ManagedExecutorService, etc.) for concurrent application development, and creation of item-oriented batch processes.

Overall, the Java EE 7 Recipes book is perfect for those that are interested in getting up-to-speed with Java EE, including the latest features.  For those who are already experts with Java EE and are only interested in the new features, stay tuned for the release of my upcoming book entitled 'Introducing Java EE 7', to be published by Apress within the next few weeks.


Saturday, November 03, 2012

Java EE 7 by JSR

The following is a listing of JSRs that are contained in the Java EE 7 Specification.

Java EE Platform Specification - http://java.net/projects/javaee-spec/pages/Home 

JSR 107 - JCache https://github.com/jsr107/jsr107spec http://jcp.org/en/jsr/detail?id=107
JSR 236 - Community Utilities for EE http://jcp.org/en/jsr/detail?id=236
JSR 338 - JPA 2.1 http://jcp.org/en/jsr/detail?id=338
JSR 339 - JAX-RS 2.0 http://jcp.org/en/jsr/detail?id=339
JSR 340 - Servlet 3.1 http://jcp.org//en/jsr/detail?id=340
JSR 341 - EL http://jcp.org/en/jsr/detail?id=341
JSR 342 - EE 7 http://jcp.org/en/jsr/detail?id=342
JSR 343 - JMS http://jcp.org/en/jsr/detail?id=343
JSR 344 - JSF 2.2 http://www.jcp.org/en/jsr/detail?id=344
JSR 345 - EJB 3.2 http://jcp.org/en/jsr/detail?id=345
JSR 346 - CDI 1.1 http://jcp.org/aboutJava/communityprocess/pr/jsr346/index.html
JSR 349 - Bean Validation http://jcp.org/en/jsr/detail?id=349
JSR 352 - Batch Applications for the Java Platform http://jcp.org/en/jsr/detail?id=352
JSR 353 - Java API for JSON Processing http://jcp.org/en/jsr/detail?id=353
JSR 365 - WebSockets

Thursday, December 29, 2011

Java 7 Recipes: A Problem-Solution Approach

This is a quick post to mention a new book that will be published soon entitled Java 7 Recipes. I had the pleasure of leading a team of excellent authors: Carl Dea, Mark Beaty, Freddy Guime, and John O' Conner in the authoring of this book. It features a problem-solution approach demonstrating how to get up and running quickly with the Java language. The book features some of the most common questions for newbies starting to develop with Java, and provides answers in an easy-to-learn and reuse manner. It also features some of the most common intermediate and advanced problems and solutions, as well as material that is new to the Java 7 release.

Carl Dea wrote several chapters on JavaFX 2.0, and the material covers enough information to get started with JavaFX 2.0 and then delves into some advanced examples as well. If you are looking to learn the latest in Java desktop and rich internet client development, you will want to check out the chapters on JavaFX 2.0.

Mark Beaty wrote a chapter covering data structures and iteration. He is an expert in object oriented Java concepts, and this chapter covers some of the most fundamental parts of the Java language. Mark also was a technical reviewer for the book, and he did an excellent job of working through the material and solidifying it. I would also like to give a shout out to David Coffin who also performed technical review on several of the chapters...great work!

Freddy Guime is a Java expert who wrote chapters on input/output, exceptions, concurrency, unit testing, and more. Freddy has presented at JavaOne several times and his material exploits his knowledge of the Java language.

John O' Conner has been an avid Java developer for years, and is seasoned in the language. He began his career with Sun Microsystems and helped to develop the internationalization and Unicode support libraries of the core Java SE platform. He authored chapters on those topics for the book, and more.

I authored chapters varying from Strings, object orientation, numbers and dates, database development, and more. We even threw in a chapter on Android so that interested Java developers could take a look at how to develop applications for the Android platform.

Check this book out soon, or pre-order now on Amazon the Apress site. This is a must-have for any Java developer!

I am currently working on my latest Apress book entitled Java EE 7 Recipes...it should be published late next year...stay tuned for more updates on that book!

Friday, March 04, 2011

Django-Jython 1.3.0 Final Available

The Django-Jython project is proud to announce the release of Django-Jython 1.3.0 Final!

This release adds Django 1.3.x compatibility for the Oracle, MySQL, MS SQL, and PostgreSQL backends. Please test with your Django-Jython apps and provide feedback.

Project Home: http://code.google.com/p/django-jython/
Documentation: http://packages.python.org/django-jython/

Thanks to all of those who helped out with this release, your time and effort is truly appreciated!

Support for Django 1.4 is coming soon...

Thursday, March 03, 2011

Jython 2.5.2 Final Released

The Jython development team is proud to announce the release of Jython 2.5.2 final! With this release comes new features, better performance, bug fixes, etc.

For the latest release info, please visit: http://jython.org/latest.html

Thanks to all of the developers for the hard work they put into this release. Looking forward to moving onto 2.6!

Tuesday, December 21, 2010

Oracle PL/SQL Recipes

Since the beginning of my career, I have worked with Oracle databases. I began as a database administrator, monitoring performance and creating database objects. From there, I became a more advanced DBA as I began writing PL/SQL code and creating triggers, functions, packages, and procedures in the database. After a while, I became interested in web application development because I was always receiving requests for creating database reports. Why write a SQL statement and re-run it every time someone wanted to see the output, when you could write a web query that accepted parameters as input and the user could run it on their own? That is the point when I discovered how to do web application development with PL/SQL and the Oracle PL/SQL web toolkit. My good friend and colleague, Matt Arena, showed me the ropes about developing PL/SQL web applications, and it was great! Now I was able to develop web-based queries whenever I had received a request for a report.

After a while, I began to write Java stored procedures because I was developing some sophisticated PL/SQL web applications by that time and I wanted to use some features that the Java language had to offer. Of course, this all worked very well...but I soon gained interest in developing Java Server Pages (JSP) based web Java web applications because they seemed a bit more versatile then PL/SQL web applications. I learned that I could more clearly separate business logic from display code using Java technologies, and began to learn more about it. Before long, I was a full-fledged Java application developer. I was developing Java enterprise applications for Oracle database, and using PL/SQL objects to help facilitate my applications where it made sense.

That brings me to where I am today. I still develop web applications for Oracle database using Java technologies and PL/SQL. I have broadened my horizons by using great languages such as Jython. Life couldn't be much better. This past year, I decided to author a book about PL/SQL that focuses on the basics...but also goes into advanced topics such as working with PL/SQL and Java to develop advanced solutions. I brought my highly respected coworker, Matt Arena, into the book as my co-author. Matt is the most advanced PL/SQL developer that I know, and he wrote the chapters that focus on PL/SQL web application development, collections, PL/SQL jobs, and performance. He taught me, and now he is sharing his great knowledge by teaching others. I authored many chapters that focus on the PL/SQL language fundamentals, and also some advanced chapters working with PL/SQL and Java application development.

Our book is entitled, Oracle PL/SQL Recipes - A Problem-Solution Approach. I recommend you picking it up if you are an Oracle applications developer. Learning PL/SQL is a great asset to any Oracle developer's toolbox. Even if you only work with Java applications, PL/SQL can help you to develop better-performing, and highly robust Oracle solutions. A big thanks goes to Apress and the entire editorial team, including my good friend Jonathan Gennick, who has done an excellent job editing this book. I look forward to working with him again on future projects. I also thank my colleague and great friend Matt Arena for showing me the ropes with PL/SQL web application development...leading my to where I am today in my career.

Oracle PL/SQL Recipes - A Problem-Solution Approach...publishing late December 2010.

Tuesday, October 12, 2010

JavaOne and Oracle Develop 2010 - A New Experience

I took my first trip to JavaOne this year. There were many deciding factors that made me choose to make the trip this year, but perhaps the biggest reason that I attended was due to the Oracle acquisition of Sun Microsystems that took place earlier this year. I wanted to see what Oracle's viewpoint was on the Java ecosystem, and what they planned to do with it over the next several years. I must say that I was pleasantly surprised with the message that I received at the conference, I think Java is alive and very well.

I attended several sessions each day, and the conference made for a very hectic week. I had never visited San Francisco before and I must say that I found it very similar to Chicago. Being a Chicago area person myself, I found nothing overly different about San Francisco as compared to Chicago, but then again, I did not take any opportunities to go sight seeing as I was completely focused on the conference itself.

Having never been to a JavaOne conference before, i think that it was fairly well organized. Now, JavaOne was spread across a few different hotels and one large tent...and in the past I believe that it was centered in the Moscone convention center. I thought that the hotel system worked, but it did make for some rather busy shuffles from session to session. I did like the fact that I had the opportunity to go outside in between sessions though, and since the Mason St. tent was in the center of it all, I could swing by the tent on the way to another session and pick up a coffee or chat with some interesting folk. This really enhanced the experience for me.

The sessions were well thought out and worthwhile. Of course, being a Jython fan I went to as many sessions that were centered on dynamic languages on the JVM as possible. Jim Baker and myself had put in for a Jython-specific talk at this year's JavaOne and unfortunately it was turned down. Our talk was going to focus on the overall picture of bringing dynamic languages to the JVM...and Jython was going to be the example-case. I wasn't too surprised when our session was turned down as there are thousands of submissions, but when I attended the conference it was clear to see why it was turned down...there were several excellent sessions regarding dynamic languages on the JVM already. To be quite truthful, the dynamic language sessions at JavaOne covered several different languages...and I feel that the most used languages on the JVM today were nicely represented. It would have been very nice to have a session devoted to Jython specifically, but the fact is that there are so many dynamic languages on the JVM nowadays, that there was just not enough room for a session on each.

To that end, I attended an excellent JRuby session as my first JavaOne session...it really started my experience off in a great way. The presentation was given by Charles Nutter and Thomas Enebo...a couple of JRuby architects. This was a solid session that really made me want to go and download JRuby afterwards and try it out. Having not tried JRuby prior to the session, I was really focusing more on seeing another dynamic language on the JVM and getting some ideas of how they implemented it. After the presentation, it was clear to see that the JRuby team has a focused effort and is doing very well in porting the Ruby language to the JVM...excellent session.

My second session also focused on languages on the JVM...it was entitled "Multiple Languages, One Virtual Machine". This talk was given by Brian Goetz and John Rose. They did an excellent job of discussing invoke dynamic and what the future holds for dynamic languages on the JVM. It was clear to see that Oracle is putting resource behind offering many different languages on the JVM...not just Java. They are behind the invoke dynamic effort, and it will be included in JDK 7...which is due out sometime in 2011.

I attended many sessions on Java EE 6, EJB, JSF, and other enterprise technologies as I am currently using EJB3 and JSF on many of my projects at work. After attending so many sessions on the EJB 3.1 Lite and JSF 2.0 features, it is clear to see that I need to update my code to take advantage of many of the new features that are available today. It is too easy to get a formula that works and just continue to develop applications using that formula. I fell into that trap over the last couple of years, mainly due to a shortage of time for learning the new stuff. Between my authoring of the Jython book and Oracle PL/SQL Recipes, I haven't enough time to devote an hour a day to learning EJB 3.1, JSF 2.0 or CDI. However, I am making a goal for myself to learn how to migrate my EJB 3.0 code bases to take advantage of the new technologies as I can see from the JavaOne sessions that the newest implementations of the APIs are clearly more productive and easier to manage.

And then there was JavaFX. This technology has always been in the back of my mind as something that I want to learn and begin to use in my projects. I had purchased and read the JavaFX Script book by Jim Weaver a while back...excellent book. As everyone knows by now, it was announced at JavaOne that JavaFX Script will be going away and that the JavaFX API will be changing so that it can be used directly with Java code. This is HUGE news for me as a Java and Jython developer. I attended a great session by Jonathan Giles and Stephen Chin regarding the development of JavaFX applications using alternate languages. They covered JRuby, Closure, Scala, and Groovy in the session. It really looks like the new JavaFX API is going to be great and I am looking forward to writing a JavaFX application using Jython. As a matter of fact, I spoke with Stephen Chin in the Mason St. tent later on, and he was also interested in developing a Jython demo. I hope to see something soon, and plan to develop Jython and JavaFX applications when the new JavaFX API is available.

My parting session was an introduction to Scala. I am glad that I attended this session as well as I have been in the dark about this language until now. I had been hearing lots of good things about Scala, but hadn't found the time to take a look. Attending this session gave me a great overview of the language and really gave me the bug that I needed to put it on my priority list as a language to learn in the coming weeks. Now I need to learn both JRuby and Scala...my time is really going to be growing thin!

Other activities that I took part in included:

Oracle Publisher's Seminar - Since I am writing the PL/SQL Recipes book, I was able to attend this great seminar. It gave me a good opportunity to learn about some Oracle strategies from the team leads themselves, and also meet other Oracle authors.

Jython BoF - Oti Humbel and myself gave a Jython BoF on Wednesday of the conference in the Parc 55 hotel. The BoF was not very well attended, but the appreciation event was also that evening and I suspect that had something to do with it. Overall, Oti and I were able to muddle through the list of open bugs that need to be repaired prior to a Jython 2.5.2 final release. I had a great time meeting with Oti and look forward to working with him on Jython for future releases. We also met with Frank Wierzbicki, the Jython project lead and one of my co-authors for the Jython book. It was great to talk Jython for a while with a couple of the core devs, and to strategize about future Jython developments.

Keynotes - The JavaOne keynotes were okay...lots of hype around the future of Java and JavaFX. Glad I attended them for the experience, but nothing too earth shattering. My favorite keynote was the Oracle Develop keynote by Tom Kyte. I have been a big fan of Tom Kyte for several years as he is a lead in Oracle database technologies and PL/SQL. Excellent keynote with some great insight on Oracle 11gR2 and some of it's new features (some that I have not used yet!).

JavaPosse - Perhaps the highlight of the conference for me was the JavaPosse BoF and rooftop party at the Passion Cafe. I listen to the JavaPosse religiously, and finally having a chance to see the crew in person and have drinks with them after the BoF was a great experience. They are truly great people who do an excellent job with the podcast. Thanks JavaPosse crew, excellent show at JavaOne.

So JavaOne 2010 was a new experience for me. I think that it was a great experience and I would be happy to attend another JavaOne at some point in the future. I think that given the atmosphere and the dynamics of the conference, it was a new experience for even those who had attended in previous years. It is nice to see that Java is in good hands with Oracle, and I am looking forward to a bright future.

Wednesday, March 24, 2010

Working with Images Using Django on Jython

If you've tried to use Django on Jython along with an ImageField, you know well that Django on Jython does not support this field. This is because the ImageField in Django relies on the Python Imaging Library (PIL). Jython does not support the PIL since it is C based, and there is not currently a version of the PIL that has been ported to Java.

That being said, how do we make use of images in Django on Jython? Since the ImageField is not usable from Django on Jython, we need to use an alternate method for uploading and displaying images. The following is a solution I've been using for one of my applications. This is certainly not a perfect solution, nor do I think we should modify Django on Jython to support this solution out-of-the-box. However, it works and gets the job done.

In order to use images with Django on Jython, you need to make use of the FileField. Since the FileField does not display in a template as an image, it is also a requirement to tweak the template which will be displaying the images with an ordinary "img" tag. Also, to make things work nicely, it is important to code a variable...we'll call it "image_src"...with the path to the image that will be displayed. This is done within your views in views.py. Of course, images will take the name attribute of your FileField, but you must prefix that name with the path to your web server. So my solution for this is to create another variable, say PHOTO_ROOT, in the settings.py and we will set it equal to the web server's MEDIA_ROOT location.

Lots of steps to make a usable image? Not really, it may seem daunting at first glance, but it does work easily once you've got it down.

Steps for using images with Django Jython:

1) Create a FileField in your model to contain your image information. Be sure to indicate where you wish the image to be uploaded to by specifying the "upload_to" attribute.

For example, in the following case the "images" directory which is specified by the 'upload_to' attribute exists directly under the MEDIA_ROOT root:

class MyTestModel(models.Model):
photo = models.FileField(upload_to='images', blank=True)


2) Create a variable within settings.py to contain the path to your web server's MEDIA_ROOT location. Please note that this will need to be changed when you deploy to different environments (ie: development or production).


PHOTO_ROOT = 'http://localhost:8000/site_media/'


3) Add a variable to your views through which the image path will be exposed. This variable will need to contain the PHOTO_ROOT you specified in settings.py, as well as the appended file.name for the FileField containing your image. Therefore, you will need to code a line in each view you wish to expose the image through.

In order to make your UI slick, it is a good idea to use a default image for any records that may not have an image uploaded. You can assign the path for that default image to your variable if your FileField does not contain anything.


# Be sure to import your settings file
from django.conf import settings
...
# This code contains relevant portions of a detail view for displaying or modifying
# a record
def detail(request, record_id=0):
...
record = get_object_or_404(MyTestModel, pk=record_id)
form = MyForm(instance=record)

# Check to see if the FileField (photo) contains anything
if record.photo:
image_src = '%s/%s' % (settings.PHOTO_ROOT, record.photo.name)
else:
image_src = '%s/images/nophoto.jpg' % settings.PHOTO_ROOT

...
return render_to_response('detail.html',
{'form':form,
'image_src':image_src})



4) Add an "img" tag to your template in order to display your image. You must also add the "form.photo" field to the template in order to have the ability to upload an image.



some_content
...


{{ form.photo }}

<img title="Photo"
src="{{ image_src }}"/>


...
more_content


That is basically it. When you view the record initially, the default image should appear. After an image is uploaded successfully, it should replace the default image.

Wednesday, March 10, 2010

Received Author Copies of The Definitive Guide to Jython

For the past few weeks since The Definitive Guide to Jython had been published, I've been checking my mail often in anticipation of seeing our book in print for the first time. Well, today my copies finally arrived and it is great. It is excellent to read the printed copy...and it will definitely be nice to have on my desk while I'm coding some Jython.

Thanks again to all of my co-authors, the technical reviewers, editors, and everyone else involved in the publishing of the book. It is a great resource and I am glad to be a part of it. Looking forward to working on the second edition in the not too distant future!

Now, onto more coding...

Wednesday, February 03, 2010

Jython Book - Working with the Sources

The open source version of 'The Definitive Guide to Jython' (aka: Jython book) is available online, both in restructuredText format and HTML via Sphinx. Apress was good enough to send me the final versions for all of our chapters and appendicies in MS-Word format. It is my task to convert them from MS Word format into restructuredText...which is a slow and sometimes painful process.

Overview of Conversion Process

1) Open the MS-Word document in Open Office (my preference) and remove headers and footers from each page

2) Save the document in open office format

3) Try to apply the apress_odt_to_rst.py script that was donated by James Gardner. If that doesn't work, then save document in HTML format and use pandoc to convert.

Command: pandoc -t rst filename.htm > filename.rst

4) Manually parse through each rst file and repair issues (and there are usually a lot...especially with code markup and tables)

Interested in building the sources?

If you are interested in building the sources, you can check the out from bitbucket.org at the following link: http://bitbucket.org/javajuneau/jythonbook/ and then build them using Sphinx

View the Open Source Book

If you'd like to simply view the open source book, it can be found at http://jythonbook.com in Sphinx format. We of course recommend that you purchase a copy of the book from Apress to keep handy as well so that you can mark it up, make notes, etc. However, the open source version will be continually updated and it will be great for using as a quick reference while online.

Monday, February 01, 2010

The Definitive Guide to Jython Is Published

The Definitive Guide to Jython: Python for the Java Platform has been published. This is a work in which five authors: Jim Baker, Victor Ng, Leo Soto, Frank Wierzbicki, and myself, began to author early in 2009. The book covers much detail on the Jython language and it's usage. It was a much needed addition to the library of Jython books that are available today as this book focuses on Jython 2.5.1...the most current release to-date. Many methodologies that hadn't been formally documented previously, such as the object factory pattern, with-statement, django and jython, and concurrency, have been documented in detail in this text.

If you are interested in developing with Jython, I recommend you take a look at this book today. There is also an online open source version of the book that can be found at http://jythonbook.com, but all of it's contents have not yet been updated to include finalized versions of all chapters. I am working on converting the .doc formatted final versions into restructured text at this time, but it is a lengthy process.

Thanks to all of my fellow authors and to the team at Apress for all of their hard work!

Wednesday, September 16, 2009

Jython 2.5.1rc2 - zxJDBC with-statement

This past weekend (09/12/2009), the Jython developer team rolled out the second release candidate for version 2.5.1. In the release were many bug fixes and some additional features...I definitely recommend downloading it and trying it out if you haven't already done so. Thanks to all of the developers who have made this release possible.

One of the features added in this release for database work with the zxJDBC API is with-statement compatibility. Thanks to Jim Baker for updating the PyConnection and PyCursor objects in Jython so that it can now be used in the context of a with-statement. This can be useful for maintaining resources and transactional state when working with databases.

To use the new feature, you must import the closing() function from contextlib so that the connection can be bound to a variable and closed at the end of the statement. Use of this feature works as follows:


# In this example, I am connecting to a postgresql database.
# Of course, we could connect to the database of our choice so long
# as we have the appropriate JDBC driver in our CLASSPATH

>>> from __future__ import with_statement
>>> from com.ziclix.python.sql import zxJDBC
>>> from contextlib import closing
>>> jdbc_url = "jdbc:postgresql:mydatabase"
>>> username = "postgres"
>>> password = "mypass"
>>> driver = "org.postgresql.Driver"
>>> with closing(zxJDBC.connect(jdbc_url, username, password, driver)) as conn:
... with conn:
>>> # Use one or more cursors within the context of the with-statement
... with conn.cursor() as c:
... c.execute("select name from country")
... c.fetchone()
...
(u'Afghanistan',)


In the example above, I queried a database table. However, we could use the cursor in any way that we'd like within the context of the statement. Use for transaction management and if an error occurs within a transaction then everything is rolled back.


>>> with closing(zxJDBC.connect(jdbc_url, username, password, driver)) as conn:
... with conn:
... with conn.cursor() as c:
... try:
... stmt = "insert into country values (?,?)"
... # the following produces an error
... c.executemany(stmt, ['test'])
... # perform more inserts and updates
... conn.commit()
... except Exception, err:
... raise Exception("There has been a zxJDBC error")


Transaction management is taken care of such that if a statement fails, then the complete transaction is rolled back. This is very useful for transaction management. If you attempt to work with the cursor or connection outside of the statement then it will not work because the statement closes them after use. That is the beauty of using the with-statement for resource management. The with-statement is also nice for working with files and such in a similar manner.

For more information on the use of the with_statement, please visit PEP-343 or the open source Jython Book (In Progress) which will soon be updated to illustrate correct usage of with-statement context management for zxJDBC in 2.5.1.

Enjoy!

Thursday, July 02, 2009

The Definitive Guide to Jython - Open Source Version

Start reading the open source version of 'The Definitive Guide to Jython'. This book is currently being authored by Frank Wierzbicki, Jim Baker, Leo Soto, Vic Ng, and myself. It is due to be published by Apress in the fall of 2009. I am having a great time being part of the project and really appreciate the opportunity! I thank Jim Baker for contacting me in regards to the book and giving me the opportunity to become the lead author.

The book is available in restructured text format on the kenai.com website as the jythonbook project. You will find the Sphinx formatted book here for the time being, but we will migrate it to jythonbook.com in the near future. We encourage comments and suggestions.

A special thanks to James Gardner for his help on providing us with the tools to convert the book into restructured text format. I plan to have a post dedicated to my work with converting from Word to rst and vice versa sometime in the near future.

Our book is focusing on the 2.5 release of Jython, which you can download here. It goes through the Python language basics through some advanced concepts. The book then goes into Jython-specific topics such as java integration and the like.

We hope you will find this book useful. Stay tuned for more to follow on the book...

Tuesday, June 16, 2009

Jython 2.5.0 Has Been Released

Jython 2.5.0 has been released! This release includes many new language features for Jython bringing it inline with more modern releases of Python. This is a big release and I congratulate all of the developers!

Go and download today from : http://www.jython.org

Friday, April 10, 2009

Netbeans Articles

James Branam has recently turned a couple of my Python/Jython tutorials for Netbeans 6.5 into Netbeans.org articles. Check them out:

Developing a Jython App in Netbeans

Python Quickstart

If you haven't tried Netbeans out for Jython or Python development, now would be the time...it is great!

Sunday, March 29, 2009

The Definitive Guide to Jython...Fall 2009

A new Jython book will be published by Apress this fall entitled 'The Definitive Guide to Jython with Django'. Authors include Jim Baker, Frank Wierzbicki, Leo Soto, Victor Ng, and myself.

This book will be of interest to those beginning Jython and also to advanced users. We will also maintain an open source version of the book online.

I'm looking forward to working with these talented individuals and assisting in the documentation of Jython.

Tuesday, February 24, 2009

EMD Upload Error: Oracle Enterprise Management Agent

I came into work on Monday and saw that all of the databases which are running on our development database server were no longer reporting to our Oracle Grid Control. After looking at the Grid Control server, I realized that the management agent was not functioning correctly. Time to investigate...

I went to the command line and issued the following:


emctl status agent



Everything looked fine, but then I realized that the "Collection Status" indicated that it had been disabled by the collection manager. In my case, this had occurred because over the weekend I had been moving some files around and filled up one of the disks on the server completely. Realizing I had done so, I immediately removed some of those files to free up disk space. Unfortunately, this disk which filled up was the same one on which the Oracle Management Agent is installed. Being that the disk filled up and that the collection manager was not able to add the required XML files to disk, it immediately disabled itself.

The remedy: Of course, ensure that the disk has available space. Once you've done so, simply restart the management agent. It will begin working immediately.

Thursday, February 05, 2009

Developing Django-Jython Using Netbeans

If you are interested in using Django on Jython, then you will need to incorporate the Django-Jython project into your Jython installation after Django has been installed. The Django-Jython project facilitates the use of Jython's zxJDBC database infrastructure in order for Django to access database backends. At this time, the only fully supported database is Postgresql, but there are also experimental backends for using SQL Server, sqllite, and Oracle under development. In order to use Django on Jython with another database or to assist in the development of these backends, you will need to download the Django-Jython project source code and write your own backend or update one which already exists.

Working with the Django-Jython project using a text editor is one way to go, but if you are used to the automation and simplicity of using an IDE, text editing can be a painful experience. This blog will walk you through the steps of setting up an environment within Netbeans 6.5 for developing the Django-Jython project.

The process of development with Django-Jython is as follows:

1. Download source for project

2. Add/Modify source code to facilitate your needs

3. Build the source and install it into your Jython home

Number 1 above is easy enough, just visit the Django-Jython project page. However, numbers 2 and 3 are manually performed processes. You can help to automate these processes by using the power of Netbeans. Simply follow the procedure below to set up the environment:

1) Create a Python project with existing sources and name it something like "DjangoJython"




2) Add the root-level directory of the "django-jython" source folder to the "Source Root Folders" window area when creating the project, then click finish.


At this point your project will be created and you can work with the source. However, we need a way to tell the IDE to build and install the project. You can either use the command-line to do so by traversing to the project folder and issuing:

jython setup.py build, followed by, jython setup.py install

Or, you can perform have Netbeans IDE build the project for you when you invoke the "Run" process on the project by performing step 3.

3) Right-click on the project, and choose "Properties". Select the "Run" category and then enter "setup.py" as the main module and enter "install" into the application arguments text field. Now, each time you elect to "run" the project, it will cause netbeans to build and install it.




The only caveat to using this method of building and installing Django-Jython is that you will need to manually delete the "build" directory in your DjangoJython Netbeans project as well as delete the "doj" directory from your Jython installation (Jython-Path/Lib/site-packages/doj) prior to issuing "run" each time. I have found that if you do not, sometimes all of the updated modules are not reinstalled. Deleting these directories prior to running your build/install forces a new build and install to take place each time.

Now, enjoy the great development experience of Netbeans while contributing to a great project...Django-Jython! Have fun!

Wednesday, January 21, 2009

Django-Jython: Working With Experimental Database Backends - Part 1

This is the first of several blogs that I plan to publish regarding the use of experimental database backends with the Django-Jython project. In this series of blogs, I will cover the basics of how to begin using the experimental backends, as well as some details on how to create your own. At the time of this posting, only one "fully supported" backend exists for the Django-Jython project and that is for the PostgreSQL database. However, another experimental backend exists for SQLLite and there are more on the way.

In order to build and begin using the experimental backend for SQLLite (or others), you must first obtain a copy of the code, which is available on the project site, or via your command-line using the following line:

svn checkout http://django-jython.googlecode.com/svn/trunk/ django-jython-read-only

Once you've obtained the code, it is easy to build. Simply traverse into the root directory of the downloaded code which should be named "django-jython", and perform the build using the setup.py build script as such:

jython setup.py build

Now, this works nicely for a build to use the PostgreSQL backend, but it will not include the experimental backend implementations. In order to do so, you must open up the setup.py script and add the experimental backend that you wish to use within the "packages" listing as follows:


from distutils.core import setup
setup(
name = "django-jython",
version = "0.9",
packages = ['doj',
'doj.backends',
'doj.backends..zxjdbc',
'doj.backends..zxjdbc.postgresql',
'doj.backends..zxjdbc.sqllite', # Experimental backend
'doj.management',
'doj.management.commands'],
...



Once you've added this to the setup.py script, it will cause the experimental code to be built the next time the build process is invoked. Now you can begin using the new backend.

Next time I plan to delve into the process of creating your own experimental backend for the Django-Jython project!

Sunday, January 11, 2009

Jython 101 - Altering Tuple Values

Often times we use lists and tuples to hold data that will be used at some later point in an application. When we iterate through the data within them without changing it then they work without any issues. However, if we wish to change one or two of the values that are contained in a tuple then we may run into an issue because they are immutable in the Jython world. Lists are a bit different as they can be altered. If you've run into this issue with tuples and need an easy solution, then hopefully the technique which I am about to describe will help you.

The Problem

Let's say we have a tuple of parameters that we wish to pass to another Jython module at some later point. However, once the receiving function obtains the tuple of parameters, it is found that a value needs to be added to it in order to make it complete. How do we add or insert a value into a tuple if they are immutable?


The Solution


Quite easily actually, the answer is that we define a list that will take the values of the tuple and pass it on.

For instance, lets define tuple:

x = ("one", "two", "four")

print x
['one', 'two', four']


If we try to alter the tuple and insert the value "three" before the four, we receive an error:


x[2] = "three"

TypeError: can't assign to immutable object



Therefore, a great workaround is to define an empty list and populate it with the contents of the tuple. At the same time, you can add, change, or remove any elements that you wish. In the end, use the newly define list as your "new" parameter list and pass it on.



# define empty list
y = []

# iterate through tuple and populate new list

for elem in x:

# check element to see if it's contents need to be changed, or moved
# in this case, we are looking for an element with the value "four"
# so that we can insert "three" in front of it

if elem == "four":

# Insert the new element, and then the current element
y.append("three")
y.append(elem)
else:
# Insert the current element
y.append(elem)

print y # Use the new list and continue.
['one', 'two', 'three', 'four']




I hope that you find this tip for using Jython tuples useful.

Joined the Netbeans Community Docs Team

I have joined the Netbeans Community Docs team recently. This is a great program that has been put together to allow the Netbeans community to help document and provide guides for using the IDE. I hope that I am able to add some benefit to the team by providing tutorials, articles, and documentation from time to time. I am also going to be compiling and editing the monthly newsletter for the group.

Stay tuned for more Netbeans-related blog entries focused on using the IDE with all of the technologies I love...including (but not limited to) Java, JavaEE, Jython, Groovy, JavaFX, Swing, SQL...and more!

Sunday, January 04, 2009

Web Beans 1.0.0 Alpha Released

JBoss has released Web Beans 1.0.0 Alpha recently. Quoted from the Web Beans site:

"Web Beans defines a set of services for the Java EE environment that makes applications much easier to develop. Web Beans layers an enhanced lifecycle and interaction model over existing Java component types including JavaBeans and Enterprise Java Beans. As a complement to the traditional Java EE programming model, the Web Beans services provide:

* an improved lifecycle for stateful components, bound to well-defined contexts,
* a typesafe approach to dependency injection,
* interaction via an event notification facility, and
* a better approach to binding interceptors to components, along with a new kind of interceptor, called a decorator, that is more appropriate for use in solving business problems.

Web Beans is especially useful in the context of web applications, but is applicable to many different kinds of applications and may even be used in the Java SE context, in conjunction with an embeddable EJB Lite container, as defined in the EJB 3.1 specification. "

I'll be checking this out soon...

Tuesday, December 23, 2008

Jython Podcast Domain Name

Thanks to Groovymag.com, the Jython Podcast site is now available at jythonpodcast.com. If you haven't yet had a chance to read Groovymag, I suggest that you take a look if at all interested in Groovy or Grails. The magazine is an excellent resource for beginners and advanced Groovy users alike.

Thanks to Michael Kimsal and the Groovymag for the domain name.

Friday, December 19, 2008

Jython Podcast Site Ready

I finished the preliminary Jython Podcast website last week and I thought that it would be a good idea to release it to the world for your thoughts and opinions. I wanted to create and deploy the website as a Django site running on Jython. However, as it turns out I am unable to deploy a Django on Jython site to a server running on JDK 1.5 (at least I haven't figured out how to do it as yet). Therefore, I have had to postpone the deployment of the Django site until I can upgrade to JDK 1.6.

It is my plan to begin the podcast with an episode near the end of December. Hopefully once I get the first episode released, iTunes will not have any problems updating to include it.

Check out the Jython Podcast site here. I also would like to thank HostJava.net for providing the domain name and sponsoring the podcast.

Tuesday, December 02, 2008

Jython CLASSPATH

I ran into a small issue this past weekend while doing some Django development with Jython 2.5 b0. The Django scripts appeared to be running correctly until I attempted to synchronize with the database using:

jython manage.py syncdb

Each time I tried to run this against my Postgresql backend I was receiving an error stating that "org.postgresql.Driver" could not be found. In reality, that driver was already in my Jython CLASSPATH because it is installed by default when Django is set up.

The issue may be that I have too many Jython installations on my Mac now, but nonetheless, it is easy to work around. I still have not found the complete solution as yet, but as long as the "--verify" argument is passed along with the "syncdb" call then everything works out well. This is because the verify argument forces the CLASSPATH to be parsed at runtime. While the --verify argument makes it take a second or two longer to run, it should resolve issues where the CLASSPATH is not being parsed as it should.

Workaround solution:

jython --verify manage.py syncdb

Wednesday, November 19, 2008

NetCAT 6.5 Complete!

I'd like to thank all of the developers at Netbeans for hosting a great NetCAT session for the 6.5 release. It seemed that everyone on the development team played an important role in this great release and the NetCAT team members also provided meaningful feedback and assistance.

I'd recommend that anyone who is interested in having their voice heard for future releases of Netbeans should get involved in future NetCAT programs. All of us members certainly had "our say" in many features of the final product. This is a program that really goes to show how much the community can make a difference.

Thanks again to Netbeans developers and fellow NetCAT 6.5 participants.

Netbeans 6.5 GA Available

If you haven't done so already, I suggest that you go and pick up Netbeans 6.5 at this time. It is arguably the best IDE release ever. Along with the Java feature updates, this new version of the IDE includes Groovy support, compile on save, and Python support is available in EA format.

If you want to migrate your libraries from an older version of 6.5 (release candidate), simply copy the project libraries files. See this wiki article for more details.

Tuesday, November 04, 2008

Check out GroovyMag

Interested in Groovy or Grails? If you are then you'll want to check out GroovyMag.com as the first issue of GroovyMag is now available for download. Unfortunately, it looks like you have to purchase the magazine. However, the cost looks pretty reasonable and it looks as though there is a lot of good content...probably worth the $4.99, so check it out at http://www.groovymag.com/main/ to see a summary of the content.

Thursday, October 30, 2008

Netbeans 6.5 RC2

Download Netbeans 6.5 RC2 now and try it out.

If you have been using 6.5 RC1, then you will need to redo all of your settings for RC2. However, the easiest way to get around this is to copy the contents of your Netbeans user directory from RC1 into RC2. If you do this then all of your settings will be retained.

Test RC2 and give feedback to the development team (nbdev@netbeans.org) if there are issues.

Monday, October 20, 2008

Jython Monthly Newsletter

Anyone who wishes to post an article for the October distribution of Jython Monthly should place link on the following page. http://wiki.python.org/jython/JythonMonthly/Articles/October2008

Distribution of the newsletter will occur this week. Thanks in advance for all article submissions.

Wednesday, September 24, 2008

Java for Mac OS X 10.5 Update 2

Java for Mac OS X 10.5 Update 2 has been released. Mac users (with compatible machines) should go to software updates and download soon. I just installed the update and used it to run some tests with Netbeans 6.5 and the performance is much better than running on an Apple JDK 1.5 release. Things are looking good so far...

Tuesday, September 09, 2008

Groovy Datasources - Changing Hibernate Dialect - Oracle 11g

I found a funny while working with some Grails applications today. I have been developing one of my Grails applications for about 2 or 3 weeks now. I updated DataSource.groovy on Day 1 to make the application work with my development Oracle repository and all was well.

Yesterday, I migrated my development Oracle environment to 11g and my Grails application stopped functioning. I was receiving messages stating that the correct Hibernate dialect was not able to be determined. I was forced to explicitly list which dialect to use within my DataSources.groovy file and I thought I'd share.

If you migrate to Oracle 11g (from any previous release...in my case it was 10.2.0.3), and you need to specify the Hibernate dialect then you will need to add the following line to your DataSources.groovy within the DataSource block:

dialect = org.hibernate.dialect.OracleDialect

Monday, September 08, 2008

Detecting Google Chrome In Javascript

Thanks to javascript.internet.com, here is a quick post on how to detect the new Google Chrome browser from within your Javascript code.


var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

By the way, if you are looking for some great javascript tips, take a look at javascript.internet.com as it is an excellent resource.

Monday, September 01, 2008

Having Fun with JavaFX

I finally had a chance to play around a bit with Fx over this long holiday weekend. At this point, the JavaFx script language is fairly straight forward, but I still find myself looking at examples in order to get the syntax correct when building a GUI.

http://silveiraneto.net/2008/08/11/javafx-draggable-node/

http://silveiraneto.net/2008/07/31/javafx-creating-a-sphere-with-shadow/

I will be posting some updates to this blog at a later date. As for now, I've successfully created a news ticker using JavaFX and I plan to release the source once I've worked out all of the rough edges.

More to follow...

Monday, August 25, 2008

Jython News!

Check out the latest Jython Monthly for some great news on the up and coming Jython 2.5 release. It is now in alpha stages, but it is looking great so far!

You can also read-up on using Django with Jython...good work Leo Soto! Also take this opportunity to ask all of your Jythonic questions of Jim Baker...a lead Jython developer. See newsletter for more details!

NetCAT 6.5 Update

I thought I'd give a brief update of the status on the NetCAT 6.5 testing. If you are unaware of what NetCAT is, please visit the site to learn more about it.

Thus far, it appears that Netbeans 6.5 is on track with the latest projections of a production release sometime in October. As you probably already know, the first beta release was distributed already and is available here. In the release, most of the new features are fully implemented. I will warn that there are some bugs obviously found in the release (expected because it is a beta) that could cause some minor issues in your development. For instance, the new "deploy on save" feature of Netbeans is nice but has many quirks at this time. If you are developing a JavaEE application, each time you save an XHMTL, JSP, or HTML file then the complete application is recompiled and deployed. I have found that this can lead to decreased productivity as it can cause workstation performance degradation as well as PermGen errors on the deployment application server. This is probably the largest bug I've seen since the beta release, so please do not allow it to keep you away from testing the release.

For those of you who have downloaded and tested the beta release, you already know that the IDE is looking great! Netbeans developers have been outstanding in repairing bugs and putting great new features into the IDE. Each new release of Netbeans brings it one step closer to "the only IDE you will ever need" in my book...but don't take my word, please test and see for yourself.

Before I post this blog I also want to mention that for those Grails developers in the community, Netbeans 6.5 is a must have! Productivity time is increased even more by using the combination of Grails with Netbeans. One of the advantages that Netbeans offers is the Grails plugin wizard...just right-click on your project to install or uninstall any Grails plugin. No need to make that trip to the website any longer for plugin updates!

Download 6.5 beta and enjoy...

Wednesday, August 13, 2008

Netbeans 6.5 Beta Is Available...Grab It and Test!

The Netbeans team has just released 6.5 beta. Having been testing the latest nightly builds, I think that you'll be pleased with the beta once you try it. The Groovy/Grails support is in great shape. New features have been added since M1, including a plugin manager and different application layout.

You'll also enjoy the automatic deploy on save feature. This really helps to speed up development time.

Congrats to the Netbeans team on delivering this beta of 6.5...it is looking so far.

Wednesday, August 06, 2008

Plan Your Events for Free - Gather Event Planning

Gather Event Planning is a free service that I started a few months ago to assist individuals or groups that are planning events. The service is based upon my open source reunion planning software. This service is web hosting which provides sites geared towards planning and organizing events such as reunions, meetings, or gatherings in general. Each Gather Event Planning website grants it's owner privileges to change all page content, administer mailing and guest lists, post news, etc.

Originally, I was planning to charge a minimal fee for the service in order to cover the costs of hosting. However, I've partnered up with another group to pay for the hosting and together we've produced Restoring The Roar a Chicago Blackhawks Hockey fan site. I've also partnered up with another associate who will be starting a website shortly. Gather Event Planning is now free thanks to the new partnerships.

So if you or someone you know needs to plan an event of any kind, please try out Gather Event Planning...and give me feedback!

Netbeans 6.5 - Project Properties Additions

Some of the nice new features of Netbeans 6.5 include Groovy and PHP support, automatic project deployment on save (which makes development time much quicker), and some new additions in the Project Properties menu. Allan Christensen blogs about the new Project-Based formatting option which is available. This gives you the ability to apply different formatting styles on a per-project basis.

Another nice new addition to the project properties menu is the Javascript Libraries. This allows you to choose from a set of default Javascript libraries (Yahoo User Interface, Dojo, etc) and add them to your project. This new option also gives you the ability to add your own libraries which is very handy.

Tuesday, July 29, 2008

Adding Groovy File Compilation To Any Netbeans Project

Many of you may already be aware that adding support for groovy file
compilation in any Netbeans project is easy. You can easily adjust the
build file to use the groovyc compiler. For those of you who do not know
how to do this, simply perform the following:

1) Adjust build.xml by adding the following target:

<target name="-pre-compile">
  classpath="${your.netbeans.groovy.library.classpath}" />
  <groovyc destdir="${classes.dir}"
  classpath="${ your.netbeans.groovy.library.classpath}"
  jointcompilationoptions="-j -Jsource=1.5 -Jtarget=1.5">
 
  </groovyc>
  </target>



2) Compile your project as normal!

All .groovy files will be compiled into Java...seamless integration. If you
are already using the "-pre-compile" target for another task, then name it
something else and adjust the build-impl.xml accordingly to include the new
target.

Tuesday, July 15, 2008

NetCAT 6.5 - Keeping Busy!

NetCAT 6.5 just started yesterday and I can say that there is a great group of Netbeans users from the community testing! This is sure to be a stellar release of the IDE, and if you've downloaded and tried M1 I am sure you will agree.

As Roman Strobl and Greg Sporar say...Happy Netbeaning...

Jython 2.5 Alpha Released!

Frank Wierzbicki of Sun Microsystems has just announced the release of Jython 2.5 Alpha 1. Click on the link above for the download...

More to come once I have a chance to play with it a while...

Monday, July 07, 2008

Netbeans 6.5 M1 Is Out!

Download it and start testing today! I downloaded the IDE this morning and I've been using it for most of the day. I have to say that it is in great shape! I especially love the added Groovy editor and faster startup time. Another great point is that I had no issues with importing projects and settings from 6.1.

Another great Netbeans release is on it's way!

Friday, June 20, 2008

Ask Frank! A Jython Interview with Frank Wierzbicki of Sun Microsystems

Jython Monthly Presents "Ask Frank"...a question and answer session with Frank Wierzbicki for the Jython community!

I've been in touch with Frank Wierzbicki of Sun Microsystems. In case you aren't aware, Frank is one of the top Jython developers, and earlier this year Sun Microsystems hired him to work on Jython full time!

He has agreed to answer questions from the community for our July 2008 newsletter. Gather your best questions and post them to the wiki at the URL below. If you have issues posting the questions on the wiki page, then please send them to me at juneau001@gmail.com so that they can be included. The deadline for posting questions is July 11th. After that time, Frank Wierzbicki will choose which ones he wishes to answer and we will include them in the next distribution.

Please post your questions to Ask Frank at: http://wiki.python.org/jython/JythonMonthly/Interviews/July2008/AskFrank and feel free to include your name/email address if you'd like.

Thanks in advance for your participation...this is a great opportunity for the Jython community.

Special thanks to Frank Wierzbicki for his time!

JBoss Seam - Interceptors Using Groovy - Quick Tip

Quick Tip: If you are using Groovy in any of your Seam applications (particularly when deploying to Glassfish), be sure to update the @Interceptors annotation in your session beans as such:

From: @Interceptors([org.jboss.seam.ejb.SeamInterceptor.class])

To: @Interceptors([org.jboss.seam.ejb.SeamInterceptor.class])

Thursday, June 19, 2008

Using Groovy with Seam 2.0 in Netbeans 6.1

Of course, Seam 2.0 is ready to go with Groovy support which is great news! However, for someone who is not interested in using Seam Gen it is not very straight forward. This is true especially if one wishes to use Eclipse or Netbeans for their development environment.

A while back, I wrote a blog about developing Seam applications on Netbeans and deploying to Glassfish (http://jj-blogger.blogspot.com/2007/07/jboss-seam-configurations-jars-and.html). I need to post an update blog because I am now deploying Seam 2.0 apps to Glassfish Version 2 using Netbeans. I'd like to add a bit of syntactic candy into the process now and include Groovy support into my Netbeans Seam projects.

Simply add the following to your build.xml file (contained within the root of your Netbeans project) and modify paths accordingly. You will also need to package groovy-all.jar with your application. Once completed, you can add Groovy files suffixed with .groovy into your project Seamlessly. At compile time, they will be compiled into Java classes.

<target name="-pre-compile">
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpath="${classpath-to-groovy}" />
<groovyc destdir="${classes.dir}">
<classpath>
<pathelement path="${classpath-to-groovy}"/>
</classpath>
<javac source="1.5" target="1.5" debug="on"/>
<src path="${src.dir}"/>
</groovyc>
</target>

Counting Rows in Oracle in a Generic Fashion

As a DBA, every once in a while it is useful to have the ability of searching through all of the tables within a particular database to find a value. This can be a useful thing to do if you need to find all references to a particular record in a database table. Most likely, this kind of operation would need to be performed in order to safely delete a record from a database that was not using referential integrity. I know that I administer at least one legacy database which does not utilize referential integrity much at all. One major downfall to not using referential integrity is that records can be unsafely deleted, potentially leaving dangling references throughout the database.

One could easily write a block of code to search for a particular value throughout all tables in the database by iteration using views such as USER_TABLES. I have done so myself on many occasions. So much, that I grew tired of coding new blocks of code to search for particular values each time I needed to do so. I finally took a few minutes to write a generic stored procedure which will load into any Oracle database schema, and it has the ability to perform a full table search any particular value. The procedure takes two parameters, column name (or value name) and value. By invoking the procedure and passing these two values, the database will search through all tables within a particular schema and find those values within the column name you have given. The one caveat is that some databases use different column names throughout the database for the same identifiers. For example, I work with a database that calls an employee id number ID in one table, and EMP_ID in another. You must account for such discrepancies when using this procedure.

The code for this generic counting solution is as follows:

create or replace
procedure check_object_counts(column_name_val IN varchar2,
column_value IN varchar2) is
cursor table_cur is
select table_name
from user_tab_columns
where column_name = upper(column_name_val);

row_count number := 0;

begin
DBMS_OUTPUT.PUT_LINE('THE ' || upper(COLUMN_NAME_VAL) || ' IS REFERENCED IN THE FOLLOWING TABLES:');
for table_rec in table_cur LOOP
EXECUTE IMMEDIATE 'select count(*) from ' ||table_rec.table_name ||
' where ' || column_name_val || ' = :THIS_OBJECT'
INTO ROW_COUNT
USING column_value;

if row_count > 0 then
DBMS_OUTPUT.PUT_LINE(table_rec.table_name || ' - ' || row_count || ' times ');
end if;

row_count := 0;

end LOOP;

end;
/

As stated previously, this procedure can be loaded into any schema which has CREATE ANY PROCEDURE privileges. You invoke it as such from within SQLPlus:

@check_object_counts('EMP_ID','10037E');

** By the way, be sure to use SET SERVEROUTPUT ON prior to running the script so that you see the output!

It may not be a catch all solution, but it does the trick 98% of the time! Best to you and happy DBA-ing!

Wednesday, June 11, 2008

TinyMCE Basics

I spent a good deal of time searching the web yesterday. I was trying to remember how to make the TinyMCE WYSIWYG editor allow all HTML tags. If you've never heard of this editor, it is an excellent AJAX based editor for your websites. I use it to allow my clients the ability to edit and create HTML on-the-fly without any knowledge of Javascript. Basically, it displays HTML as an OpenOffice (or Word) document would. You can simply highlight text and make it bold, italic, or underlined. It also allows the ability to post photos (as long as the photo is on the web) and much more.

The key to allowing straight HTML is to include the following configuration at the top of your webpage. TinyMCE will take any textarea and make it into a nice editor.

tinyMCE.init({
...
valid_elements : "a[href|target=_blank],strong/b,div[align],br"

})



Above is a basic configuration to allow certain html elements. In order to allow a more flexible amount of elements, just follow this link: http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/valid_elements

Simple, eh...too bad I wasted some time searching for it when the answer was right in front of me...

Tuesday, June 10, 2008

JSF 2.0 Early Access Revew

Take a minute to download and read the JSF 2.0 Early Access Review doc.  It looks like JSF will be getting better, I just hope that Seam will also continue to evolve into an even better (doesn't seam like it can get much better..it is great now) framework for JSF/EJB.  Hopefully JSF 2.0 will have some added benefit in this process...

Wednesday, May 28, 2008

Great Seam Security Article for 2.1.0GA

Check out the link below for a great article that discusses the new security features in Seam 2.1.0GA!

http://shane.bryzak.com/blog/articles/seam_security_gets_an_upgrade

Friday, May 23, 2008

Java SE 7 - What would you like to see?

As always, The Java Posse had another great interview in show #187.  This time, they interviewed Danny Coward who is "Chief Architect of Sun's Client Software, and Sun's Java SE/EE representative on the Executive Committee for the JCP".  I highly recommend listening if you are interested in learning about the future of Java SE and what SE 7 may bring.

One of the interesting topics in the interview was about what will be included with Java SE 7.  I thought I'd start a blog post to capture some of the community's ideas about what should be included in the release.  

What would you like to see in the release of Java SE 7?

Wednesday, May 14, 2008

Jython Monthly Call for Articles - May 2008

Let's get Jython back in the spotlight!  Send in some articles about Jython for distribution in this month's newsletter.

Please post all articles/tutorials in the following area:  http://wiki.python.org/jython/JythonMonthly/Articles/May2008

All contributions are welcome!

Tuesday, May 13, 2008

Netbeans 6.1 - Facelets and Seam Support!

It is not official yet, but I learned that you can download and build the facelets and seam support projects for Netbeans while reading today's Netbeans newsletter.  I will give a thumbs up in the affirmative as I have followed the directions within the blog and successfully achieved Facelets and Seam support within 6.1!

Thanks for the excellent blog and for the time which was put forth in working on these projects!

Wednesday, April 30, 2008

Java 1.6 on OSX

I love my Mac even more today...Java SE 6 version 1.6.0_05 has finally been released (as if you hadn't already heard).  This is great news for any Mac Java developer!
Just remember, if you had installed a beta version of 1.6 then you will have to manually remove /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0 before you can get the update via Software Update.

Tuesday, April 29, 2008

Netbeans 6.1 - Out of the Box

I really haven't gotten too far into it yet, but I've just installed Netbeans 6.1 final edition.  So far, I can say that the start up time seems good, and I am glad that all of my libraries were migrated out-of-the-box.  I simply used the import prompt to grab all of my settings from 6.1 and I was good to go.  This is great news...it means that I can just start using Netbeans 6.1 with no additional configuration overhead.  

That's all for now...I'm looking forward to using another great product from the Netbeans team!

Wednesday, April 23, 2008

Grails - Coding and Accessing a simple custom controller method

If you've ever worked with Grails, then you know how easy it is to create domain classes which map to database tables. Similarly, it is easy to access the database via the automatically generated conroller methods that are available (create, list, delete, save, edit, show). However, if you need to perform a particular operation against the database which is not accomplished by using any of these automatically generated methods, it is still easy...but perhaps not very intuative. Once you learn how to accomplish this task then the entire power behind using hibernate and accessing your database is at your hands.

It really is as easy as 1, 2, 3 to create additional controller methods...especially if you know how to use the Groovy language itself. I will show you how to create a simple finder method which takes a parameter and searches a particular database table for the value of that parameter...then it returns the results.

As you already know, the list method for each Grails controller is already created for you...let's look at my list method for the "Test" domain class (database table):

def list = {

if(!params.max) params.max = 10
[ testList: Test.list( params) ]
}


This is all well and good, but it returns the entire dataset for the Test database table. What if I only wish to return all of the records which have foreign key id of 35? Let's say that our foreign key id variable is fkId to make it simple. So what we want is to return all members of the list returned using the "list" method above which have fkId == 35.

We need to first obtain the complete list of results, and then filter it out accordingly. This is where the power of Groovy comes into play. We could use Java and write a filter so that we iterate through each of the items in the complete list of results searching for instances where fkId == 35 and then adding those matching objects to another list. That would be lots of code though. Let's use a Groovy closure to accomplish the same thing. Take a look at the "find" method which does just that:

def find = {
def testList = Test.list( params)
[testSearch : testList.findAll{it.fkId == Integer.valueOf(params.fkId)}]

}

Ok, simplicity at it's finest! We first obtain the complete list from the database table into the testList object. Then, we use the Groovy "findAll" method to search that list for all instances where fkId == the value of our parameter which is passed in (params.fkId)...let's assume that the parameter equals 35. We store our results in the testSearch list.

Now, how do we access this method? Well, we have to create a Groovy Server Page named find.gsp to show our results. We also need to pass the fkId parameter to this method somehow. Here is a simple find.gsp which will iterate through all of the objects which are returned within the testSearch list.  Of course...this is just a quick page with ugly results...but you can clean it up to suit your needs.

find.gsp:

<g:each in="${testSearch}" status="i" var="test">
   FieldOne:  ${test.fieldOne}
   FieldTwo: ${test.fieldTwo}
</g:each>

Now, what is the URL which we use in order to access our new controller and page?  Assume that our application name is "site" and we are passing a parameter of fkId = 35...

http://localhost:8080/site/test/find?fkId=35

Easy enough, but it took me a bit of time to figure out when I first tried it.  Hopefully this post will save you some time and get you adding some much needed functionality to your standard Grails app.



Friday, April 18, 2008

Groovy - Grails Work

Onto new stuff...I have been working a lot with Grails lately. This is the technology that I have chosen to use for the implementation of the gathereventplanning.com website. While Grails is easy to use out of the box, I have found myself searching the net for information regarding customization. No doubt about it, unless you are creating your own simple CRUD application, you will want to customize the program in one way or another.

There have been many articles and blogs written about creating Grails applications and customizing them, but perhaps one of the best I have found so far is the Mastering Grails series...it has been quite helpful thus far.

I'm not going to get too technical in this brief post, but I will say that I have found a bug already. The issue resides in the Grails 1.0.2 release. I had created and customized a tiny CRUD application for testing purposes using the embedded database that comes with Grails. All was good until I attempted to "hook" my program to a PostgreSQL database instead. At that point the application was in read-only mode as it was unable to perform any batch inserts or updates to the database. Each time I tried to insert or update data, I received a stack trace stating that there was a SQL Grammar error.

I scratched my head for days on this one, looked at lots of hibernate documenation (since this is used behind the scenes in Grails), and even tried to change my domain model a bit to see if that would work. Eventually, I ended up downloading Grails 1.0.1 and trying to do the same thing. It works perfectly...no issues as yet. I have been able to successfully re-create my small application and use a PostgreSQL database without issues.

My guess is that this will be resolved with Grails 1.0.3 release, but we will see. So far, I love Grails as it is quite powerful and easy to use. Other than the bug I found, the only complaint I have is that Grails is so involved...many plug-ins are available and the Grails documentation is huge as it is. If you really want to become an expert Grails developer, you will be doing a lot of studying...but learning new technology like this is fun stuff.

Monday, April 14, 2008

Netbeans 6.1 Beta - Subtle Issues

I've been using Netbeans 6.1 beta for most of my development since it has become available. Until recently, I hadn't noticed any issues while using it. Late last week I think I've encountered a subtle, but time consuming issue.

I am in the process of migrating my Seam applications from 1.x to 2.0.1 at this time. In doing so, I am also adjusting libraries within Netbeans as necessary. As you may know, when moving from older versions of Seam you must update all JSF pages to comply with JSF 1.2 standards...so these libraries must be updated as well.

The issue arose when I attempted to deploy one of my applications to my test environment which is running Glassfish V2. Many class not found issues appeared in the server log each time I tried to deploy. At the bottom of the stack trace I received a misleading message stating that there were "Errors in the EjbDescriptor". This led me searching my ejb-jar.xml, pages.xml, and web.xml files looking for issues. As none were found, I tried to give it the old clean, rebuild, and deploy once again...same issue.

At this point I began comparing with another successful Seam 2.0 migration and there were really no apparent differences. I spotted the problem when I went to the file system and looked in the application's dist directory. None of my Seam 2.0 libraries were being packaged with the deployment.

As it turns out, if you repackage and change libraries for an existing application within Netbeans 6.1 beta, then you must do the following:

1) Right click on the project, and choose properties.

2) Navigate to Libraries and make necessary changes.

3) YOU MUST check and uncheck the package checkbox within the libraries configuration...even if it is checked by default. This must update the build script for Netbeans because this was checked by default, but my libraries were not included.

After I unchecked the library package box and then re-checked it everything worked fine. The necessary JAR files that are contained within my included Netbeans libraries were deployed with my app and it works fine now.

Not a big issue, but an issue that is definitely not obvious and took me some time to figure out. I still recommend Netbeans 6.1...but I am not moving to RC1 at this time. I will probably wait for the production release because I do not want to migrate my libraries manually...

Happy NetBeaning....

Monday, April 07, 2008

Shameless Self-Advertising

Time for a bit of shameless self-advertising. I'd like to let everyone know about a new hosting service I've started to assist individuals in event planning. If you or anyone you know needs to plan an event sometime soon, please take a look at my site and see if it will help out. Gather Event Planning offers individuals their own dedicated web site for organizing an event. The website includes a news blog, member registration, member forum, email contact lists, and much more to help aid in the process of planning an organized event.

There is no fee to try the service...only an email address is required. If you use the service for less than 30 days then it is free. This will allow anyone to plan a short-term event (such as a surprise party) without incurring any charges. There are plans available for those who wish to host a long-term event site for class reunions and such.

Enough gabbing about the service, feel free to give it a try and then let me know what you think.

Visit the site at http://www.gathereventplanning.com for more details.

SeamFramework.org - In case you did not know...

I wanted to let everyone know about another great JBoss SEAM resource, it is the seamframework.org website. This site includes a lot of documentation, as well as a community for SEAM developers.

Another good reason to use the SEAM framework!

Jython Monthly Call for Articles - April 2008

The April 2008 edition of the Jython Monthly newsletter is scheduled for distribution on April 15, 2008.

Please post any articles or contributions for the April 2008 distribution of the Jython Monthly newsletter at the following link:

http://wiki.python.org/jython/JythonMonthly/Articles/April2008

Visit http://wiki.python.org/jython/JythonMonthly/Articles/Submitting for details regarding newsletter artical submittals.

All contributions are appreciated! Please feel free to contact me if you have any questions.

Tuesday, April 01, 2008

Groovy Netbeans Plugin

After searching for a while to find information regarding the Groovy and Grails Netbeans plugin, I determined that it is only available if you download and use a nightly build. You must download a nightly build and then go to the plugin manager to find it.

Ok, that is good news, so now I will get to try out the plugin and see how it works. One slight reminder though, if you download and use a Netbeans nightly build then none of your created libraries will be carried forward. I've got too many libraries created so I plan on using the nightly build to evaluate the Groovy plugin only...I will continue my day-to-day development on the NB 6.1 release.

I wonder if a Jython plugin is in the future? One would think that since a couple of Jython gurus have been hired by Sun, we may have some hope for good Jython support in a future Netbeans release...let's hope so!

Wednesday, March 19, 2008

Netbeans 6.1 Beta

I've downloaded the latest Netbeans 6.1 beta release and installed it on my Mac today. I haven't had too much time to work with it as yet, but thus far I have found the following to be nice:

- No need to manually set up libraries or import projects, ALL of my settings from 6.0.1 have been imported successfully!

- Javascript support is nice

- Startup time has been greatly reduced!

These are some of the improvements I've seen within the last few minutes of looking around. It also seems like my applications build faster and deploy to Glassfish V2 with improved speed...

I have found one negative point so far...Facelets support is completely gone from what I can see. My facelets support plugin https://nbfaceletssupport.dev.java.net/ which worked in 6.0.1 does not load anymore. All XHTML documents now look like plain old JSP...but I cannot say whether code completion for facelets will work or not as I have not really had a chance to test thus far.

If you are looking to see improvements and don't mind losing the facelets plugin support, I recommend giving it a try.

Tuesday, March 11, 2008

Jython Monthly Call for Articles - March 2008

The March 2008 edition of Jython Monthly is scheduled to be distributed next Tuesday, March 18th. Everyone would definitely like to see more articles and/or tutorials, so if you have any content that you'd like to share then please submit it to the following area:

http://wiki.python.org/jython/JythonMonthly/Articles/March2008

Thanks in advance for all contributions!

P.S - Way to go Frank!! Good luck at Sun!

Tuesday, February 12, 2008

Jython Monthly Call for Articles - February 2008



Please submit new articles and/or tutorials for the Feburary 2008 distribution of Jython Monthly. Feel free to write or teach about any topic that is Jython related...the more articles the better!

Thanks in advance for your participation!

Monday, February 11, 2008

JavaFX Script - An Excellent Read

I finished reading the JavaFX Script book by James Weaver a couple of days ago. I ordered this book from Amazon last November, and it just arrived last month. I have to say that I was getting a bit impatient about the delay, but it really was worth the wait.

If you are new to JavaFX like me, then you will find this to be an excellent starting point. The book is really geared towards developers who are interested in authoring small Swing-like applications. I'd have to say that it helped to have a good background in Swing prior to reading this book...but I think that anyone could pick it up and just start from scratch. James does a great job from start to finish as he builds upon concepts as the book goes on. It really is a start-to-finish book, but at 200 pages, that is not very rough to read straight through. It really is a quick read, and quickly jumps into the basics and works up from there. I was also impressed with the example applications used in the book as they gave me a great sense of what the language is capable of doing.

This book is definitely worth the read if you are interested in learning JavaFX basics and beyond.

Thursday, January 24, 2008

EJB 3.1 - Significant Changes Sound Promising

Being a big fan of the EJB 3.0 specification, I read this new EJB 3.1 New Features article published by Serverside right away. Clearly, the current EJB spec is much simpler to use and maintain than previous generations. Building upon that logic, the upcoming EJB 3.1 specification looks even better.

Real quick, I just wanted to point two of the features I found most interesting about this article. First, it sounds like interfaces will be made optional. This could be viewed as a bonus or a downfall, depending upon the way you look at it. Certainly removing the need for interfaces will simplify the writing of EJB code immensely. However, the benefits of using the loose-coupled approach may make EJB more difficult in some circumstances. If you enjoy unit testing of EJB code, this may make a big difference. However, since the specification plans to make this an optional feature then it will leave the implementation to the coder. Therefore, this seems to be a feature that can greatly benefit those who do not wish to write EJB interfaces.

Second, the article briefly mentions support for stateful web services and EJB timer service enhancements to support scheduling and/or deployment-time timer creation. I will be interested to hear more about these.

Give the article a read if you are interested in EJB...it is worth the time.

Thursday, January 10, 2008

Oracle JDeveloper 11g Technology Preview 3 Released

I recently downloaded the new JDeveloper 11g Tech Preview 3 for my Mac, and I am impressed. While I primarily use Netbeans for Java application development, the JDeveloper IDE is great for developing PL/SQL and Java Stored Procedures.

All of the new features in this technology preview are amazing. I understand that if you develop Java applications within the JDeveloper IDE then there have been many enhancements and improvements as well. For instance, the SOA and Web Services modules have had some significant adjustments.

My primary use of the JDeveloper IDE is for PL/SQL and Java Stored Procedure development. If you are looking to create and/or maintain any PL/SQL, then this tool can help you greatly. The new editor is nice, package body and header separation is a plus, and the automatic SQL command window is nice to have. One no longer needs to open a SQL Worksheet to invoke an SQL statement, it opens automatically when a database connection is selected. Of all the great SQL IDEs available today, I do not think any are better than JDeveloper for managing Oracle Java Stored Procedures. Straightforward and easy to manage, developing Java Stored Procedures for the Oracle database has never been easier.

I recommend downloading the technology preview and giving it a try. Even if you do not develop any SQL or PL/SQL code, you may find that it has some nice features to benefit your Java development.

Tuesday, January 08, 2008

Glassfish - A Noteworthy Application Server

I've been running across quite a few blogs lately speaking about Glassfish. It appears that this great application server is being used by more people and gaining some real popularity. I've been using Glassfish since version one. Actually, prior to Project Glassfish, I used the Sun Java Application Server version 8.

I have nothing bad to say about Glassfish. It is an excellent choice for a JavaEE application server. Powerful and easy to use, this application server should not be overlooked if you are in the business of Java web development.

I have not yet tried out version 3, but I plan to do so very soon. I've been working primarily with Glassfish version 2 for the past few months. I've found it very easy to deploy JBOSS Seam applications to Glassfish even though there is no direct IDE deployment option for this setup as yet.

I will post any issues or concerns with using Glassfish V3 and JBOSS Seam...