{"id":62,"date":"2006-09-13T10:00:22","date_gmt":"2006-09-13T15:00:22","guid":{"rendered":"http:\/\/stein.everybody.org\/brain\/simple-jsf-spring-example\/"},"modified":"2011-03-10T10:57:31","modified_gmt":"2011-03-10T15:57:31","slug":"simple-jsf-spring-example","status":"publish","type":"post","link":"https:\/\/jeremystein.com\/brain\/simple-jsf-spring-example\/","title":{"rendered":"Simple JSF-Spring Example"},"content":{"rendered":"<p>If you want to see JSF and Spring working together, check out <a href=\"http:\/\/appfuse.dev.java.net\/\">AppFuse<\/a>.  But, AppFuse also uses acegi, hibernate, sitemesh, and a bunch of other little packages.  You probably should use most of them too, but you might not have realized it yet.  So, until you do, you could start with an absolutely bare bones Hello World project to help you jumpstart your configuration.  Here is my JSF-Spring Hello World example: <a href=\"http:\/\/stein.everybody.org\/brain\/wp-content\/jsf-spring-example.zip\">[download]<\/a>.<\/p>\n<p>You&#8217;ll need the latest versions of <a href=\"http:\/\/maven.apache.org\/download.html\">Maven<\/a> and <a href=\"http:\/\/tomcat.apache.org\/download-55.cgi\">Tomcat<\/a>.  Unzip.  Run &#8220;mvn&#8221;.  Drop the war (or exploded war) in Tomcat.  Start her up and hit <code>http:\/\/localhost:8080\/example\/test.faces<\/code>.  If you don&#8217;t understand those instructions, you came to the wrong place.  Try a <a href=\"http:\/\/bestwebbuys.com\/0596005636\" title=\"O'Reilly's Javaserver Pages\">JSP Book<\/a> or <a href=\"http:\/\/bestwebbuys.com\/193011012X\" title=\"Manning's Web Development With Java Server Pages\">two<\/a>.<\/p>\n<p>If you want to load it into MyEclipse 5, follow these instructions:<!--more--><\/p>\n<ol>\n<li><code>mvn compile<\/code> (if you haven&#8217;t already)<\/li>\n<li><code>mvn -Declipse.workspace=<\/code>&lt;path-to-eclipse-workspace&gt; <code>eclipse:add-maven-repo<\/code> (<a href=\"http:\/\/maven.apache.org\/guides\/mini\/guide-ide-eclipse.html\">see Maven Eclipse guide<\/a>).<\/li>\n<li><code>mvn eclipse:eclipse -DdownloadSources=true<\/code><\/li>\n<li>Open MyEclipse<\/li>\n<li>File > Import&#8230;, &#8220;Existing Projects into Workspace&#8221;, Pick the &#8220;example&#8221; directory you created, Finish<\/li>\n<li>Select the project and use the menu bar (or right click it and use the context menu), MyEclipse > Add WebProject Capabilities&#8230;, set the Web Root Directory to <code>\/src\/main\/webapp<\/code>, set the Web Context Root to whatever you want, do not create web.xml, do not add J2EE Libs to Buildpath.<br \/><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/jeremystein.com\/brain\/wp-content\/uploads\/2006\/09\/myeclipse_screen12.png\" alt=\"Add WebProject Capabilities screenshot\" width=\"546\" height=\"322\" \/><\/li>\n<li>MyEclipse > Add Spring Capabilities&#8230;, select no libraries, Next, Specify the existing configuration file: <code>src\/main\/webapp\/WEB-INF\/applicationContext.xml<\/code>, Finish.<\/li>\n<li>Backup web.xml<\/li>\n<li>MyEclipse > Add JSF Capabilities&#8230;, JSF Implementation: MyFaces 1.1.1, uncheck the Install checkboxes.<\/li>\n<li>Undo the change made by MyEclipse to web.xml (using the backup made earlier<\/li>\n<\/ol>\n<p>Note that if you change the dependencies, you&#8217;ll want to re-run <code>mvn eclipse:eclipse<\/code>.  This will mess up the build path configuration for MyEclipse.  MyEclipse likes to compile directly to the WEB-INF\/classes folder.  Maven doesn&#8217;t.  So, you&#8217;ll have to follow these steps:<\/p>\n<ol>\n<li><code>mvn eclipse:eclipse -DdownloadSources=true<\/code><\/li>\n<li>Open MyEclipse<\/li>\n<li>Right click the project > Build Path > Configure Build Path<\/li>\n<li>Uncheck &#8220;Allow output folders for source folders&#8221;<\/li>\n<li>Set the Default output folder to YourProjectName<code>\/src\/main\/webapp\/WEB-INF\/classes<\/code><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>If you want to see JSF and Spring working together, check out AppFuse. But, AppFuse also uses acegi, hibernate, sitemesh, and a bunch of other little packages. You probably should use most of them too, but you might not have realized it yet. So, until you do, you could start with an absolutely bare bones [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":0,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"wp:attachment":[{"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jeremystein.com\/brain\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}