Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Java Development with the Spring Framework
This is the forum to discuss the Wrox book Professional Java Development with the Spring Framework by Rod Johnson, Juergen Hoeller, Alef Arendsen, Thomas Risberg, Colin Sampaleanu; ISBN: 9780764574832
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Java Development with the Spring Framework section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 3rd, 2005, 08:39 AM
Registered User
 
Join Date: Oct 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems with Sample Application

Hi,

I have been trying to get the sample application working and have now given up. I am using Oracle9i and Tomcat.

Here's a list of issues I came across and what i did:

1. There is a compile error in class org.springframework.prospring.ticket.dao.hibernate .HibernateBoxOfficeDaoTest.java - Eclipse informed me that i had to declare that the onTearDownInTransaction() method throws Exception (or surround with try/catch).
2. The oracle ddl script contained an error - the Table SHOWS was misnamed SHOW.
3. The insert script for Oracle is missing. I used the POSTGRES script but had to make changes to cater for the dates that are inserted into the PERFORMANCE table.
4. I too came across the messages about EHCache but since they were warnings i ignored them.
5. Selecting a performance (I think Giselle) and then submitted caused an error. The sql sent to oracle was incorrect. I narrowed down the problem to the line:
...
) as availability
...
where 'as' needed to be removed. However, I have no experience with Hibernate so was not sure if this could be changed in the code.

At this point I gave up. I think the creators of the sample app need to at address these issues otherwise the app is useless.

Excellent book btw, shame about the sample app.

Rakesh
Reply With Quote
  #2 (permalink)  
Old January 12th, 2006, 04:11 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

struggling with similar - posted my attempt here: http://forum.springframework.org/sho...6783#post46783

Reply With Quote
  #3 (permalink)  
Old February 3rd, 2006, 04:03 PM
Registered User
 
Join Date: Oct 2005
Location: Hill Air Force Base, Utah, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Rakesh,

The 'as' keyword is not a Hibernate issue. It's a database specific issue. Oracle does not support the 'as' keyword.

You were correct in removing the 'as' in front of 'availability'. You should also remove the 'as' in the following strings: 'as pId', 'as pbId' and 'as seatCount'.

To create a table alias in Oracle, you simply put the alias after the column reference or subquery (as in the case of alias 'availability').

BTW, I've implemented the sample applications in the other three databases (HSQL, MYSQL and PostgreSQL) and the 'as' keyword is supported for these databases.

Reply With Quote
  #4 (permalink)  
Old March 10th, 2006, 06:48 PM
Registered User
 
Join Date: Oct 2005
Location: Hill Air Force Base, Utah, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I got the boxoffice app to successful work with my Oracle 10g database.

I made the following 3 fixes to the boxoffice app.
1. Starting with the postgres "create ticket" script change all occurrences of "serial" with "integer not null" and remove the grant statements to create the oracle ddl.
2. In Booking.hbm and Purchase.hbm change:
     <generator class="identity">
   to:
     <generator class="assigned">
3. Make the change to queries.hbm change
     "} as availability"
   to:
     "} availability"

Reply With Quote
  #5 (permalink)  
Old July 19th, 2006, 03:30 PM
Registered User
 
