Skip to main content

jjviana's Blog

My JavaOne 2011 Presentation

Posted by jjviana on October 6, 2011 at 2:21 PM PDT

My JavaOne talk about Apache Wicket went really well: the room was almost full, lots of interesting questions and I met a lot of nice people. Thanks to all atendees!

You can find the presentation in the link below:

http://prezi.com/jpbpmjzc1ryr/productively-fun-web-development-with-apache-wicket-and-java-ee-6-v3/

 

 

Related Topics >>

Bean Validation with Apache Wicket

Posted by jjviana on October 5, 2011 at 6:13 PM PDT

Some Wicket goodies for my JavaOne talk.

If you go to my JavaOne 2011 talk "Productively Fun Web Development with Apache Wicket and Java EE 6" you will see a demo where Bean Validation is used in conjunction with Apache Wicket.

In order to accomplish that, all that you need is a single Java class that bridges the Wicket validation framework and the JSR 303 validation engine.

I am posting here not only this bridge class (JSR303Validator) but also two other utility classes: ValidationStyleBehaviour and BaseEntityForm.

ValidationStyleBehaviour is a Wicket behaviour that displays form component erros messages close to the form component itself, instead of in a FeedbackPanel.

BaseEntityForm is a Wicket Form that uses any class anotated with Bean Validation annotations and uses JSR303Validator and ValidationStyleBehaviour in every form field, so that the resulting form validates according to the constraints expressed by the annotations and renders validation messages nicely.

The results can be seen below:

 

You can download the code here.

 

AttachmentSize
JSR303Validation.zip3.04 KB
RegisterFormValidation.png121.63 KB

JavaOne Day 1: don´t be Pwned!

Posted by jjviana on October 4, 2011 at 12:14 AM PDT

There is one talk I would like to comment on today: "Don't Be Pwned: A Very Short Course on Secure Programming in Java".

This talk, presented by Robert Seacord  and Dean Sutherland from SEI/CERT, was the scariest Java talk I have ever been to.

Do you believe the software you write is secure enough?  Believing it or not, I suggest you take some time to read through the CERT Oracle Secure Coding Standard for Java. It is a guide prepared by the guys at CERT that describe the main concerns you should have when writing secure code in Java. Or to put it in another way, it describes the many ways you are probably writing insecure code right now.

I never imagined how dangerous class inheritance can be in bypassing security managers, or how simple it is to crash most JVM versions by feeding them specially crafted floating-point numbers. Even if you don´t memorize all the guide rules, reading it is definitely an eye opener.

This will be required literature for all my team members and students from now on.

 

 

JavaOne Day 0: Glassfish Community Event

Posted by jjviana on October 2, 2011 at 11:49 PM PDT

JavaOne started for me today with the Glassfish Community Event.

It was a nice opportunity to meet the Glassfish Development Team as well as people I have interacted with but not met in person until today.

The event, as well as the community party afterwards, had more people than last year. That is also my perception for the entire conference: there are more people attending this year than in the last year. If that is true or just my impression is something that only the conference organizers will be able to answer. The Java community seems, at least in numbers, to be stronger than ever...

From the information provided at the event, I can tell you that Java EE 7 and Glassfish are moving towards the Cloud: the next version of Glassfish (Glassfish 4) will have support for managing Glassfish on virtualized environments and will support multi-tenant applications as per the Java EE 7 spec.

There were many customer testimonials about how Glassfish is performing in production environments. Common themes: the high performance of the web stack (Grizzly) and the poor formatting of the server log messages.

 Looking forward to the JavaOne keynote tomorrow...

Related Topics >>

Heroku Java Support: Simple? or Simplistic?

Posted by jjviana on August 29, 2011 at 12:58 PM PDT

Heroku, the PaaS cloud owned by salesforce.com, announced a few days ago support for the Java language. In the process they declared Java EE to be irrelevant in the cloud world. Is that so?

I try to embrace anything that helps me develop, test or deploy code faster. Cloud Computing has the potential to bring radical improvements to all these areas, hence I have been following its developments closely over the last couple of years.

