<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Rodrigo Lazoti Blog</title>
	
	<link>http://www.rodrigolazoti.com.br/en</link>
	<description>Software development and technology in general</description>
	<lastBuildDate>Mon, 14 Dec 2009 17:41:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/RodrigoLazotiBlog2" /><feedburner:info uri="rodrigolazotiblog2" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Testing JavaEE 6 with Glassfish and Eclipse</title>
		<link>http://feedproxy.google.com/~r/RodrigoLazotiBlog2/~3/tx8XcX_4n0E/</link>
		<comments>http://www.rodrigolazoti.com.br/en/2009/12/12/testing-javaee-6-with-glassfish-and-eclipse/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 13:36:33 +0000</pubDate>
		<dc:creator>Rodrigo Lazoti</dc:creator>
				<category><![CDATA[Application Server]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JavaEE 6]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ejb]]></category>
		<category><![CDATA[glassfish]]></category>
		<category><![CDATA[javaee]]></category>
		<category><![CDATA[javaee6]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[stateful]]></category>
		<category><![CDATA[stateless]]></category>

		<guid isPermaLink="false">http://www.rodrigolazoti.com.br/en/?p=41</guid>
		<description><![CDATA[In this post, I&#8217;ll show some news of the Java EE 6. I&#8217;ll use the following softwares: Glassfish v3 Eclipse Galileo JEE Edition After install them, we go create a dynamic web project in the Eclipse called FirstProjectJEE6: Now, I&#8217;ll replace the contents of the web.xml file for this: &#60;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&#62; &#60;web-app xmlns=&#34;http://java.sun.com/xml/ns/javaee&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34;


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>In this post, I&#8217;ll show some news of the Java EE 6.<br />
I&#8217;ll use the following softwares:</p>
<p><a href="http://java.sun.com/javaee/downloads/index.jsp" target="_blank">Glassfish v3</a><br />
<a href="www.eclipse.org/" target="_blank"> Eclipse Galileo JEE Edition</a></p>
<p>After install them, we go create a dynamic web project in the Eclipse called FirstProjectJEE6:</p>
<p>Now, I&#8217;ll replace the contents of the web.xml file for this:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;web-app xmlns=&quot;http://java.sun.com/xml/ns/javaee&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
	xsi:schemaLocation=&quot;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&quot;
	version=&quot;3.0&quot;&gt;
	&lt;welcome-file-list&gt;
		&lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
		&lt;welcome-file&gt;index.htm&lt;/welcome-file&gt;
		&lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
	&lt;/welcome-file-list&gt;
&lt;/web-app&gt;
</pre>
<p>To compile our project, we need to add a external jar (javaee.jar) to the project, the jar file is in the path <strong>[glassfish_directory]/glassfish/lib/javaee.jar</strong></p>
<p>I&#8217;ll create a ant script to make the deploy of our application in glassfish. It must be saved in the project root and should be called build.xml</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project name=&quot;FirstProject JavaEE 6&quot; basedir=&quot;.&quot; default=&quot;deploy&quot;&gt;
	&lt;property name=&quot;warfile&quot; value=&quot;FirstProject&quot; /&gt;
	&lt;target name=&quot;create&quot;&gt;
		&lt;war destfile=&quot;${warfile}.war&quot; webxml=&quot;WebContent/WEB-INF/web.xml&quot; update=&quot;true&quot;&gt;
			&lt;classes dir=&quot;build/classes&quot; /&gt;
			&lt;fileset dir=&quot;WebContent&quot;&gt;
				&lt;exclude name=&quot;WEB-INF/web.xml&quot; /&gt;
			&lt;/fileset&gt;
		&lt;/war&gt;
	&lt;/target&gt;
	&lt;target name=&quot;copy&quot;&gt;
		&lt;copy todir=&quot;/Users/rodrigolazoti/Programs/glassfishv3/glassfish/domains/domain1/autodeploy&quot; overwrite=&quot;true&quot;&gt;
			&lt;fileset dir=&quot;.&quot;&gt;
				&lt;include name=&quot;*.war&quot; /&gt;
			&lt;/fileset&gt;
		&lt;/copy&gt;
	&lt;/target&gt;
	&lt;target name=&quot;deploy&quot;&gt;
		&lt;antcall target=&quot;create&quot; /&gt;
		&lt;antcall target=&quot;copy&quot; /&gt;
	&lt;/target&gt;
&lt;/project&gt;
</pre>
<p>Note that this path:<br />
/Users/rodrigolazoti/Programs/glassfishv3/glassfish/domains/domain1/autodeploy<br />
Should be replaced by the:<br />
[your glassfish]/glassfish/domains/domain1/autodeploy</p>
<p>Now, we let&#8217;s code a little, first we let&#8217;s create two EJB using the new specification.<br />
I&#8217;ll create one stateless and one staleful EJB, the stateful ejb will serve only to represent the number of requests and the stateless will serve to return a message to the User.</p>
<p>The code of stateless ejb:</p>
<pre class="brush: java;">
package br.com.rodrigolazoti.firstproject.service;

import javax.ejb.Stateless;

@Stateless
public class MyStatelessSessionBean {

	public String createMessage( String username ) {
		String message = &quot;Hello World, &quot;;

		if ( username != null &amp;&amp; !&quot;&quot;.equals( username.trim() ) ) {
			message += username + &quot;!&quot;;
		}
		else {
			message += &quot;stranger!&quot;;
		}

		return message;
	}

}
</pre>
<p>And the code of the stateful ejb:</p>
<pre class="brush: java;">
package br.com.rodrigolazoti.firstproject.service;

import javax.ejb.Stateful;

@Stateful
public class MyStatefulSessionBean {

	private int amountOfrequests = 0;

	public int getAmountOfrequests() {
		return ++amountOfrequests;
	}

}
</pre>
<p>Note that in both ejb, was not necessary to create a local or remote interface. <img src='http://www.rodrigolazoti.com.br/en/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>With our EJBs ready, we&#8217;ll create a servlet to respond to http methods: GET and POST.</p>
<pre class="brush: java;">
package br.com.rodrigolazoti.firstproject.controller;

import java.io.IOException;

import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.rodrigolazoti.firstproject.service.MyStatefulSessionBean;
import br.com.rodrigolazoti.firstproject.service.MyStatelessSessionBean;

@WebServlet( name = &quot;MyServlet&quot;, urlPatterns = { &quot;/hello&quot; } )
public class MyServlet extends HttpServlet {

	private static final long serialVersionUID = -2206981309178199835L;

	@EJB
	private MyStatefulSessionBean myStatefulSessionBean;

	@EJB
	private MyStatelessSessionBean myStatelessSessionBean;

	@Override
	protected void doGet( HttpServletRequest request, HttpServletResponse response )
			throws ServletException, IOException {
		String message = myStatelessSessionBean.createMessage( null );
		request.setAttribute( &quot;message&quot;, message );

		int amountOfRequests = myStatefulSessionBean.getAmountOfrequests();
		request.setAttribute( &quot;amountOfRequests&quot;, amountOfRequests );

		request.getRequestDispatcher( &quot;/hello.jsp&quot; ).forward( request, response );
	}

	@Override
	protected void doPost( HttpServletRequest request, HttpServletResponse response )
			throws ServletException, IOException {
		String username = request.getParameter( &quot;username&quot; );
		String message = myStatelessSessionBean.createMessage( username );
		request.setAttribute( &quot;message&quot;, message );

		int amountOfRequests = myStatefulSessionBean.getAmountOfrequests();
		request.setAttribute( &quot;amountOfRequests&quot;, amountOfRequests );

		request.getRequestDispatcher( &quot;/hello.jsp&quot; ).forward( request, response );
	}

}
</pre>
<p>And finally, we&#8217;ll create our jsp files. The index.jsp file will make the calls to the servlet and the hello.jsp file will show the result of calls.</p>
<p>The index.jsp file:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot; pageEncoding=&quot;ISO-8859-1&quot;%&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
  &lt;meta name=&quot;author&quot; content=&quot;Rodrigo Lazoti&quot;/&gt;
  &lt;title&gt;First Java EE 6 Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;p&gt;&lt;a href=&quot;hello&quot;&gt;Execute Servlet (GET)&lt;/a&gt;&lt;/p&gt;

  &lt;hr width=&quot;100%&quot; noshade=&quot;noshade&quot;/&gt;

  &lt;form action=&quot;hello&quot; method=&quot;post&quot;&gt;
    &lt;p&gt;Name:&lt;input type=&quot;text&quot; name=&quot;username&quot;/&gt;&lt;/p&gt;
    &lt;p&gt;&lt;button type=&quot;submit&quot;&gt;Execute Servlet (POST)&lt;/button&gt;&lt;/p&gt;
  &lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>And the hello.jsp file:</p>
<pre class="brush: xml;">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot; ?&gt;
&lt;%@ page language=&quot;java&quot; contentType=&quot;text/html; charset=ISO-8859-1&quot; pageEncoding=&quot;ISO-8859-1&quot;%&gt;
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
  &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=ISO-8859-1&quot; /&gt;
  &lt;meta name=&quot;author&quot; content=&quot;Rodrigo Lazoti&quot;/&gt;
  &lt;title&gt;First Java EE 6 Example&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
  &lt;h2&gt;Result: ${requestScope.message}&lt;/h2&gt;&lt;br/&gt;
  &lt;h3&gt;This servlet was executed ${requestScope.amountOfRequests} time(s).&lt;/h3&gt;&lt;br/&gt;
  &lt;hr width=&quot;100%&quot; noshade=&quot;noshade&quot;/&gt;
  &lt;h4&gt;&lt;a href=&quot;index.jsp&quot;&gt;Back to main page&lt;/a&gt;&lt;/h4&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Some news that I used this example:</p>
<ul>
<li>Local business interfaces are optional in EJB 3.1.</li>
<li>In EJB 3.1, you can place enterprise bean classes in the .war file along with web tier components. You don&#8217;t have to put EJB classes in the ejb-jar file.</li>
<li>Annotations can now be used in more types of Java EE components. And the set of annotations used for dependency injection has been standardized.</li>
<li>Instead of creating deployment descriptors, you can annotate classes to specify servlet-related deployment information.</li>
</ul>
<p>This example is available at github: <a href="http://github.com/rlazoti/tutorial-javaee6-first-project" target="_blank">http://github.com/rlazoti/tutorial-javaee6-first-project</a></p>

<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>

<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/RodrigoLazotiBlog2/~4/tx8XcX_4n0E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rodrigolazoti.com.br/en/2009/12/12/testing-javaee-6-with-glassfish-and-eclipse/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.rodrigolazoti.com.br/en/2009/12/12/testing-javaee-6-with-glassfish-and-eclipse/</feedburner:origLink></item>
		<item>
		<title>[Video] Testing the Chromium OS in Virtual Box</title>
		<link>http://feedproxy.google.com/~r/RodrigoLazotiBlog2/~3/JP2IuRgZqv8/</link>
		<comments>http://www.rodrigolazoti.com.br/en/2009/12/09/video-testing-the-chromium-os-in-virtual-box/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 01:52:14 +0000</pubDate>
		<dc:creator>Rodrigo Lazoti</dc:creator>
				<category><![CDATA[Chromium OS]]></category>
		<category><![CDATA[operational system]]></category>
		<category><![CDATA[chromium]]></category>
		<category><![CDATA[goggle]]></category>
		<category><![CDATA[os]]></category>
		<category><![CDATA[virtual box]]></category>
		<category><![CDATA[virtual machine]]></category>

		<guid isPermaLink="false">http://www.rodrigolazoti.com.br/en/?p=32</guid>
		<description><![CDATA[Like most people, I also wanted to know about the new operating system Google&#8217;s Chromium OS, then in a quick search I found a link to download a virtual machine with Virtual Box Chromium OS. An interesting point about the new OS is that logging in, you must have a Gmail account. The link to


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Like most people, I also wanted to know about the new operating system Google&#8217;s Chromium OS, then in a quick search I found a link to download a virtual machine with Virtual Box Chromium OS.</p>
<p>An interesting point about the new OS is that logging in, you must have a Gmail account.</p>
<p>The link to download the VM is <a href="http://www.ausgamers.com/news/read/2816103" target="_blank"> http://www.ausgamers.com/news/read/2816103</a></p>
<p>I made a video showing how to use the VM in Virtual Box.</p>
<div style="text-align: center;"><object type="application/x-shockwave-flash" data="http://www.youtube.com/v/g5my_CyRuKc&#038;fs=1" width="425" height="344"><param name="movie" value="http://www.youtube.com/v/g5my_CyRuKc&#038;fs=1" /><param name="FlashVars" value="playerMode=embedded"/><param name="wmode" value="transparent"/></object></div>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/RodrigoLazotiBlog2/~4/JP2IuRgZqv8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rodrigolazoti.com.br/en/2009/12/09/video-testing-the-chromium-os-in-virtual-box/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.rodrigolazoti.com.br/en/2009/12/09/video-testing-the-chromium-os-in-virtual-box/</feedburner:origLink></item>
		<item>
		<title>Now i’ll write in English too</title>
		<link>http://feedproxy.google.com/~r/RodrigoLazotiBlog2/~3/ityfQEsqXz0/</link>
		<comments>http://www.rodrigolazoti.com.br/en/2009/11/27/now-ill-write-in-english-too/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 15:56:52 +0000</pubDate>
		<dc:creator>Rodrigo Lazoti</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.rodrigolazoti.com.br/en/?p=7</guid>
		<description><![CDATA[Hello world! After some time, finally I decided to write in English. First because I need to improve my writing, second because writing in English I can reach a larger audience and thus share information with more people around the world and not only from Brazil. Outside the new posts, I want to translate some


No related posts.

Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Hello world! <img src='http://www.rodrigolazoti.com.br/en/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>After some time, finally I decided to write in English.<br />
First because I need to improve my writing, second because writing in English I can reach a larger audience and thus share information with more people around the world and not only from Brazil.</p>
<p>Outside the new posts, I want to translate some old posts written in Portuguese to English too.<br />
If you want the translation of some post, let me know ok.</p>
<p>Please, if you find any grammatical error in my posts, i&#8217;d like to get your fix. <img src='http://www.rodrigolazoti.com.br/en/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a>.</p><img src="http://feeds.feedburner.com/~r/RodrigoLazotiBlog2/~4/ityfQEsqXz0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.rodrigolazoti.com.br/en/2009/11/27/now-ill-write-in-english-too/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.rodrigolazoti.com.br/en/2009/11/27/now-ill-write-in-english-too/</feedburner:origLink></item>
	</channel>
</rss>
