The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

I'm very much enjoying working my way through this book. I'm using Visual Studio for Mac Community Version 7.3.2 to work with the source code and examples.

In Chapter 12 you designed the database connection to use MS SQL Local database:

"...SQL Server Express’ Local DB feature. This is installed as part of Visual Studio 2017 (when you choose the .NET Desktop Development workload) and provides a lightweight SQL Server engine."

How can I use a local database on my Mac for working with Entity Framework?

Since one of the primary purposes of .net core is to be enable cross platform development and running of .net applications it would be great to know how to build and run applications that use .net core EF on my Mac.

Thank You,

Bruce
Read through chapter 1 and I'm considering purchasing the MEAP version.

Will you have an explanation for how to install/run the Java 8 JDK? I use Mac OS X and uBuntu Linux.

I'd like to be able for to code and execute your examples.

Thank You,

Bruce Phillips
University of Kansas
I was able to install the latest development build of NetBeans (http://bits.netbeans.org/dev/nightly/latest/). During the installation I told it to use the Java 8 JDK I have previously installed.

Then I could open your Maven project (NetBeans automatically understands Maven projects), view your source code, and run the main classes from within NetBeans.

Bruce
Thanks for the quick reply.

I was able to install Java 8 JDK.

I forked your project and cloned my fork to my local computer.

I successfully compiled and ran the chapter 1 FilteringApples example

I did send you a pull request with some changes for your pom.xml.

Are you using a Java IDE to code your examples?

Bruce
For the chapter 2 code, besides going through the same steps I did for the chapter 1 code, I had to change pom.xml so that Maven could get the artifacts. The version numbers in the original pom.xml for some of the artifacts are no longer correct in the repositories.

Here are the nodes I changed:

<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
<scope>runtime</scope>
</dependency>

Additionally to get the tests to run I changed this node in domain.xml (under src/test/resources/glassfish.config:


<jdbc-connection-pool datasource-classname="org.apache.derby.jdbc.ClientDataSource" res-type="javax.sql.DataSource" name="Chapter2Pool">
<property name="DatabaseName" value="chapter2" />
<property name="Password" value="password" />
<property name="PortNumber" value="1527" />
<property name="ServerName" value="localhost" />
<property name="User" value="admin" />
<property name="URL" value="jdbc:derby://localhost:1527/chapter2" />
<property name="connectionAttributes" value=";create=true" />
</jdbc-connection-pool>

The original domain.xml is missing the <property name="connectionAttributes" value=";create=true" /> so the tests fail because the chapter2 database doesn't exist.

After making the above changes I could run mvn test successfully.
Thank you for the repository link.

To use the source code provided with EJB 3 In Action, Second Edition (MEAP version) in Eclipse 3.6 (with M2Eclipse plugin) I did the following:


1. Added the subversion repository to Eclipse SVN client
1. http://action-bazaar.googlecode.com/svn/trunk
2. Checkout ActionBazaar under chapter 1
1. Select radio button for Checkout as a project in the workspace
3. In Java EE perspective, right click on the checked out project (ActionBazaar) and select Maven - Enable Dependency Management
1. If this is the first time you've done this Maven will download many artifacts from Maven repositories to your computer
4. Add Eclipse project nature
1. Right click on project name and select Run As - Maven build ... (note the ellipses)
2. In the Goals input field enter eclipse:eclipse -Dwtpversion=1.5
3. Click on the Run button
5. Refresh project
1. Right click on the project name and select Refresh
Now you can run Maven build, tests, goals, etc from within Eclipse

For example to run the tests, right-click on the project name and select Run As - Maven test
In chapter 2, page 21 it reads "downloading the zip containing code examples file from www.manning.com/panda" but that is for the first edition.

Is it possible to get the source code for this new second edition? It would be very helpful to be able view and run the example code.

Bruce
I liked the metaphor. Live and let live.
I'm purchasing the MEAP. If the rest of the chapters already available are as well-written as chapter 1 then this will be one of the best MEAP books I've purchased.

I'm looking at EJB 3.1, CDI, JPA 2, JSF 2 and GlassFish 3 to replace my current use of Struts 2, Spring, Hibernate, and Tomcat for Java web applications.

EJB 3.1 with it's built in support for CDI and JPA and the new JSF 2 seem like a better technology stack. Your book will help me learn more about these new technologies and if they are fully suited to developing the next generation of Java web applications.

Message was edited by:
phillips1021
The chapter 2 example code doesn't match the book. Additionally the chapter 2 example will not run because you have the Spring context xml files in the wrong place in the Maven folders.
Ashish - after our early thread discussion on whether or not there were parts of chapters 1-9 that were too specific to a particular portlet container/portal server (e.g. Liferay) I said I would re-read the chapters and code examples to see if I could find areas that demonstrate my concern.

In section 3.2.3 Portal Server Specific Request Handling Using PortalContext you show a code example that uses a PortalContext object to get portal server specific info.

This section seems out of place in the flow of the chapter as it's a sub-section of 3.2 Portlet Request Objects. Also you define the Constants used in the doHeaders method in a separate Constants class, but how did you know what values to put for the different portal servers?

This section states:

"To check if the your portlet can add custom JavaScript and CSS DOM elements to the head section of portal page (discussed later in this chapter)"

which you then detail further in section 3.3.5. But again the information in 3.3.5 is very portal server specific.

Also the code example in Listing 3.6 doesn't match the source code download for class BookCatalogPortlet

My suggestion would be that the information in sections 3.2.3 and 3.3.5 be moved to a chapter late in the book on portlets and portlet servers/containers optional elements.

For me, secitons 3.2.3 and 3.3.5 just complicated/confused what otherwise is a good chapter about Portlet request/response/session and user attributes.

I'll re-read through chapter 4 next.

Bruce
I've recommended before that chapter 5 should be moved to an appendix. Please see my comments under the thread about moving from Liferay 5 to Liferay 6.

Chapter 5 very much breaks up the flow of the book and doesn't have much to do with the overall theme of the book as I understand it:

" This book teaches readers how to use the portlet technology in real projects by providing complete
coverage of Portlet 2.0 API..."
-page 4

Thanks as always for considering all the MEAP readers' feedback. As I mentioned before I'm already encouraging other Java developers to purchase this book.

Bruce
In ch12_BookCatalogResourceURL, class BookCatalogPortlet.java recommend you change line 305 from:


File file = new File(getInitParameter("uploadFolder") + "\"

to

File file = new File(getInitParameter("uploadFolder") + File.separator

On line 355 make the same change.

The correct file separator for all operating systems is provided by File.separator. See: http://java.sun.com/javase/6/docs/api/java/io/File.html#separator

The as a file separator only works for Windows.
To answer my own question - I was able to build the ch12_DateTime portlet without the portal-kernal.jar and portal-service.jar. I deleted the reference to those jars in the Project Properties - Java Build Path - Libraries.

The portlet build.xml worked fine and the portlet was deployed successfully to Liferay.

Message was edited by:
phillips1021
Really looking forward to chapter 12.

I checkout from the subversion repository the ch12_DateTime project. It has a hard-coded external lib for portal-kernel.jar and portal-service.jar (view Project - Properties - Java Build Path - Libraries). This causes a build error in Eclipse because I don't have those jars in the same path as the project specifies.

Are those jars required to build the portlet?

Bruce
I think all the material that deals with Liferay specific issues should be in an appendix. Our organization uses a completely different portlet container.

There is alot of Liferay specific material in chapters 1-9, that will only benefit people using Liferay. I also think focusing so much content on Liferay takes away from the book's main theme, which I thought was how to take advantage of the new portlet specification.
Ashish:

I'll go back through the chapters and try to find examples of where I feel Liferay specific code is being used without an adequate comment for the user. It may be that my impression that the chapters and code examples contain too much Liferay specific code is not valid.

As a note, I've already started going over chapter 2. The work you did in explaining portlet lifecycle, modes, and annotations in that chapter is very good. I also like that each chapter's example is a separate project that can be checked out of the subversion repository.

This book will be one I'll be using for a long time to come. I think many portlet developers will find this book very useful. That is why I'm advocating clearly identifying code that is Liferay specific so that readers needing to create similar functionality in their portlets that will run in a different portal server/portlet container will know exactly what code they will need to change for their environment.

As I noted above, I could have a false impression so I will go back over the chapters and see if I can provide you some examples.

Bruce
I'm fine with the author choosing to use Liferay as the portlet container. However, there is too much material in chapters 1-9 (especially chapters 5 and 9) that only applies to Liferay and will not work in other portlet containers. It would be good to know that here is the code that will work in any Portal 2.0 compliant container and here are the parts that only work in Liferay and will have to be modified to work in a different portlet container.

Much of chapters 5 and 9 could be moved to an appendix that developers who are building portlets for Liferay will find useful, but for the rest of us is not very important. The Liferay specific material really doesn't have anything to do with the book's overall theme.

Otherwise this book will be more about developing Portlets for Liferay and not developing portlets that should be able to be deployed into any Portlet 2.0 container. One of the major problems with the state of vendor implementation of portlet containers is that there is too much lock-in as each vendor (including Liferay) forces you to use their specific implementation to accomplish some of the features that are supposed be "standard" in Portlet 2.0. So most portlets designed for one portlet container can not be used in a different portlet container.

My request is that the author clearly identify those code elements that are Liferay specific and that will need to be changed if the reader needs to build portlets for some other portlet container.

That said please understand that I think this book is moving along very well and I know of several Java developers (including myself) that think the author is doing a great service in helping us learn Portlet 2.0 development.

I also really appreciate and commend the author on his timely responses to all the user feedback.

Bruce

Message was edited by:
phillips1021
Why have the first 9 pages of Chapter 9 be about how to configure Liferay to use MySql?

Couldn't you put that information in an appendix and start chapter 9 with integrating Spring JDBC into a portlet web application?

Even for those readers who use Liferay, they probably are not concerned with configuring which database Liferay should use (and which information should be readily available in Liferay's documentation).

It was a bit frustrating to read through those 9 pages to get to the material I thought the chapter was about.
Ashish:

I'm continuing to work my way through chapter 11 and I"m learning alot of useful information. I did get stuck for a little while when trying to run the portlet examples for section 11.4 (public render parameters).

The content of section 11.4.3 - Put your public render parameters to work in a flash (note there are two section 11.4.3's in this chapter) should be moved forward in this chapter prior to your discussion of the code in the portlet examples for section 11.4.

I loaded the example portlets (ch11_BookCatalog_public and ch11_RecentBook_public) into Liferay and ran them as I read sections 11.4.1 (Setting/retrieving...) to 11.4.3 (Advantages/Disadvantages). I noticed the Recent Book portlet wasn't being updated after I added a new book to the book catalog.

I had to read through the code a few times to figure out why. Then after reading the section on disadvantages/advantages (11.4.3) I came to the section titled Put your public render parameters to work in a flash (also numbered 11.4.3) where you provide the WARNING that since the portlets are not using a shared database, the book added to the Book Catalog needs to have an ISBN of 1, 2, 3, 4, or 5 in order for a book to show up in the Recent Book portlet.

It would have been less confusing for me if that warning was provided up near the beginning of section 11.4 so that I'd know about the issue before running the examples in Liferay.

Otherwise very good section on public parameters. I especially liked figure 11.6 and your explanation - really cleared up the reason for the namespace.

Bruce
Ashish:

I really appreciate your quick and thoughtful replies. This is the last I'll post on this subject. I'm posting this only because I think providing your readers as much information as possible so that they can successfully run your example applications is very important.

You wrote:
I wouldn't like to add that in the book because I think it is expected from a product like Liferay to work in a consistent manner across different OS and configuration (resin/tomcat/....).

Unfortunately, my testing of Liferay on both Windows and Mac shows that Liferay doesn't work in a consistent manner across different OS when it comes to using the Sun OpenPortlet container.

Of the Liferay bundles a user may download from: http://www.liferay.com/downloads/liferay-portal/overview;jsessionid=151FAC788622D2AF4A37C22FF35F3F85.node-1 I could not get the Sun OpenPortal configuration to work with your example code in the following on Windows XP and Mac OS X

Liferay 5.2.3 bundled with Resin
Liferay 5.2.3 bundled with Jetty
Liferay 5.2.3 bundled with Glassfish 3

On Mac OS X

Liferay 5.2.3 bundled with Tomcat 6

The only Liferay bundles I can successfully configure with Sun OpenPortlet container and run your example portlets are:

Windows XP
Liferay 5.2.3 bundled with Tomcat 6

Mac OS X
Liferay 5.2.2 bundled with Tomcat 5.5


As you state, Liferay in its default configuration is not a Portlet 2.0 compliant portlet container. Your code examples explore the various portlet 2.0 capabilities. You want the user to run your code examples in a portlet 2.0 container. In your book you instruct the user to use Liferay but with the Sun OpenPortlet container so that Liferay can run portlets that use 2.0 features.

Unfortunately only a few of the Liferay bundles a user can download and install (whether on Windows or Mac or Linux) will work with the Sun OpenPortlet container (and therefore work with your examples). Liferay is not consistent across different OS and configuration. The problem isn't a Mac OS X issue. The same problems occur on Windows in the other Liferay--non Tomcat--bundles.

Why not let your readers know up-front what Liferay bundles work with Sun OpenPortlet container and therefore will enable the user to run your example portlets?

You wrote:

I use Windows OS and I have used a couple of different Liferay bundles and they all worked fine for me.

Which Liferay bundles did you use? Were you successful using any bundles that don't use Tomcat?

Thanks again for being so open to comments from your MEAP readers. You're writing an excellent book and one I will recommend to other Java developers.

Bruce
Ashish:

I'm trying to run the ch11_ips_session portlet application in Liferay (using the Resin deployment).

When I add the Book Catalog portlet from that application to a page in Liferay this exception is generated and the portlet is not added:

16:06:07,750 ERROR [InsertTag:922] ServletException in '/html/common/themes/portlet.jsp'

Can you let me know the exact Liferay configuration you're using when testing/running the example applications from Chapter 11?

It might be helpful to your readers if you include that information in each chapter when instructing the user to refer to the code example.

There are many different implementations of the Liferay portal (using Tomcat 5.5, Tomcat 6, Jetty, Resin, Glassfish) and only a few work with Sun's OpenPortal Portlet Container.

If someone would pickup your book and skip to chapter 11 and try to run the code in one of the Liferay implementations where your code will not work, they might get pretty frustrated with your book. If you provide the reader specific details on what version/configuration of Liferay he/she must setup to be able to run your example applications that would prevent some frustration.

I'll check tonight at home if I get the same error when using Liferay configured with Tomcat 5.5 and the Sun OpenPortal Portlet container (I cannot use Tomcat 5.5 on my Windows computer at work).

Bruce
For the Chapter 7 Hello World example I had to add the doctype declaration to liferay-display.xml to get the portlet to run in Liferay.

<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 5.2.0//EN" "http://www.liferay.com/dtd/liferay-display_5_2_0.dtd">
Ashish:

I'm trying to run the example portlets described at the end of chapter 11: ch11_BookCatalog_event and ch11_RecentBook_event.

After adding a book to the book catalog, ch11_RecentBook_event throws an Exception:

Caused by: java.lang.ClassCastException: chapter11.code.listing.events.BookAddedEvent cannot be cast to chapter11.code.listing.events.BookAddedEvent
at chapter11.code.listing.base.RecentlyAddedBookPortlet.processAddedBookEvent(RecentlyAddedBookPortlet.java:3smilie

I'm running Java 6 on Mac OS X. I've deployed the portlets to Liferay bundled with Tomcat 5.5.

I'm using the latest code download from Google.

Any suggestions for how I can get this code to work?

Bruce
Ashish:

Thank you for contacting Liferay for assistance on running Liferay with Sun OpenPortal on Tomcat 6 on the Mac OS X.

But I think you missed my larger point.

I believe you should inform your readers in an appendix the Liferay configurations in which your code examples will work. You could then refer the reader to this appendix whenever you tell the reader to run through a code example.

This way a reader will know what deployment of Liferay (e.g. Liferay 5.2.3 with Tomcat 6 on Windows using Sun OpenPortal and Liferay 5.2.2 with Tomcat 5.5 on Mac OS X using Sun OpenPortal) the user will need to install on his/her computer to run the examples.

Otherwise your readers will assume that they can deploy your examples into any version of Liferay (e.g. Liferay 5.2.3 with Jetty) and that your examples will work.

However, since most of your examples require Liferay to be running Sun OpenPortal that is not correct.

On the Liferay download page (http://www.liferay.com/downloads/liferay-portal/overview;jsessionid=151FAC788622D2AF4A37C22FF35F3F85.node-1) there are numerous Liferay bundles a user can download and install on his/her computer. Only a few of these appear to work with Sun OpenPortal container.

Your code examples and code explanations are very good. But your book is missing a key piece: detailed instructions on how to configure a specific Liferay bundle on the user's computer so your code examples will work on the user's computer.

Bruce
It's worked for me now. Thanks for checking on it.

Bruce
I was able to add the two portlets that are part of ch11_ipc_session to the Liferay portal version 5.2.2 running on Mac OS X using the Tomcat 5.5 and with the Sun OpenPortal portlet container.
I get an error when clicking on the code download link at

http://code.google.com/p/portletsinaction/downloads/list

Bruce
Ashish:

I want to revisit the problems I've had using OpenPortal container with Liferay. No one at Liferay answered my forum post about not being able to use OpenPortal with Tomcat 6 on the Mac.

In chapter 4 (section 4.7) you instruct users to configure Liferay to use the OpenPortal portlet container. However, you don't mention that OpenPortal only will work with certain versions of Liferay that a user can download.

You may want to add some more information about which downloads of Liferay (e.g. Tomcat 6 on windows, Tomcat 5.5 on Mac) will work with the OpenPortal container and which downloads of Liferay (Resin, Jetty, Glassfish, Tomcat 6 on the Mac) will not work with the OpenPortal portlet container.

I think this is very important for your readers to know as most of your portlet examples from chapter 4 on require Liferay to be using the OpenPortal container.

I think one of the strongest parts of your book are your code examples (and your very good explanations of the code you've written in each chapter). Making it as easy as possible for your users to run these code examples on their computers means your users can learn even more by running your code and playing with it.

You've provided excellent code downloads with a simple build system. The last step you're missing is ensuring your users know exactly what Liferay configuration they must use (and will work on their operating system) in order to run the examples.

Bruce
Ashish - I appreciate the quick response.

I'm trying to find a LifeRay installation for the Mac (OS 10.6, Snow Leopard) that doesn't use Tomcat that I can try setting up LifeRay to use OpenPortal. So far I've not been successful. The download page for LifeRay community edition isn't to clear on what to use for the Mac.

Do you have any recommendation for what I should use on the Mac so I can use OpenPortal?

Is there any way you can check the LifeRay 5.2.3 Tomcat installation on a MacBook Pro running Snow Leopard to see if the problem I'm having occurs for you? I think many of your readers will be using Macs (our Java shop is 75% Macs).

I don't want you to write a separate version of the examples since you're saying that your examples ARE NOT doing anything outside the JSR 286 specification and that OpenPortal is a JSR 286 standard portal.

I'll research trying to use OpenPortal with LifeRay on the Mac also to see what I find out. If I do find a workable solution I'll post it here.

Again, thanks for the help. I just got frustrated today as I am really looking forward to chapter 6 and working through your example code. I also want to ensure that if I recommend purchasing this book for each of our Java developers, the code in the book is going to work for them.

Bruce
Thanks for the reply. I tried your suggestions several times and get the same error message as above whenever I try to deploy a portlet after adding the portal-ext.properties file with the line portlet.container.impl=sun.

I'm using Liferay 5.2.3 with Tomcat on Mac OS X (10.6).

If I can continue through chapter 5 without using the Sun OpenPortal then I won't worry about this issue.

Bruce
Ashish - unfortunately because of the problem described previously in using OpenPortal Portlet Container with my installation of Liferay I cannot run the chapter 6 example. That example uses code in the doHeaders methods of class BookCatalogPortlet that requires Liferay to be using OpenPortal. So when I try to add the Chapter 6 example portlet to Liferay it errors with a NullPointerException thrown from the doHeaders method.

I will see if I can install a different version of Liferay that is not using Tomcat but some other server and then see if I can get OpenPortal portlet container to work.

One big concern I have with your book and examples is that you are including code that goes beyond the JSR 286 standard (http://jcp.org/aboutJava/communityprocess/final/jsr286/index.html) and requires the portlet to be run inside a specific portlet container. Those examples I feel are at odds with explaining the JSR 286 portlet standard.

I think it would be much better to save the portal specific additions to much later chapters in the book. The first part of the book should be about explaining the standards and developing portlets that will run in any JSR 286 compliant portal container.

For example our University uses uPortal 3, which will soon adopt JSR 286. However, we won't be able to use your book for training our Java developers because the examples and much of chapters 5 and 6 include code/information that will not work in our portal container.

I respect your work on this book, but strongly urge you to reconsider the amount of non-standard portlet code you're including in your examples and then explaining in the chapters. Rather move all of that information to a chapter at the end of the book. That way readers who in their real work are NOT able to use the specific portal you're targeting (LifeRay) can still use your example portlets for learning and benefit from the majority of chapters in your book.

Additionally you should consider that not all your readers will be able to use OpenPortal Portlet container with LifeRay and will have the same problem I am. I'm on a MacBook pro, running OS 10.6 and using the Tomcat installation of LifeRay. When using the portlet container that comes with LifeRay everything works fine.

Bruce Phillips

Message was edited by:
phillips1021
LifeRay 5.2.2 with Tomcat 5.5 worked very well. I can deploy the chapter 6 example just fine after adding portal_ext.properties.

I will post the problem I had trying to get OpenPortal to work with LifeRay 5.2.3 and Tomcat 6.0.18 on Mac OS X (Snow Leopard) on the LifeRay forum.

Bruce
I'm using Liferay 5.2.3 with Tomcat

After following the directions in section 4.10, including restarting Liferay and redeploying the portlet applications, none of the portlets work. The stack trace for each deployment has this error:

java.io.FileNotFoundException: file:/Users/brucephillips/opt/Liferay/liferay-portal-5.2.3/tomcat-6.0.18/temp/web253526460103772001.xml (No such file or directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
at org.apache.xalan.transformer.TransformerIdentityImpl.createResultContentHandler(TransformerIdentityImpl.java:253)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:296)
at com.sun.portal.portletcontainer.warupdater.PortletWebAppUpdater.createUpdatedFile(PortletWebAppUpdater.java:305)
at com.sun.portal.portletcontainer.warupdater.PortletWebAppUpdater.addWebAppParam(PortletWebAppUpdater.java:216)
at com.sun.portal.portletcontainer.warupdater.PortletWarUpdater.preparePortlet(PortletWarUpdater.java:270)
at com.liferay.portal.tools.deploy.BaseDeployer.deployDirectory(BaseDeployer.java:440)
at com.liferay.portal.tools.deploy.BaseDeployer.deployFile(BaseDeployer.java:739)
at com.liferay.portal.tools.deploy.BaseDeployer.deployFile(BaseDeployer.java:676)
at com.liferay.portal.tools.deploy.BaseDeployer.deploy(BaseDeployer.java:407)
at com.liferay.portal.deploy.auto.PortletAutoDeployer.autoDeploy(PortletAutoDeployer.java:99)
at com.liferay.portal.deploy.auto.PortletAutoDeployListener.deploy(PortletAutoDeployListener.java:84)
at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.processFile(AutoDeployDir.java:196)
at com.liferay.portal.kernel.deploy.auto.AutoDeployDir.scanDirectory(AutoDeployDir.java:144)
at com.liferay.portal.kernel.deploy.auto.AutoDeployScanner.run(AutoDeployScanner.java:60)
14:38:22,806 INFO [PortletAutoDeployListener:87] Portlets for /Users/brucephillips/opt/Liferay/liferay-portal-5.2.3/deploy/UserRegistration.war copied successfully. Deployment will start in a few seconds.

Nothing happens after the line "Deployment will start in a few seconds..."

These portlets all worked before adding the portal-ext.properties file.

Bruce Phillips
Ashish:

First off I didn't properly thank you for posting these new chapters and example code. Even though I've been developing Portlet applications for the past year using the Portlet 1 API, I'm really learning alot just from the first three chapters in your book. The Portlet 2 API seems much more complete.

As I was reading about PortletSession in chapter 3 I got confused when I read the following on page 98:

QUOTE
SAMPLE CODE
Refer to BookCatalogPortlet and BookServlet classes to see how BOOK CATALOG portlet makes use of PortletSession to share search criteria between a portlet and a servlet in a portlet application.
UNQUOTE

I think it would be very helpful to readers if you could add some more information about where to look in the source code for the above.

As best I could tell from studying the BookCatalogPortlet and BookServlet classes you are not using PortletSession to share the search criteria.

Here is the code from BookCatalogPortlet method searchBook:

@ProcessAction(name = "searchBookAction")
public void searchBook(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
logger.info("Inside search Book action");
request.setAttribute("myaction", "searchBookAction");
PortletRequestDispatcher dispatcher = request.getPortletSession()
.getPortletContext().getRequestDispatcher(
response.encodeURL("/myservlet/bookServlet"));
dispatcher.include(request, response);
response.setRenderParameter("myaction", "showSearchResults");

// --store the search criteria in session
request.getPortletSession().setAttribute("authorNameSearchField",
request.getParameter("authorNameSearchField"),
PortletSession.APPLICATION_SCOPE);
request.getPortletSession().setAttribute("bookNameSearchField",
request.getParameter("bookNameSearchField"),
PortletSession.APPLICATION_SCOPE);
// retrieving the matchingBooks request attribute set by BookServlet and
// store it in session
request.getPortletSession().setAttribute("matchingBooks",
request.getAttribute("matchingBooks"));
}

The search criteria is stored in the PortletSession AFTER dispatching to the BookServlet class. In the BookServlet class is this code:

if(myaction != null && myaction.equalsIgnoreCase("searchBookAction")) {
logger.info("Searching for books with name : " + request.getParameter("bookNameSearchField") + " and author name : " + request.getParameter("authorNameSearchField"));
List<Book> matchingBooks = bookService.searchBooks(request.getParameter("bookNameSearchField"), request.getParameter("authorNameSearchField"));
request.setAttribute("matchingBooks", matchingBooks);
}

The above code gets the search criteria (book name and author name) out of the standard HttpServletRequest object, not out of the PortletSession scope.


I searched through the rest of the BookCatalogPortlet class and BookServlet class and don't see where you ever get the search criteria out of PortletSession scope.

Anyway this was a bit confusing for me.

Bruce
OK - I found where your code gets the search criteria back out of Session scope. It's when the user clicks on the Refresh Search Results link. Then the action value is "refreshResults" and this code in BookServlet's doGet method executes:

if (action != null && action.equalsIgnoreCase("refreshResults")) {
String bookNameSearchField = (String) request.getSession().getAttribute("bookNameSearchField");
String authorNameSearchField = (String) request.getSession().getAttribute("authorNameSearchField");

if(bookNameSearchField == null) {
bookNameSearchField = "";
}
if(authorNameSearchField == null) {
authorNameSearchField = "";
}
logger.info("Searching for books with name : " + bookNameSearchField + " and author name : " + authorNameSearchField);
List<Book> matchingBooks = bookService.searchBooks(bookNameSearchField, authorNameSearchField);
request.setAttribute("books", matchingBooks);
RequestDispatcher dispatcher = request
.getRequestDispatcher("/WEB-INF/jsp/home.jsp");
dispatcher.include(request, response);
}

So the values for authorNameSearchField and bookNameSearchField that you put into the PortletSession in class BookCatalogPortlet are pulled out of the normal HttpSession in the Servlet.

After reading several times pages 94-99, I suggest you move the Sample Code statement from page 98 to page 94 before the paragraph starting "If Servlets/JSPs included by your portlet needs to access PORTLET_SCOPE session attributes..." since your example code is using APPLICATION_SCOPE and then getting the values directly out of HttpSession scope in the Servlet. I would also add more detail on where the reader should look in the code for the statements that illustrate what you're explaining on page 94.


Bruce
I removed the doctype declaration from liferay-display.xml and rebuild the chapter 3 book catalog portlet.

I did get the same error when liferay tried to register the portlet:

Here is the stack trace:

12:53:26,381 INFO [PortletAutoDeployListener:87] Portlets for C:liferayliferay-portal-5.2.3deploych3_BookCatalog.war copied successfully. Deployment will start in a few seconds.
[12:53:46.819] {resin-17} C:liferayliferay-portal-5.2.3 esin-3.1.8webappsch3_BookCatalogWEB-INFclassescontentLanguage-ext.properties time is modified.
[12:53:46.834] {resin-17} WebApp[http://localhost:8080/ch3_BookCatalog] stopping
[12:53:46.834] {resin-17} SessionImpl[abcUJePypDi_CfzU2xLxs,/ch3_BookCatalog] LRU while in use (use-count=4). Consider increasing session-count.
12:53:46,834 INFO [PortletHotDeployListener:381] Unregistering portlets for ch3_BookCatalog
12:53:46,834 INFO [PortletHotDeployListener:412] 1 portlet for ch3_BookCatalog was unregistered
12:53:47,053 INFO [PortletHotDeployListener:227] Registering portlets for ch3_BookCatalog
12:53:47,053 WARN [SAXReaderImpl:441] XSD validation is diasabled because SAX2 driver class org.apache.xerces.parsers.SAXParser not found
12:53:47,053 WARN [SAXReaderImpl:441] XSD validation is diasabled because SAX2 driver class org.apache.xerces.parsers.SAXParser not found
12:53:47,069 WARN [SAXReaderImpl:441] XSD validation is diasabled because SAX2 driver class org.apache.xerces.parsers.SAXParser not found
12:53:47,116 WARN [SAXReaderImpl:441] XSD validation is diasabled because SAX2 driver class org.apache.xerces.parsers.SAXParser not found
12:53:47,116 ERROR [HotDeployUtil:111] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for ch3_BookCatalog
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for ch3_BookCatalog
at com.liferay.portal.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:5smilie
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:130)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:10smilie
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:153)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:43)
at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(PortletContextListener.java:113)
at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitableUtil.java:4smilie
at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:109)
at com.caucho.server.webapp.WebApp.start(WebApp.java:1866)
at com.caucho.server.deploy.DeployController.startImpl(DeployController.java:667)
at com.caucho.server.deploy.DeployController.restartImpl(DeployController.java:630)
at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.alarm(StartAutoRedeployAutoStrategy.java:177)
at com.caucho.server.deploy.DeployController.handleAlarm(DeployController.java:789)
at com.caucho.util.Alarm.handleAlarm(Alarm.java:375)
at com.caucho.util.Alarm.run(Alarm.java:345)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:730)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:649)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.liferay.portal.SystemException: com.liferay.portal.kernel.xml.DocumentException: Error on line 3 of document : Document is invalid: no grammar found. Nested exception: Document is invalid: no grammar found.
at com.liferay.portal.service.impl.PortletLocalServiceImpl.getWARDisplay(PortletLocalServiceImpl.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy58.getWARDisplay(Unknown Source)
at com.liferay.portal.service.PortletLocalServiceUtil.getWARDisplay(PortletLocalServiceUtil.java:126)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:272)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:127)
... 16 more
Caused by: com.liferay.portal.kernel.xml.DocumentException: Error on line 3 of document : Document is invalid: no grammar found. Nested exception: Document is invalid: no grammar found.
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:377)
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:38smilie
at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:156)
at com.liferay.portal.service.impl.PortletLocalServiceImpl._readLiferayDisplayXML(PortletLocalServiceImpl.java:827)
at com.liferay.portal.service.impl.PortletLocalServiceImpl.getWARDisplay(PortletLocalServiceImpl.java:163)
... 32 more
I downloaded from your Google code site the examples for chapter 1-5.

I attempted to build and use the Chapter 3 Book Catalog portlet.

I updated the build.properties to the location of where I installed the Liferay Portal version 5.2.3.

I executed the build target. The war file was created and copied to the Liferay portal deploy folder.

The following error message appears in the console when Liferay attempts to register the portlet:

11:59:46,368 ERROR [HotDeployUtil:111] com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for ch3_BookCatalog
com.liferay.portal.kernel.deploy.hot.HotDeployException: Error registering portlets for ch3_BookCatalog
at com.liferay.portal.deploy.hot.BaseHotDeployListener.throwHotDeployException(BaseHotDeployListener.java:5smilie
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:130)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._doFireDeployEvent(HotDeployUtil.java:10smilie
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil._fireDeployEvent(HotDeployUtil.java:153)
at com.liferay.portal.kernel.deploy.hot.HotDeployUtil.fireDeployEvent(HotDeployUtil.java:43)
at com.liferay.portal.kernel.servlet.PortletContextListener.portalInit(PortletContextListener.java:113)
at com.liferay.portal.kernel.util.PortalInitableUtil.init(PortalInitableUtil.java:4smilie
at com.liferay.portal.kernel.servlet.PortletContextListener.contextInitialized(PortletContextListener.java:109)
at com.caucho.server.webapp.WebApp.start(WebApp.java:1866)
at com.caucho.server.deploy.DeployController.startImpl(DeployController.java:667)
at com.caucho.server.deploy.StartAutoRedeployAutoStrategy.startOnInit(StartAutoRedeployAutoStrategy.java:72)
at com.caucho.server.deploy.DeployController.startOnInit(DeployController.java:549)
at com.caucho.server.deploy.DeployContainer.update(DeployContainer.java:227)
at com.caucho.server.deploy.ExpandDeployGenerator.deploy(ExpandDeployGenerator.java:543)
at com.caucho.server.deploy.ExpandDeployGenerator.request(ExpandDeployGenerator.java:491)
at com.caucho.server.deploy.ExpandDeployGenerator.handleAlarm(ExpandDeployGenerator.java:1005)
at com.caucho.util.Alarm.handleAlarm(Alarm.java:375)
at com.caucho.util.Alarm.run(Alarm.java:345)
at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:730)
at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:649)
at java.lang.Thread.run(Thread.java:619)
Caused by: com.liferay.portal.SystemException: com.liferay.portal.kernel.xml.DocumentException: Error on line 3 of document : Document is invalid: no grammar found. Nested exception: Document is invalid: no grammar found.
at com.liferay.portal.service.impl.PortletLocalServiceImpl.getWARDisplay(PortletLocalServiceImpl.java:166)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy58.getWARDisplay(Unknown Source)
at com.liferay.portal.service.PortletLocalServiceUtil.getWARDisplay(PortletLocalServiceUtil.java:126)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.doInvokeDeploy(PortletHotDeployListener.java:272)
at com.liferay.portal.deploy.hot.PortletHotDeployListener.invokeDeploy(PortletHotDeployListener.java:127)
... 19 more
Caused by: com.liferay.portal.kernel.xml.DocumentException: Error on line 3 of document : Document is invalid: no grammar found. Nested exception: Document is invalid: no grammar found.
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:377)
at com.liferay.portal.xml.SAXReaderImpl.read(SAXReaderImpl.java:38smilie
at com.liferay.portal.kernel.xml.SAXReaderUtil.read(SAXReaderUtil.java:156)
at com.liferay.portal.service.impl.PortletLocalServiceImpl._readLiferayDisplayXML(PortletLocalServiceImpl.java:827)
at com.liferay.portal.service.impl.PortletLocalServiceImpl.getWARDisplay(PortletLocalServiceImpl.java:163)
... 35 more

To fix this problem I added the following DOCTYPE declaration to liferay-display.xml:

<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 5.2.0//EN" "http://www.liferay.com/dtd/liferay-display_5_2_0.dtd">

After adding the above to liferay-display.xml the chapter 3 Book Catalog portlet is registered without a problem by Liferay and can then be added to a portal page in Liferay.

However when trying to add the Book Catalog portlet to a Liferay portal page I then get the following error

Caused by: java.lang.NullPointerException
at chapter03.code.listing.base.BookCatalogPortlet.showBooks(BookCatalogPortlet.java:115)



Bruce Phillips

Message was edited by:
phillips1021
Did you see my note in the original post about having to add the DOCTYPE declaration to liferay-display.xml to fix the initial problem I had--Liferay could not register the portlet?

You may want to add that DOCTYPE declaration to the liferay-display.xml files in the source code for the chapter examples.

Bruce
I'm using Liferay Portal 5.2.3 with Resin
The Chapter 3 Book Catalog portlet application is working now. I restarted Liferay and the catalog variable is no longer null.

Bruce
Reference Chapter 3, pages 90-93

I'd previously read in other blogs that it is a best practice to nest all styles being applied to a specific portlet so as not to interfere with the styling of HTML in other portlets should those other portlets have the same selector, id or class selector.

In your chapter 3 example you style the anchor class selector. Won't your styling of the anchor class selector in an external style sheet--which you add to the head section of the portal page--effect any other portlets that might also have an anchor class selector?

Rather in your external style sheet you could use

.myportletname .anchor

Then surround your jsp markup with a <div class="myportletname"> </div> and the .anchor class style you've created for that portlet will only be applied to that portlet and no other portlets even if those portlets have defined an anchor class selector.

This become even more important when styling common HTML elements (e.g. h1, h2, p, etc.). If you don't nest those styles then your styling of h1 for your portlet could change the appearance of the h1 tag in other portlets.

Bruce Phillips
Before I start, thank you for writing this book. There are not many books out that explain how to create portlet applications using the new 2.0 specifications.

I look forward to reading the rest of the chapters. I develop portlet applications as part of my job and I've already learned some things just from chapter 2.

One question I have is why did you decide to use Ant instead of Maven for the build process for the chapter example projects?

Using Maven you don't need to worry about including all the artifacts (e.g. jstl, log4j) in your source code download.

This would reduce your download size. Plus it will be much easier for readers to update the dependencies and transitive dependencies as newer versions of the artifacts are released (for example new version of the jstl jar).

I was able to replace your ant build.xml with a Maven pom.xml that is 30 fewer lines (including a goal to deploy the created war file to the Liferay deploy folder).

Anyway - thanks again for writing this book.

Bruce
Thank you for writing this book. There are not many good books out on developing portlet applications using the newer 2.0 specification.

For the chapter 2 example project, I think this part from UserRegistrationPortlet is a bit confusing due to the comment.

// -- if actionStatus is error then show the registration form populated
// -- with values that were entered by the user
if (!"error".equalsIgnoreCase((String) request
.getAttribute("actionStatus"))) {
request.setAttribute("email", defaultEmail);
}

The if statement tests for NOT "error" as the actionStatus. I think you could actually do away with the if statement and just have:

request.setAttribute("email", defaultEmail);

Given the test in the processAction method for if email is null or empty string, why would you not want to show the default email address again to the user?

Also in the processAction method perhaps you should add to the email test to test for if the user clicks on submit without changing the default email (otherwise the default email becomes the user's email).

In the formRegistration.jsp recommend you change:

<input type="text" name="firstName" value="${requestScope.firstName}"></input>

to:

<input type="text" name="firstName" value="${requestScope.user.firstName}"></input>

otherwise if you submit the form and processAction finds an error (e.g. email address missing) then when the form is rendered again the input fields don't have the user's original input for first and last name (make the same change as above for the lastName input field).

The processAction method sets the User user object on the request scope. There never is a firstName or lastName object in requestScope for the view page to use.

I'm enjoying your book and learned some new techniques (e.g. annotating processAction methods) from chapter 2. Thanks again.

Bruce Phillips
Ashish:

Reference section 9.1 - Why did you include in chapter 9 specific information on setting up Liferay's internal database to use MySQL? This is very Liferay specific and I don't think necessary for chapter 9's intent (integrating portlets with a database).

Why not just instruct the user how to use MySQL to setup a database that can then be used by the portlet?

Even if someone is using Liferay as his portal server it probably would not be a good practice to use the Liferay database for portlet specific database needs as that would limit the portability of the portlet and expose Liferay's internal database tables to database users who don't need access to them.

Section 9.1 is an example of Liferay specific information I think could be moved to an Appendix or chapter specifically on Liferay.

Bruce
Chapter 6 is very good. I had no problems with the example code or being able to follow your explanations.

I do think the material in chapter 6 should come after chapter 3. Chapters 4 and 5 interrupt the flow of presenting the basics of using the portlet 2.0 specification.
Reference chapter 4 section 4.7.3

The explanation of MyUrlGenerationListener doesn't work when running the code example. If I click on the Add Book button the portlet window is not maximized.

Bruce
Reference chapter 5. I didn't get much value out of this chapter since I don't use Liferay (we use uPortal). I understand the ideas you develop in chapter 5 about finding out the capabilities your portal container provides and taking advantage of them. But that knowledge is very container specific.

I think the information in chapter 5 should come much later in the book. There is still much to cover that is related to developing portlets across portal containers (such as portlet tags, how to correctly reference images, use JavaScript, incorporate CSS specific to a portlet, database interaction). I know you'll get to these topics eventually.

I really liked chapters 1-4, but 5 took me off track. I think chapters on the more universal portlet knowledge developers must have should come before what you've put in chapter 5.

Again thanks for writing this book and being so responsive to our posts. I will definitely be recommending this book to other Java developers. I look forward to the next chapters released.

Bruce
Chapter 10 is also very good.

But again I recommend this material be moved up in the book. I think the information in chapters 6 and 10 should follow chapter 3.

I don't understand why chapter 10 would be after the chapters on using Spring MVC to create portlets (chapters 7 and smilie.

If your readers aren't using Spring MVC then the material in chapters 7 and 8 isn't of value to them. But the material in chapter 10 will be useful for any portlet 2.0 developer.
Purchased the book.

Downloaded the source code on June 19 2011

Unzipped the download. It looks like some of the examples are Eclipse projects while others are not. The examples are organized in the Maven way, but some are missing the pom.xml

Tried to run the springidol-annotation example's test and get test failures.

Cannot figure out how to run the spitter-persistence-jpa test - it looks like the pom.xml is missing.

Very disappointed with the quality of the source code.
Downloaded and unzipped the source code.

Want to run the tests in spitter-persistence-jpa (under Spitter folder).

No README file available - no instructions on how to build, run the test, etc.

It is not an Eclipse project. It is organized in a Maven way but there is no pom.xml.

How can I run the JUnit test that is in src/test/java?
Running mvn test fails with Spring configuration errors. I think you need to add some @Qualifier annotations to your Instrumentatlist.java class since your Spring configuration file creates two Instrument beans. You probably also need to add an id to the Guitar bean.
The author and/or Manning publishers have shown a great deal of disrespect for those of us who purchased this book through MEAP. Chapter 5 is a complete waste of time. Why put something on MEAP that will so clearly be NOT in the book. The code examples and statements about JUnit are years out of date. JUnit 4 improves significantly how Spring can be used to inject dependencies into the test class.

Part of the reason, Manning allows people early access to its books is to get feedback for the author(s) and to build word-of-mouth amongst "early adopters."

Right now I'm warning my fellow developers away from this title based on the very poor work done so far on the 3rd edition.
In example 1.13 on page 19 pointcut should be pointcut-ref below:

<aop:config>
<aop:aspect ref="kryptonite">
<aop:pointcut id="superThings" >
expression="execution(* *.doSuperThings(..))"/>
<aop:around method="weakenSuperhero" pointcut="superThings"/>
</aop:aspect>
</aop:config>
Where is the source code?
Is the source code available for the chapters provided in the MEAP?
I downloaded the source code from the repository on google.

I unzipped the file.

In the root flexonjava folder I executed mvn install.

I get this build error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Failed to resolve artifact.

Missing:
----------
1) com.adobe.flex:compiler:pom:4.0.0.7219
Path to dependency:
1) org.sonatype.flexmojos:flexmojos-maven-plugin:maven-plugin:3.4.2
2) com.adobe.flex:compiler:pom:4.0.0.7219