Cloud platforms come in different flavours, the main ones being IaaS (Infrastructure as a Service) an PaaS (Platform as a Service). IaaS clouds, like Amazon EC2 or Rackspace Cloud, provide infrastructure building blocks (CPUs, storage space, ip addresses, firewalls, etc.) in a programatic way. In a way, they transform infrastructure in code. You can then lay the software stack you need over these building blocks: operating systems, databases,virtual machines, programming languages etc. Lots of decisions to make.

PaaS clouds, like Google AppEngine or Heroku, would like to make some of these decisions for you.They restrict the menu of available stack components to a few supported configurations. In return, they relief you from the burden of having to manage these components. You stop thinking about "servers" and think instead about "applications" , "components" or other logical deployment units.

I am a big fan of IaaS clouds, but have yet to be convinced of the usefulness of PaaS. Take Heroku for example: their announcement about Java support revolves around the revolutionary idea of embedding Jetty inside your application so that your web application contains the web server, and not the other way around. They go to some lengths in criticizing Java EE for its complexity and to show how this containerless approach is going to make your life easier.

The problem is, this approach is not new: I have personally written applications using this architecture for a while now, going as far back as 2002. The idea of going containerless has a certain lure, but as the application grows  you start to realize its drawbacks. The moment you need a connection pool, or  transaction control, or manageability, or security, you start to recreate the container inside your application, one third-party library at a time. Fast forward a few releases and now your application is a collection of 150Mb of conflicting jar files.You have recreated something like the Java EE container inside your application, at a great cost and zero standardization.

PaaS vendors: as a User, I don´t want my platform to be simple, I want it to make my life simpler. These are different goals.

Simple != Simplistic.

 

 

 

Related Topics >>

Comments

Funny -- the pot calling the kettle black :-). It seems to ...

Funny -- the pot calling the kettle black :-). It seems to me that PaaS is yet to have much relevence to server-side Java :-). The same goes for supposed Spring "simplicity" as compared to Java EE :-).

Hmm... with the premise that whenever a service vendor ...

Hmm... with the premise that whenever a service vendor quickly dismisses something else's technology as irrelevant I get annoyed, I must say that the scenario is interesting.

Some time ago I would totally agree with you. Today I'm puzzled and probably very soon I won't agree. Or probably it's the matter to better define the context.

The moment you need a connection pool, or  transaction control, or manageability, or security, you start to recreate the container inside your application, one third-party library at a time.

You don't need to reinvent this stuff, as e.g. Spring provides all what you need. For small applications, you're effectively going simpler if you don't put into your project what you don't need.

Fast forward a few releases and now your application is a collection of 150Mb of conflicting jar files. You have recreated something like the Java EE container inside your application, at a great cost and zero standardization.

True (apart from the "zero standardization" with isn't true if you go the Spring way). Summing up, this to me means that there are situations in which Heroku-like approach makes sense, and a threshold in which you start to lose the advantage, and Java EE is a viable approach.

Giving that IT is spreading and there are more and more simple webapps, in addition to the old, corporate-style ones, I think that Oracle should really care of this, anyway.

Hi Fabrizio, Spring is nice, but its not really a ...

Hi Fabrizio,

Spring is nice, but its not really a standard...Currently it is a VMWare product. You can pick and choose what you need from it, but the problem is evolution - as I said, as the application grows it becomes more and more bloated with third-party dependencies that implement common services. I have had sutiations where one third-party framework would depend upon a specific version of a library (like ASM) and another one would require a newer version of the same library, which would then bring on its own set of dependencies... commonly known as Classpath Hell.

Maybe the situation is different for web applications - but Java EE has already acknowledged this fact in the form of the Web Profile, aimed at simpler applications. And I have difficulty separating Web Applications from Enterprise Applications: in my experience most Enterprise applications are born as Web Applications that over time become central to the business. Where does one draw the line?

 

It's not a standard as a specification, but it's a set of ...

It's not a standard as a specification, but it's a set of standard knowledge. I mean, if people want to do transactions with Spring, there's a small set of "standard" ways to do that in Spring.

The classpath hell can be a problem, right. It's when the application grows up in complexity. As I said, it makes sense that the gap between the "simpler" approach of Spring and Java EE shrinks to zero for complex applications. But there is a growing room for simpler applications around.

small typo:  "this approach is now new" ...

small typo:
"this approach is now new" => " this approach is not new" (somehow I make that mistake often myself)
I think it's hard to disagree with you about the services that eventually every PaaS service will need to offer.
I suppose the debate is more around the programing model and I'm hoping that we can still work with Heroku on Java EE (after all they've dismissed J2EE, an ancient technology :)

