Feeds

Categories

Archives

Spring MVC Step-by-Step Tutorial ported on NetBeans/GlassFish

I was recently using the 1.1 release of Craig MacKay’s Spring Module for NetBeans which supports the latest Spring Framework 2.5. Spring Framework tutorial hosted at NetBeans.org provides details on how to use this module in NetBeans IDE. Thomas Risberg’s Developing a Spring Framework MVC Application Step-by-Step tutorial is a good one which explains end-to-end web application development using Spring Framework 2.5. The sample in this tutorial was developed using Eclipse 3.3 and the application was deployed to Apache Tomcat 6.0.14. Spring supports JEE technologies, this sample application should run on any JEE compatible servers without much porting effort. I was able to run this tutorial using NetBeans IDE 6.0 and GlassFish V2 UR1 without any hassle. In fact, this combination worked out great for me with Craig MacKay’s plugin. A very useful plugin for Spring development on NetBeans IDE. I modified the original tutorial to use NetBeans and GlassFish infrastructure, and these tools should definitely help increase the productivity for Spring developers.

You can access the tutorial “Developing a Spring Framework MVC application step-by-step using NetBeans and GlassFish” here.

[Update: 11/09/09 - NetBeans wiki is missing the tutorial page since their recent migration to the new NetBeans.org infrastructure. I have removed the original redirect to the NB wiki, so you could access the tutorial directly from my website. The project can be downloaded from here].

Possibly Related Posts:


Share and Enjoy:
  • Print
  • Digg
  • StumbleUpon
  • del.icio.us
  • Facebook
  • Yahoo! Buzz
  • Twitter
  • Google Bookmarks

