Discussions

News: Version 2.2 of xPetStore Released

  1. Version 2.2 of xPetStore Released (27 messages)

    xPetStore is a lightweight version of Sun PetStore that shows how to use leading opensource frameworks/tools to build J2EE 1.3 WODRA ( Write Once, Deploy and Run ) everywhere. Ant, xDoclet, Struts, SiteMesh and JunitEE are used in the application.

    xPetStore has been successfully deployed and tested on JBoss 3.0.4+ and WebLogic 6.1+, as well as the databases SapDB, PostgreSQL, MySQL, hsqldb, PointBase and MSSQL.

    You can download it at:
    http://sourceforge.net/projects/xpetstore.

    Homepage:
    http://xpetstore.sourceforge.net/.

    Threaded Messages (27)

  2. Really cool[ Go to top ]

    Just wanna say that Herve is really cool to have converted Petstore to Xpetstore making use of tools which are free and accessiblet to all such as ant and xdoclet. Great work!
  3. If I owned an actual pet store, I'd have so many freely available choices for running my Internet systems that it would be overwhelming! This is obviously a boon for the animal sales industry ;-)

    Your overview doc looks pretty impressive. A couple of quick questions, if you do not mind:

    - How does it perform?

    - How does it compare (code, complexity, architecture, performance) to the other implementations? Particular to the iBatis implementation?

    - What are your opinions on the performance bottlenecks in the various implementations?

    - How would you architect the pet-store to make it simpler or more modular? Would that imply more code in the result?

    Thanks!

    Peace,

    Cameron Purdy
    Tangosol, Inc.
    Coherence: Easily share live data across a cluster!
  4. [- How does it perform? ]
    I haven't made any performance test. But, it works very well on my devellopement machine (AMD 1.7G, JBoss3+Tomcat + Jikes).
    xPetStore was created for educational purpose, not as a performance guideline.
    I think that the perf is decent and there is room for improvement.

    [- How does it compare (code, complexity, architecture, performance) to the other implementations? Particular to the iBatis implementation?]
    xDoclet reduction drastically the complexity of the app by generating almost 60% of the code (~75% at EJB layer).
    To number of LOC:
    xPetStore: 4250, BUT 2000 are generated by xDoclet
    iBatis jPetStore ~ 3100
    MS PetStore ~ 3000
    Sun Petstore ~14000
    But, don't forget that the architechture are different.
    xPetStore has a middle tier (Session as MDB), while iBatis and MS version has none

    Using Sitemesh at the web layer really simplify jsp pages.
    Its a much more elegan solution that struts Tiles

    [- How would you architect the pet-store to make it simpler or more modular? Would that imply more code in the result?
    ]
    Replace entity beans with POJO, use a persistence framework like Hibernate, OJB, JDO etc. This will reduce highly the complexity of the app.
    Get rid of SSB for managing the Cart state.
  5. Herve ,

    Marvellous Job!! Kudos! If you publish a book on this , I will buy a dozen for my team --- its better than any classroom training on using oss components!

    -dd
  6. How do I get the database working?[ Go to top ]

    When I try to deploy the application on JBoss, it gives me a SQLException saying unknown database 'xpetstore'.

    I'm using MySQL and I know I haven't created a database for this app yet. But, isn't there suppose to be sql script to run the DDL to create the database? How do I know which tables to create??

    Thanks,

    Alan
  7. Please read the documentation at:
    http://xpetstore.sourceforge.net/x357.html
  8. Yes, I read and followed those instructions. But, the Ant Build script assumes that the database and tables are already existing. I went in and manually created the xpetstore database in MySql, but now it's complaining that the t_counter table does not exist. Is there suppose to be a script that creates the db and tables??

    Thanks,

    Alan
  9. The T_Counter is used to generate unique ID.
    create table t_counter( name varchar(255), value integer );
  10. Re: How do I get the database working?[ Go to top ]

    I had a similar issue with MySql 3.23, and here is the solution of my problem.

    In the class xpetstore.domain.catalog.ejb.ItemEJB one can find the following doclet:

        /**
         * @ejb.persistence
         * column-name="description"
         * jdbc-type="VARCHAR"
         * sql-type="varchar(256)"
         */

    Based on that definition, xDocLet generates the following lines in the file ...gen\META-INF\jbosscmp-jdbc.xml

             <cmp-field>
                <field-name>description</field-name>
                <column-name>description</column-name>

                <jdbc-type>VARCHAR</jdbc-type>
                <sql-type>varchar(256)</sql-type>

             </cmp-field>

    and the varchar of size 256 is actually the problem for MySql 3.23, since maximum of 255 is allowed. Due to this error, during deployment, creation of table T_ITEM has failed.

    After I've changed that value to 255 in the ItemEJB and generated code again ('build make') everything was OK.

    Btw it works also on Windows ME :)

    Regards,
    Zoran.
  11. Great Job[ Go to top ]

    Excellent job Herve! I think more than anything Java has proven to be the most flexible platform with the most architectural options!

    I just wanted to clarify a couple of points:

    >> iBatis jPetStore ~ 3100

    If you're comparing to the 2.0 editions of the PetStore (MS, TMC and iBATIS), then the line counts are actually as follows:

    iBATIS JPetStore = 2215
    MS PetStore = 2096
    TMC = ....lots

    Not that it matters much (a point I make in my white paper). ;-)

    The biggest problem with all of these comparisons (LOC and otherwise) is the lack of a real, complete specification for the PetStore requirements/features. For exmaple, I noticed you included the emailer...something TMC, Microsoft and I did not do. Then there's the Web Service and the distributed transaction which I don't see in xPetStore.

    >> But, don't forget that the architechture are different.
    >> xPetStore has a middle tier (Session as MDB),
    >> while iBatis and MS version has none

    In the 2.0 version of the .Net Pet Shop, MS claims to have a business tier (albeit a heavily bastardized one).

    In the iBATIS JPetStore 2.0 I included one as well (by request). However, it is a very simple POJO (as you suggested to do). Normally I have a more involved business logic tier that is often the "thickest" code in the application. But I found it difficult to find enough business logic in the Pet Store spec (a la TMC/Microsoft) to warrant a complex business layer. It's almost completely a CRUD app. So my business tier does little more than manage data (starting transactions, inserting records etc.). The validation is mostly form level validation in the presentation tier. I suppose it's somewhat of a minimalistic approach ("simplest solution first").

    More information about JPetStore 2.0 is available here:

    http://www.ibatis.com/jpetstore/jpetstore-2.html

    The online demo for 2.0 is available too, but as of this moment it would seem that my IP Address has finally changed. Should be resolved in a couple hours when I get home.

    Again, great job. I look forward to trying it out!

    Cheers,

    Clinton Begin
    http://www.ibatis.com
  12. Great Job[ Go to top ]

    [I think more than anything Java has proven to be the most flexible platform with the most architectural options]
    You are right clinton, I was comparing with jPetStore v1.0,
    which BTW, is also great (all my web-layer is inspired from jPetStore :-)).

    [The biggest problem with all of these comparisons (LOC and otherwise) is the lack of a real, complete specification for the PetStore requirements/features]
    I aggree 100% with that. Since there are no common specs, all PetStore app should not be compared bc they are differents. It's like comparing apple with oranges

    I looked at jPetStore2.0 and jPetStore2.0.1, I saw that you have incoporated WebServices. I'm not familiar with WebServices, but it looks like JAXM offer a simple and portable way to write quickly webservices.
    I think that for the next release, your code will help me again to add WebServices ;-)
  13. RE: Great Job[ Go to top ]

    -------
    I looked at jPetStore2.0 and jPetStore2.0.1, I saw that you have incoporated WebServices. I'm not familiar with WebServices, but it looks like JAXM offer a simple and portable way to write quickly webservices.
    -------

    Hehe...before JPetStore 2.0 I had never written a web service either. JAXM was so simple I actually wanted to return the book I bought.

    The messiest part is the SOAP marshalling. But there are a number of good frameworks to help with that, JWS and Axle to name a few...

    Have fun and keep up the great work!

    Clinton Begin
    www.ibatis.com
  14. Just out of interest, how many lines of XDoclet code did you have to write to generate the 2000 lines of java?

    Regards.
  15. I haven't counted that, but its probably around 300
  16. Excellent work ![ Go to top ]

    Hi,

    I got this working on jboss 3.0.4 and was very impressed. I did find a few issues though ...

    i) You need to copy 'all' and not 'default' folder if the distributable tag is being used in Jboss, otherwise I got a org.mortbay.j2ee.session.JGStore classNotFound.

    ii) Somethings up with the UID generation during the submit order process, sometimes got a bean id already exists exception.

    Other than that all the tests worked ! And of course the ant scripts can be further extended to perform all the actions that are detailed in the notes automatically. (One click install / test).

    Excellent work thanks for providing this.
  17. I think I can say (on behalf of the XDoclet team): Great work!

    Perhaps you could reduce the LOC even further by generating the persistence layer with Middlegen? That way you'd only have to write the SQL create statements (and no CMP java code at all, since Middlegen generates it).

    Cheers,
    Aslak
  18. Can anyone verify that xpetstore-2.2 works in JBoss 3.0.5 with Tomcat-4.1.18 embedded but not in JBoss with Jetty? I always get a ClassCastException....

    12:39:22,781 WARN [jbossweb] WARNING: Exception for /xpetstore
    java.lang.ClassCastException
            at org.mortbay.j2ee.session.StateAdaptor.checkState(StateAdaptor.java:395)
            at org.mortbay.j2ee.session.StateAdaptor.getId(StateAdaptor.java:109)
            at org.mortbay.jetty.servlet.ServletHttpRequest.getSession(ServletHttpRequest.java:495)
            at com.opensymphony.module.sitemesh.filter.PageFilter.doFilter(Unknown Source)
            at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:320)
            at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:272)
            at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:553)
            at org.mortbay.http.HttpContext.handle(HttpContext.java:1656)
            at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:549)
            at org.mortbay.http.HttpContext.handle(HttpContext.java:1606)
            at org.mortbay.http.HttpServer.service(HttpServer.java:862)
            at org.jboss.jetty.Jetty.service(Jetty.java:497)
            at org.mortbay.http.HttpConnection.service(HttpConnection.java:752)
            at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:916)
            at org.mortbay.http.HttpConnection.handle(HttpConnection.java:769)
            at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:202)
            at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
            at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)

    12:39:23,843 ERROR [SubscribingInterceptor] could not get AbstractReplicatedStore


    Anyone know why this is? I followed exactly the same instructions ( http://xpetstore.sourceforge.net/x357.html ) for both JBoss 3.0.5 with Tomcat-4.1.18 embedded and the normal JBoss with JBossWeb (Jetty). Is this a bug in Jetty or a bug in the application which Tomcat deals better with?

    Jake
  19. xPetStore doesn't work with JBoss-Jetty.
    Everything works smootly on JBoss-Tomcat
  20. I have great difficult in getting this to work. First of all no db scripts. Even when i create t_item table and populate it somewhere in the build it goes and deletes it despite commenting out in data.sql file. Could you give us some more insights into what all should we tweak to get this working in JBoss/Tomcat?
  21. What db are you trying to use? i tried it with Hypersonic, followed the instructions and it just deployed smooth. Im now having trouble doing it with Oracle. I fixed the oracle-service.xml but have some issue with "Missing Keyword" error while Deploying.
    2003-01-26 19:32:18,037 WARN [org.jboss.system.ServiceController] Problem starting service jboss.j2ee:jndiName=local/xpetstore.domain.catalog.Category,service=EJB
    org.jboss.deployment.DeploymentException: Error while creating table; - nested throwable: (java.sql.SQLException: ORA-00905: missing keyword
    )

    Anyone tried deploying this with Oracle?

    -Raj
  22. here are the installation instructions for JBoss:
    http://xpetstore.sourceforge.net/x357.html
  23. I think that you have a problem of sequence of operation.
    You should fill the database only after the application is deployed on JBoss, because JBoss automatically drop all the tables and recreate them.

    After the application is deployed, you run 'build.sh db', which will execute the script 'data.sql' and fill all the tables.
  24. When I deploy xpetstore.jar to jboss-3.0.6, I get many exceptions:

    MBeans waiting for other MBeans:
    [ObjectName: jboss.j2ee:jndiName=local/xpetstore.domain.signon.Account,service=E
    JB
     state: FAILED
     I Depend On:
     Depends On Me: java.lang.ClassNotFoundException: SELECT OBJECT(o) FROM Order AS
     o WHERE o.customer.customerUId=?1xpetstore.domain.signon.interfaces.AccountLoca
    lHome, ObjectName: jboss.j2ee:jndiName=local/xpetstore.domain.catalog.Product,se
    rvice=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome, ObjectName: jboss.j2ee:jndiName=local
    /xpetstore.util.uidgen.Counter,service=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome, ObjectName: jboss.j2ee:jndiName=local
    /xpetstore.domain.order.Order,service=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome, ObjectName: jboss.j2ee:jndiName=local
    /xpetstore.domain.catalog.Item,service=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome, ObjectName: jboss.j2ee:jndiName=local
    /xpetstore.domain.catalog.Category,service=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome, ObjectName: jboss.j2ee:jndiName=local
    /xpetstore.domain.customer.Customer,service=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome, ObjectName: jboss.j2ee:jndiName=local
    /xpetstore.domain.order.OrderItem,service=EJB
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: local home class not f
    ound: SELECT OBJECT(o) FROM Order AS o WHERE o.customer.customerUId=?1xpetstore.
    domain.signon.interfaces.AccountLocalHome]
  25. After I add these lines into OrderEJB.java
     * @ejb.ejb-ref
     * ejb-name="Customer"
     * view-type="local"
    the application can be deploied successful and work fine. Is this the problem?
  26. Herver has shown us the ejbcreate methods of the customer and account beans but what happens between beans having relationships( 1 to many) such as the product and item bean. How to should the ejbcreate methods be written. Actually there are no ejbcreate methods for beans such as product and items because the xpetstore does no need to create and items, products or categories because ther are no "admin pages" for inserting these. could you give us insight how to code these herver?
  27. Problem with Database linkage[ Go to top ]

    Hi Herve,
      I was reading a thread between you and Brian McSweeney relating to a problem with xpetstoreDS under JBoss (in my case 3.0.7) and I have exactly the same problem and it is diriving me mad. Maybe you eventually found a solution to that problem and it is not on the noticeboards.
      I checked on the jmx console and everything looks OK but when the beans first try to use xpetstoreDS they get the message that it is not bound. What is strange is that if I then run the build.bat db script it crashes saying it cannot find the first table in the SQL - so the separately configured db-name.properties with the same URL and JDBC module are working at getting connection to the database. Could it be a security problem (if so why - don't I see this in some log message)?
      My problems are compounded a little by trying to use Cloudbase (while I am waiting for Oracle to be set up here) which I know has not been tested - but I am so close it is very frustrating.
    As an aside, do you have the create tables as SQL so I can at least test that?
    Jim Brady
  28. Presto PetStore[ Go to top ]

    Welcome to the simplest and by far the fastest pet store implementation.
    See it running at http://www.prevayler.org/presto

    Julio