2) com.adobe.flex.compiler:asdoc:zip:template:3.2.0.3958

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=com.adobe.flex.compiler -DartifactId=asdoc -Dversion=3.2.0.3958 -Dclassifier=template -Dpackaging=zip -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=com.adobe.flex.compiler -DartifactId=asdoc -Dversion=3.2.0.3958 -Dclassifier=template -Dpackaging=zip -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.sonatype.flexmojos:flexmojos-maven-plugin:maven-plugin:3.4.2
2) com.adobe.flex.compiler:asdoc:zip:template:3.2.0.3958

3) net.sf.saxon:saxon-dom:jar:9.0

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=net.sf.saxon -DartifactId=saxon-dom -Dversion=9.0 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=net.sf.saxon -DartifactId=saxon-dom -Dversion=9.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.sonatype.flexmojos:flexmojos-maven-plugin:maven-plugin:3.4.2
2) net.sf.saxon:saxon-dom:jar:9.0

4) org.graniteds:granite-generator:jar:1.1.0

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=org.graniteds -DartifactId=granite-generator -Dversion=1.1.0 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=org.graniteds -DartifactId=granite-generator -Dversion=1.1.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) org.sonatype.flexmojos:flexmojos-maven-plugin:maven-plugin:3.4.2
2) org.graniteds:granite-generator:jar:1.1.0