Join Date: Oct 2005
Location: Hill Air Force Base, Utah, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I revisited my prior post and came up with a slightly different approach (steps #1.a. and #2). This solution is more compatible with using Oracle sequences to autogenerate the primary keys.

I made the following 3 fixes to the boxoffice app.
1. Starting with the postgres "create ticket" script change all occurrences of "serial" with "integer not null" and remove the grant statements to create the oracle ddl.
1.a. In the "create ticket" script add two commands: "Create SEQUENCE booking_id_sequence;" and "Create SEQUENCE purchase_id_sequence;"
2. In Booking.hbm change:
     <column name="id">
     <generator class="identity">
   to:
     <column name="id" not-null="true"/>
     <generator class="sequence">
         <param name="sequence">booking_id_sequence</param>
     </generator>

   In Purchase.hbm change:
     <column name="id">
     <generator class="identity">
   to:
     <column name="id" not-null="true"/>
     <generator class="sequence">
         <param name="sequence">purchase_id_sequence</param>
     </generator>


3. Make the change to queries.hbm change
     "} as availability"
   to:
     "} availability"

Reply With Quote
  #6 (permalink)  
Old September 29th, 2006, 04:45 PM
Registered User
 
Join Date: Oct 2005
Location: Hill Air Force Base, Utah, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I revisited the spring/oracle app and extended the application to include JAX-RPC webservices for the "Events Calendar". I discovered that this will work only for the post-J2EE 1.4 web services clients. For pre-J2EE 1.4 web services clients, I had to write another webservices server to serve as an intermdediary (using Sun's JWSDP 2.0).

Here's the procedure (developed using chapter 8 and the spring's jpetstore as a reference):

1. add 5 axis 1.4 jars to /lib
axis.jar, commons-discovery-0.2.jar, jaxrpc.jar, saaj.jar
2. add the axis servlet to web.xml
3. create server-config.wsdd and place in /src/webapp/WEB-INF
4. create 2 jax-rpc service files eventsCalendarAxis and eventsCalendarAxisImpl and placed them in /src/java/org/springframework/prospring/ticket/service

Note that in jPetstore there's an implementation a remoting example which implements all four Spring remoting protocols Hessian/Burlap, HttpInvoker, RMI and JAX-RPC (post-J2EE 1.4). I chose to implement only for JAX-RPC since at this stage in time I'm only interested in perl SOAP-LITE webservices client (Solaris).

files: web.xml, server-config.wsdd, EventsCalendarAxis, EventsCalendarAxisImpl

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
    <display-name>Spring BoxOffice</display-name>

    <description>Spring BoxOffice sample application</description>

    <!--
     - Specifies the context location for the root application context of
     - this web app. The value mentioned here is the default of the
     - ContextLoaderListener, but for clarity we're including it anyway.
    -->
    <context-param>
        <param-name>contextConfigLocations</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml
        </param-value>
    </context-param>

    <!--
     - Loads the root application context of this web app at startup,
     - by default from "/WEB-INF/applicationContext.xml" (see above).
     -
     - Use WebApplicationContextUtils.getWebApplicationContex t(servletContext)
     - to access it anywhere in the web application, outside of the framework.
     - Note that this will only work in Servlet 2.4 environments, or Servlet 2.3
     - environments that follow the 2.4 initializaiton order (most of them).
     - Alternately, ContextLoaderServlet can be used for older environments.
    -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>
    </listener>

    <!--
     - Declaration of the dispatcher servlet, resulting in a WebApplicationContext
     - being loaded from /WEB-INF/boxoffice-servlet.xml. The parent of this
     - application context is the one loaded by the ContextLoaderListener
     - (in this case /WEB-INF/applicationContext.xml).
     - You can tweak the name of the WebApplicationContext to be laoded by setting
     - one or more context parameters (explained in more detail in the MVC chapter).
    -->
    <servlet>
        <servlet-name>ticket</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherSe rvlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <!--
        - Servlet definition for Web Service remoting via Apache Axis
        - (see server-config.wsdd for Axis configuration).
        -->
    <servlet>
        <servlet-name>axis</servlet-name>
        <servlet-class>org.apache.axis.transport.http.AxisServlet</servlet-class>
        <load-on-startup>5</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>ticket</servlet-name>
        <url-pattern>*.html</url-pattern>
    </servlet-mapping>

    <!--
        - Servlet mapping for Web Service remoting via Apache Axis
        - (see server-config.wsdd for Axis configuration).
        -->
    <servlet-mapping>
        <servlet-name>axis</servlet-name>
        <url-pattern>/axis/*</url-pattern>
    </servlet-mapping>

    <welcome-file-list>
        <welcome-file>index.htm</welcome-file>
    </welcome-file-list>



    <taglib>
        <taglib-uri>http://www.springframework.org/tags</taglib-uri>
        <taglib-location>/WEB-INF/tld/spring.tld</taglib-location>
    </taglib>

</web-app>

<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/" xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
    <globalConfiguration>
        <parameter name="adminPassword" value="admin"/>
        <parameter name="sendXsiTypes" value="true"/>
        <parameter name="sendMultiRefs" value="true"/>
        <parameter name="sendXMLDeclaration" value="true"/>
        <parameter name="axis.sendMinimizedElements" value="true"/>
        <requestFlow>
            <handler type="java:org.apache.axis.handlers.JWSHandler">
                <parameter name="scope" value="session"/>
            </handler>
            <handler type="java:org.apache.axis.handlers.JWSHandler">
                <parameter name="scope" value="request"/>
                <parameter name="extension" value=".jwr"/>
            </handler>
        </requestFlow>
    </globalConfiguration>
    <handler name="Authenticate" type="java:org.apache.axis.handlers.SimpleAuthenti cationHandler"/>
    <handler name="LocalResponder" type="java:org.apache.axis.transport.local.LocalRe sponder"/>
    <handler name="URLMapper" type="java:org.apache.axis.handlers.http.URLMapper "/>
    <service name="AdminService" provider="java:MSG">
        <parameter name="allowedMethods" value="AdminService"/>
        <parameter name="enableRemoteAdmin" value="false"/>
        <parameter name="className" value="org.apache.axis.utils.Admin"/>
        <namespace>http://xml.apache.org/axis/wsdd/</namespace>
    </service>
    <service name="eventscalendar" provider="java:RPC">
        <parameter name="allowedMethods" value="*"/>
        <parameter name="className" value="org.springframework.prospring.ticket.servic e.EventsCalendarAxisImpl"/>
        <beanMapping qname="boxoffice:Genre" xmlns:boxoffice="urn:boxoffice" languageSpecificType="java:org.springframework.pro spring.ticket.domain.Genre"/>
    </service>
    <service name="Version" provider="java:RPC">
        <parameter name="allowedMethods" value="getVersion"/>
        <parameter name="className" value="org.apache.axis.Version"/>
    </service>
    <transport name="http">
        <requestFlow>
            <handler type="URLMapper"/>
            <handler type="java:org.apache.axis.handlers.http.HTTPAuthH andler"/>
        </requestFlow>
    </transport>
    <transport name="local">
        <responseFlow>
            <handler type="LocalResponder"/>
        </responseFlow>
    </transport>
</deployment>
package org.springframework.prospring.ticket.service;

import java.rmi.*;
import org.springframework.prospring.ticket.domain.*;

/**
* Represents the event calendar of the system. The event calendar provides services regarding the
* genres, shows, and performances available.
*/
public interface EventsCalendarAxis extends java.rmi.Remote {

    /**
     * Returns string of all genres defined in the system.
     * @return String of all genres defined in the system.
     */
    public String getAllGenres() throws java.rmi.RemoteException;

    /**
     * Returns string of all genres which currently have shows.
     * @return String of all genres which currently have shows.
     */
    public String getCurrentGenres() throws java.rmi.RemoteException;

    /**
     * Returns string of the performance associated with the given id.
     * @param performanceId The id of the requested performance.
     * @return String of the performance associated with the given id.
     */
    public String getPerformance(long performanceId) throws java.rmi.RemoteException;

    /**
     * Returns string of the show associated with the given id.
     * @param showId The id of the requested show.
     * @return String of the show associated with the given id.
     */
    public String getShow(long showId) throws java.rmi.RemoteException;
}
package org.springframework.prospring.ticket.service;

import java.util.*;

import org.springframework.prospring.ticket.dao.*;
import org.springframework.prospring.ticket.domain.*;
import org.springframework.remoting.jaxrpc.ServletEndpoin tSupport;

/**
* The default implementation of the EventsCalendar service.
*/
public class EventsCalendarAxisImpl extends ServletEndpointSupport implements EventsCalendarAxis {

    // the dao this service uses to retrieve the data from the database.
    private BoxOfficeDao boxOfficeDao;

    protected void onInit() {
     this.boxOfficeDao = (BoxOfficeDao) getWebApplicationContext().getBean("dao");
    }

    /**
     * Returns all genres which currently have shows.
     * @return All genres which currently have shows.
     */
    public String getCurrentGenres() {
        Genre genre;
        Collection genres = boxOfficeDao.getCurrentGenres();
        Iterator iterator = genres.iterator();
        String line = "";
        while (iterator.hasNext()) {
            genre = (Genre) iterator.next();
            line = line + genre.getName() + ' ';
        }
        return line;
    }

    /**
     * Returns all genres defined in the system. *
     * @return All genres defined in the system.
     */
    public String getAllGenres() {
        Genre genre;
        Collection genres = boxOfficeDao.getAllGenres();
        Iterator iterator = genres.iterator();
        String line = "";
        while (iterator.hasNext()) {
            genre = (Genre) iterator.next();
            line = line + genre.getName() + ' ';
        }
        return line;
    }

    /**
     * Returns the performance associated with the given id.
     * @param performanceId The id of the requested performance.
     * @return The performance associated with the given id.
     */
    public String getPerformance(long performanceId) {
        Performance performance = boxOfficeDao.getPerformance(performanceId);
        Long pId = new Long(performance.getId());
        String line = pId.toString();
        line = line + ' ' + performance.getDateAndTime().toString();
        line = line + ' ' + performance.getShow().getName();
        line = line + ' ' + boxOfficeDao.getPriceStructure(
                 performance.getPriceStructure().getId()).getNa me();
        return line;
    }

    /**
     * Returns the show associated with the given id.
     *
     * @param showId The id of the requested show.
     * @return The show associated with the given id.
     */
    public String getShow(long showId) {
        Show show = boxOfficeDao.getShow(showId);
        Long pId = new Long(show.getId());
        return pId.toString() + ' ' + show.getName();
    }

}
Reply With Quote
  #7 (permalink)  
Old November 14th, 2006, 01:24 PM
Registered User
 
Join Date: Oct 2005
Location: Hill Air Force Base, Utah, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've been playing with the remoting-servlet described in chapter 8.
Here's a few notes:

1. In order for all the http transport protocols to work (http-invoker, hessian and burlap) you need to replace cglib-2.1.jar with a later version. I replaced it with cglib-nodep-2.1_3 which comes with the spring framework distribution spring 1.2.7 distribution.

2. In order for hessian and burlap to work you need to replace hibernate. JPetstore uses ibatis.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Where is the code of sample application? rogerthis BOOK: Professional Java Development with the Spring Framework 1 November 27th, 2006 01:26 AM
Application Domain problems sky_handsome C# 0 December 29th, 2005 04:22 AM
Exception design on Boxoffice Sample Application? dleal BOOK: Professional Java Development with the Spring Framework 1 November 11th, 2005 06:31 AM
Can't start the Phile sample web application kuotaiyi BOOK: ASP.NET Website Programming Problem-Design-Solution 1 June 12th, 2003 10:29 PM



All times are GMT -4. The time now is 06:11 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.