27 comments to Spring MVC Step-by-Step Tutorial ported on NetBeans/GlassFish

  • Michael

    Hello,

    thanks a lot for this tutorial.

    BTW: I can’t deploy the project at “4.6. Adding a form controller”. In your example of ‘springapp-servlet.xml’ I have to change each occurrence of ‘springgfapp’ to ‘springapp’ to make it work.

    bye ;O)
    michael

  • Michal,

    I am happy this tutorial was useful to you. The typos have been fixed now in the NetBeans community site.

    Thank you,
    Arul

  • coolPB

    hello,

    It seems the path for the tutorial “Developing a Spring Framework MVC Application Step-by-Step” has been changed. Could anyone please provide the updated path for this link.

    Thanks

  • Hi,

    I fixed the broken link. The original link seems to have changed recently.

    Thanks,
    Arul

  • saint

    I am currently doing the tutorial. Thank you very much for this tutorial.
    I am stuck in the part 5.5 of the tutorial. Instead of using hsqldb, i am using mysql (it should not make a difference).

    when i running the test i am getting the following error:
    22/08/2008 10:47:57 org.springframework.test.AbstractSingleSpringContextTests loadContextLocations
    INFO: Loading context for locations: classpath:test-context.xml
    22/08/2008 10:47:57 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [test-context.xml]
    22/08/2008 10:47:57 org.springframework.test.AbstractSingleSpringContextTests loadContextLocations
    INFO: Loading context for locations: classpath:test-context.xml
    22/08/2008 10:47:57 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [test-context.xml]

    it does not seem to find where the classpath:text-context.xml is located.

    Any suggestions will be greatly appreciated.

    thanks

  • Did you create the test-context.xml as mentioned in section 5.5?

    By looking at your logs, it seems Spring has loaded test-context.xml successfully from the classpath. Did you modify the jdbc.properties matching MySQL driver info?

    Are you getting any specific errors?

    -Arul

  • saint

    thanks Arul for your reply.
    i have included the test-context.xml.

    instead of using jdbc.properties, i have hard-coded the values in the the xml file
    eg

    and commented out the propertyConfigurer.(hope it is ok to do that).

    So i got the error that i mentioned in my earlier post.

    I changed the getConfigLocations() in the JdbcProductDaotests.java from “classpath:test-context.xml”

    to

    protected String[] getConfigLocations() {
    return new String[] {“springapp/test/test-context.xml”}; }

    i got a new set of error:

    INFO: Loading XML bean definitions from class path resource [springapp/test/test-context.xml]
    25/08/2008 14:48:52 org.springframework.context.support.AbstractApplicationContext prepareRefresh
    INFO: Refreshing org.springframework.context.support.GenericApplicationContext@3570b0: display name [org.springframework.context.support.GenericApplicationContext@3570b0]; startup date [Mon Aug 25 14:48:52 GMT+10:00 2008]; root of context hierarchy
    25/08/2008 14:48:52 org.springframework.context.support.AbstractApplicationContext obtainFreshBeanFactory
    INFO: Bean factory for application context [org.springframework.context.support.GenericApplicationContext@3570b0]: org.springframework.beans.factory.support.DefaultListableBeanFactory@cfec48
    25/08/2008 14:48:53 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
    INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@cfec48: defining beans [productDao,dataSource,transactionManager]; root of factory hierarchy
    PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property ‘driverClassName’ threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not load JDBC driver class [com.mysql.jdbc.Driver]; nested exception is java.lang.ClassNotFoundException: com.mysql.jdbc.Driver)
    25/08/2008 14:48:53 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
    INFO: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@cfec48: defining beans [productDao,dataSource,transactionManager]; root of factory hierarchy

    thanks

  • saint

    the database bean was not posted in the last post

    thanks

  • saint

    i still can’t get the datasource bean to be displayed in the post so the values are:

    driverClassName –> com.mysql.jdbc.Driver
    url –> jdbc:mysql://localhost:3307/springwebapp
    username –> root
    password –> admin

    so i have hardcoded the values in the test-context.xml rather than use jdbc.properties

    thanks

  • Did you add mysql JDBC driver to your classpath?

    -Arul

  • saint

    Hi Arul,
    i have finally fixed the problem. Forgot to add the mysql-connector jar file to the library.

    I got the whole tutorial running.

    thank you very much for the tutorial

    cheers

    :-)

  • saint

    oops! just saw your much now

  • Nice to hear things worked for you.

    -Arul

  • saint

    Hi Arul,

    I am trying to use hibernate to access the database rather than JDBC. I am using Netbeans 6.5 so i have created a hibernate.cfg.xml that lists all my database properties.
    i have also created a HibernateUtil.java for my sessionfactory.

    i do not know how to wire it in my xml files. Please advice.

    Also do you know of any spring mvc hibernate tutorials (hopefully in netbeans) that i can do?

    thanks

  • Your best shot would be to look at the PetClinic sample bundled with Spring 2.5.5. It demonstrates data access strategies such as JDBC, Hibernate and JPA.

    Let me know if you have any specific questions.

    -Arul

  • Tatyana

    Thank you very much for your version of Spring tutorial!
    I found it on NetBeans Wiki and it is really work – regardless transfer all steps to Eclipse and MYSQL.
    I am absolutely newbie in this field – much more even my experience in Java is only 2 week long. And English is not my native language (please, sorry for mistakes).
    But I was so impressed of your easy and teachable manner that now I am going to look for your other articles and tutorials.
    Thank you, thank you, thank you.

  • Nice to hear this tutorial was useful to you.

    -Arul

  • Brian

    Is there anywhere I can find a tutorial on how to use the annotations features for spring 2.5 – all I can find is incomplete information.

  • Hi Brain,

    I would suggest you to look at the Spring documentation[1] on MVC annotations and Juergen’s blog entry [2] on Annotated Web MVC controllers in Spring 2.5.

    What exactly you are looking for?

    -Arul

    [1] http://static.springframework.org/spring/docs/2.5.x/reference/mvc.html#mvc-annotation
    [2] http://blog.springsource.com/2007/11/14/annotated-web-mvc-controllers-in-spring-25/

  • Harish Vembu

    Thanks for the tutorial.

    For the impatients like me , Link below is not working …..

    Download springapp NetBeans Project for the impatient ::::

    http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=5171

    Please check and let me know for the benefit of readers.

    Best Regards

    Harish

  • Hi Harish,

    Unfortunately the NetBeans plugin site is currently down. You can grab a copy of the project from here.

    Cheers,
    Arul

  • thantzawmyint

    netbean don’t use hibernate Spring MVC

  • nice! thank you so much!

  • Hi, I’m using Netbeans 6.8 but am sure it doesn’t matter in the problem i’m having.(unless the libraries bundled in the netbeans distribution are wrong)

    the problem is, in the priceincrease form that gets into the browser, when i view the src, the from action is pointing to

    /springapp/WEB-INF/jsp/priceincrease.jsp which am sure will not be served as WEB-INF is blocked by the servlet container.

    Do you know what can be causing this.

    Kind regards

  • JOSIP

    hi all.i need help. previous 3 parts worked for me.but part four gives me errors

    i downloaded spring-form.tld from web somewhere becouse i can’t find it in spring freamework…
    i am using ECLIPSE Java EE IDE for Web Developers.
    Build id: 20090920-1017

    i’ve downloaded spring framework 23.0.2 release thanks for help in advance
    Josip

    img96.imageshack.us/i/29718014.jpg/

    img443.imageshack.us/i/90149143.jpg/

    img3.imageshack.us/i/62016171.jpg/

    img707.imageshack.us/i/11890248.jpg/

  • sam

    Hi everyone new to this. I got stuck at 4.6. When i hit the execute then it takes me to /WEB-INF/jsp/priceicrease.jsp
    I’m using netbeans 6.5.1.
    Thanks for any help.