Thanks for the tip! Thats what you get when you try to write ...

Thanks for the tip! Thats what you get when you try to write too fast :)

 

 

Hi Juliano. Note that there's nothing named ...

Hi Juliano.

Note that there's nothing named "JEE". You probably meant "Java EE".

Bill Shannon

Java EE Spec Lead

http://www.java.com/en/about/brand/naming.jsp
http://www.theserverside.com/news/thread.tss?thread_id=35561

Hi Juliano. Note that there's nothing named ...

Thanks for the tip!

Fixed.

GlassFish Webcast Series: Java EE 6 e GlassFish Server 3.1: Simplicidade + Leveza = Produtividade

Posted by jjviana on June 14, 2011 at 5:03 AM PDT

Next week I will be presenting a free webinar about Java EE 6 and Glassfish 3.1.

The title can be translated to English as: "Java EE 6 and Glassfish 3.1: Simplicity + Ligthness = Productivity". The reason the title is in Portuguese is because this will be a webinar targeted at Brazilian Java EE and Glassfish users - as far as I know it will be the first webinar in Portuguese on these topics.

It will be based on a talk I gave at JustJava 2011 conference in São Paulo but will also have new content. I will talk about the new and cool features of Java EE 6 and how Glassfish enables developers to take advantage of these new features to buid applications that are at the same time lightweight and highly available. The Glassfish part will focus on the new features in glassfish 3.1: clustering, high-availability and centralized management.

The webinar will take place on Wednesday, June 22 2011 14:00 Brazilian time (10:00 a.m. PT / 1:00 p.m. ET / 19.00 CT ).

Registration is free but space is limited - you can register by following this link.

Many thanks to Alexandra Huff ( Principal Product Manager @ Oracle Glassfish) for making this webinar possible, and to Arun Gupta for introducing me to the Glassfish team a few months ago.

RainToolkit 1.3 is available

Posted by jjviana on April 4, 2011 at 10:19 AM PDT

Just a quick note to annountce the availability of RainToolkit 1.3.

It can be downloaded at:  http://www.logicstyle.com/raintoolkit.html

If you manage Amazon EC2 resources from the command-line, Rain Toolkit can make your life easier by automating a lot of common repetitive tasks.

New features in this release include:

  • Support for micro instances
  • Support for EBS instances
  • Support for Amazon Virtual Private Cloud (VPC)

Rain Toolkit is written in Java, using the AWS Java SDK and is released under the GPL v2 license.

 

Related Topics >>

expert-in-tech.com = Consulting as a Service

Posted by jjviana on February 16, 2011 at 3:08 PM PST

I know what you are thinking...consulting has always been a service. But the Cloud is making it evolve.

Cloud Computing has been one of my favourite topics in the last couple of years. Coming from a sysadmin background I am frequently in awe of how easy it is nowadays to conjure up vast amounts of computing and storage resources out of thin air. Of course I know that its not "out of thin air" ... behind the scenes there is a lot of powerful hardware, hard working people and clever software that makes it all possible. Some people say that Cloud Computing is just a bunch of computers connected to a network, but I disagree: I believe it represents a fundamental shift in how we approach computing.

Consulting, on the other hand, has been my main professional activity for the last couple of years. I love doing it but sometimes I feel it is too bureaucratic for the customers to hire a consultant: what you need is someone who can help you get your problem solved quickly, but you end up having to mess with quotations, contracts, physical access permissions etc.

Wouldn´t it be nice if you could conjure up a consultant in an as-needed basis in the same way as you can with hardware and software?

 