----------
4 required artifacts are missing.

for artifact:
org.sonatype.flexmojos:flexmojos-maven-plugin:maven-plugin:3.4.2

from the specified remote repositories:
flexmojos-repository (http://repository.sonatype.org/content/groups/public/),
flexonjava-repository (http://flexonjava.googlecode.com/svn/repository),
central (http://repo1.maven.org/maven2)

Please help.
It seems the authors hate Mac computers so they didn't take the time to test their source code and BeanShell on Mac. Here is what I had to do so far to get the BeanShell and Source code to run on my Mac.

You'll need to change this line in file /iWeb2/src/iweb2/util/config/iWeb2Config.java

if (osName.startsWith("Linux") ) {

to

if (osName.startsWith("Linux") || osName.startsWith("Mac")) {

Do the above before running the ant build.

Then after a successful ant build you'll need to modify the bsc.sh file:

Modify the bsc.sh file to be unix formatted instead of windows.


using vi open bsc.sh on your computer

execute this command in vi
:set fileformat=unix

make sure this line is IWEB2_HOME=/iWeb2 (note the / and the case of each letter - this is needed if you've copied the iWeb2 folder to your root)

:wq (to save and exit)

you then should be able to execute the script using ./bsc.sh

BTW to exit from the BeanShell use exit();

Bruce Phillips
University of Kansas
Luke:

You'll also need to change this line in file /iWeb2/src/iweb2/util/config/iWeb2Config.java

if (osName.startsWith("Linux") ) {

to

if (osName.startsWith("Linux") || osName.startsWith("Mac")) {

Do the above before running the ant build.

Bruce
Luke:

Had the same problem as you. First I had to modify the bsc.sh file to be unix formatted instead of windows.


note the forward slash in front of iWeb2 and also the case of each letter



using vi open bsc.sh on your computer

excute this command in vi
:set fileformat=unix

make sure this line is IWEB2_HOME=/iWeb2 (note the / and the case of each letter - this is needed if you've copied the iWeb2 folder to your root)

:wq (to save and exit)

you then should be able to execute the script using ./bsc.sh

Bruce
In the spring-idol.xml for chapter 4's example I uncomment this node:

<bean class="com.springinaction.springidol.JudgeAspect" >
factory-method="aspectOf">
<property name="criticismEngine" ref="criticismEngine" />
</bean>

and get an error that class com.springinaction.springidol.JudgeAspect cannot be found. The only file named JudgeAspect in package com.springinaction.springidol is JudgeAspect.aj which is not recognized as a Java class.

Has anyone got the AspectJ AOP example from the end of chapter 4 to work?
Found it here:

https://m2proxy.atlassian.com/repository/public/incubator-activemq/activeio-core/3.0-beta3/

and then used mvn install:install-file to install it to my local maven repository
It would be helpful to post an errata on the books website to point out the changes in the code necessary for the examples to work in the latest version of Spring.

In addition to the new XMLBeansFactory constructor, I also had to have commons-logging.jar from Jakarta-Apache in my class library path to get this class to run correctly.

Here is the HelloApp.java I used to get the first example (chapter 1) to work correctly:

package com.springinaction.chapter01.hello;

/**
*

Title: HelloApp.java


*
*

Description: Loads the Spring container and uses
* it to retrieve the greeting service. Then has the
* greeting service object call its sayGreeting method.
* From page 14-15 of Spring in Action


*
*

You must complile this class with the following jar
* files in your class library path: spring-beans.jar
* (from www.springframework.org) and
* commons-logging.jar from Jakarta-Apache
*
*

Date: Sept 2005


*
* @author Bruce Phillips
* @version 1.0
*/



//these are from the spring-beans jar


import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;

//this is from the spring-core.jar
import org.springframework.core.io.FileSystemResource;



public class HelloApp {


public static void main(String[] args) {

//create FileSystemResource Object using the XML configuration file
//hello.xml is stored in the project folder
//see page 14 of Spring in Action to read what
//hello.xml does

FileSystemResource configurationXMLFile =
new FileSystemResource("hello.xml");//hello.xml is in the project folder

//Start the Spring container
//using the FileSystemResource object for configuration
//The fileSystemResource object (built above using
//hello.xml file) tells the container to create an object of
//the GreetingServiceImpl class and then to call
//its setGreeting method to set the value of the greeting
//instance field
BeanFactory factory = new XmlBeanFactory( configurationXMLFile ) ;

//using the factory object created above
//get a reference to an object of the class
// that implements the GreetingService
//interface which mandates that the object have
//a fully defined sayGreeting method
//note the cast to a GreetingService object

GreetingService aGreetingService = (GreetingService)
factory.getBean("greetingService") ;

aGreetingService.sayGreeting();


}//end main method

} //end class HelloApp