We at Logicstyle believe it would, and this is why we have created Expert-in-Tech . This is an online consulting branch which will provide on-demand consulting services in a wide range of technologies: Java SE, Java EE, open source frameworks, commercial and open source application servers, commercial and open source databases and operating systems. You can create support tickets on demand and choose a support level that better suits your needs.

So if you have a tricky problem, need an urgent patch for an open source project you use or have a task you are just too busy to deal with right now, give Expert-in-Tech a try. We look forward to working with you!

Please send any suggestions or comments about the service to contact at expert-in-tech.com

 

 

 

Related Topics >>

mvn classpath:hell

Posted by jjviana on December 14, 2010 at 10:12 AM PST

Apache maven is supposed to solve the classpath hell; or so I´ve been told...

Started using maven 2 in a multi-pom project. One of the requirements is to be able to deploy EAR files to Weblogic.

After looking around it seemed like the most stable way of doing this with maven and Weblogic 10.x is to use the Weblogic Ant task. Not ideal since we are migrating away from Ant, but still okay.

So I happily added the maven antrun plugin to my pom.xml file:

 <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.6</version>

        <executions>
          <execution>
            <phase>integration-test</phase>
            <configuration>
              <tasks>
                 <path id="wlappc.classpath">
                <fileset file="${wlFullClient}" />
        </path>

            <taskdef name="wldeploy"
              classname="weblogic.ant.taskdefs.management.WLDeploy"
            classpathref="wlappc.classpath" />
         <wldeploy action="deploy" verbose="true" debug="true"        
           upload="true" name="Myapp" source="myservice-ear-1.0-SNAPSHOT.ear"
           user="${deployUser}" password="${deployPassword}" adminurl="${deployURL}" targets="${deployTargets}" />

           ...

Great! Now I can easily deploy my ear file before the integration tests are run.

But now, after all tests are run and Maven then tries to deploy the generated artifact to the remote repository, it fails with the misterious error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error deploying artifact: Failed to transfer file: http://172.30.12.31:8081/nexus/content/repositories/snapshots/groupid/gr.... Return code is: 401

After a few hours of debugging the repository user permissions and the repository installation itself (http error 401 is a permission denied error after all) I was almost giving up hope when it occurred to me to test disabling the antrun plugin execution. Suddently the repository deployment started working again.

It turns our there is something in wlfullclient.jar (the weblogic admin client used by the ant task) that is messing up with the maven deployment plugin. Since there is no way to isolate the classpath between the plugins I had to choose to either deploy to the integration application server or to deploy to the remote repository. I ended up choosing (for now) disabling the remote repository deployment for the EAR artifact:

 <plugin>
               <artifactId>maven-deploy-plugin</artifactId>
               <configuration>
                 <skip>true</skip>
              </configuration>
            </plugin>

   <plugin>

This is hardly an appropriate solution, as now I have to manually manage the copy of these files to the production system.

For a build system that is supposed to get rid of the classpath hell, Maven is turning out to be for me a classpath devil itself (that is not my first classpath problem with Maven ).

 

Related Topics >>

Comments

mvn classpath:hell

I use the antrun plugin in one of my projects and it does not give troubles. So there must be another evil interaction.
In order to mitigate your workaround, do you have considered to use profiles? You can have the default profile e.g. that deploys locally and a specific profile that deploys remotely, alternatively excluding the offending stuff. In this way you can do both things, even though not at the same time, without constantly changing the POM.
PS There's nothing necessarily wrong in using Ant with Maven, if Ant is confined within a single goal - in other words, it's not a strange hybrid because the build system is really still the Maven workflow, and it's not "polluted" by Ant. With this usage, Ant is just a script interpreter, much like you were using a Maven plugin written in Groovy or such.

mvn classpath:hell

Interesting idea about using profiles. I will give it a try.
The problem is not with the antrun plugin itself . Rigorous investigation has proven that it is related to the wlfullclient jar file being loaded in the JVM maven is running in.
After executing any antrun target that uses the task defined in this file, all subsequent modules in the reactor fail to deploy with the HTTP 401 error.
It would not happen is maven kept each plugin on its own classloader. As it is seems like all plugins execute under the same classloader, which given the distributed nature of the plugin providers is bound to cause this type of clash.

mvn classpath:hell

Further testing shows it seems to have nothing to do with the wlfullclient.jar - just using the antrun plugin in a project seems enough to trigger the problem.
Tested with maven 2.2.1 . Will try 3.0 now.

mvn classpath:hell

It does happen with 3.0 also....
But it looks like it really depends on the loading of some classes in wlfullclient.jar. Argh....

Maven: the classpath devil

Goodness; try http://cargo.codehaus.org/--it looks like it supports WebLogic 10+.
Best,
Laird

Maven: the classpath devil

I considered Cargo, but it only supports local deployment to Weblogic, and in this customer we need remote deployment.
There is also a Weblogic maven plugin, but its quite old and reported to be unstable with 10.x.

Maven: the classpath devil

It shouldn't be difficult to extend Cargo to support remote deployment to WebLogic - please submit a patch if you really need that functionality. :) The codebase is really easy to understand and extend.
I submitted a patch to the Cargo team earlier this year to allow configuring JNDI properties in a Jetty deployment via Maven. They took the patch and it was in the trunk within a few hours of submitting it.

A global Glassfish outage

Posted by jjviana on November 10, 2010 at 2:53 PM PST

One of the exciting things about teaching is the fact no matter how well you prepare for a class, events will always surprise you.Yesterday I was caught by surprise in the middle of a class by what seemed like a global Glassfish admin console outage.

I was teaching my Software Architecture students at IGTI how to change the default maximum thread pool size for the HTTP listener in Glassfish 3.0.1. We needed to do that in order to run a JMeter load test against our example application. The default maximum thread pool size in Glassfish is just 5 threads, which makes it impossible to stress the system with a decent  number of concurrent users.

I tried to access the Glassfish admin console on http://localhost:4848 on my notebook. It started loading but hang after the "Admin Console is starting..." screen. Restarted Glassfish, no change.

So I thought: "well, my Glassfish instance must be broken somehow". Tried it on a student notebook, same thing: admin console would still failed to load.

Switched to a remote virtual desktop(Ubuntu Lucid) running on Amazon EC2, started Glassfish, tried to load management console. Same result, hangs after the starting screen.

Luckily we had a coffee break coming up so I sent the students to eat something while I tried to figure out what was going on. What could possibly have broken admin console in 4 Glassfish instances running under two operating systems (Windows and Linux) in two different countries (Brazil and USA)?

My sysadmin years taught me to look for the network whenever something stops working without any apparent reason. So I ran netstat and found some suspicious connections from the Glassfish process  to *pkg.sun.com hosts. So I remembered that admin console has an auto-update feature. Maybe that had something to do with the failure to load?

To test this theory I disconnected my notebook from the network, restarted Glassfish and tried http://localhost:4848 again. Loaded promptly, worked like a charm. So I explained my students why Glassfish was behaving like that and told them to try the same solution on their notebooks. It worked for everyone so we were able to go on with the class.

What I explained to the students was this: admin console must be trying to check for updates while loading. If it cant connect to the update server (a fast kind of failure) it ignores the error and finishes loading. No problem there, only a few seconds lost. But when it can connect to the update server and the server is just not responding (a slow kind of failure) then it will wait forever for a reply and hence not finish loading.

This kind of unintended coupling is not uncommon in networked applications. But when it happens on something as big as Glassfish is gets kind of scary. I wonder how many other users where scratching their heads just then, wondering what was going on with their servers.

But this event, unpredictable as it was, presented me with the opportunity to teach one more Software Architecture lesson to my students: if your application uses a Cloud service, its better be prepared for the service to fail in all sorts of unexpected ways.

 

Comments

A global Glassfish outage

Juliano:
I'm Antonio Ortega from Mexico City, I'm new in java, i develop in many lagnuages but at this time I want to develop a cliente server app (CRUD) I'm using Netbeans IDE 6.9.1, glasfish 3.0 y mysql.
I can not find any simple sample to connect awt components with a mysql database.

Do you have any sample to see how can I do that.

Thanks in advanced.

A global Glassfish outage

Thanks Juliano!
Filed a bug at https://glassfish.dev.java.net/issues/show_bug.cgi?id=14699 for tracking purpose.