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.

Map stadiumMap = [:]

how does : helps here, since it is declared Map.,

1) do : means declaring empty key and value.
2) : goes togather with Map.
Page-33

Geocoder geo = new Geocoder()
stadiums.each { s ->
geo.fillInLatLng s
db.execute """
insert into stadium(name, city, state, team, latitude, longitude)
values(${s.name},${s.city},${s.state},
${s.team},${s.latitude},${s.longitude});
"""
}

what's meaning of above bold code- what i can understand here is.
1) s -> is declared.
2) geo.fillInLatLng s. s here is being assigned value.
Thanks Ken.
The stadiums variable is initialized to an empty java.util.ArrayList. The left-shift
operator has been implemented in Collection to be an append method, so the rest
of the listing instantiates each of the MLB stadiums and appends it to the list.

I wonder why left shift operator is append rather than right shift operator? It's just a design of Groovy syntax.
Thanks Ken for reply.

Here we are talking about 2 defaults.

1) One at package level which is present in Java. This is package private.
2) 2nd at class level- default for getters/setters which is absent in Java.

if above 2nd default is missing- does it really means it makes the 1st default feature useless?
That’s another “duh” moment. The default access in Java is “package private,” which means the member is accessible from any other class in the same subdirectory. In roughly 15 years of Java coding I’ve used this access deliberately may be twice, and both times there were reasonable alternatives. I can understand trying to create some sort of friend access, but why make it the default? Once again, Groovy does what makes sense.


Sorry didn't understood above point. I thought making default makes its better like Groovy where default things happen without declaration like getter/setter methods.
I'm not sure if i am labeling this right. In below examples, we are using closure inside closure hence subclosures.

SwingBuilder.edt {
frame(title:'Hello, World!', visible:true, pack: true,
defaultCloseOperation:WC.EXIT_ON_CLOSE) {
label(icon:new ImageIcon("$base$qs".toURL()),
constraints:BL.CENTER)
}
}

After the parentheses there’s another closure. That’s interpreted to mean I’m
about to supply components that will be added to the JFrame instance.

“about to supply components” - What this means technically. edt i can understand is method.
How about defaultCloseOperation:WC.EXIT_ON_CLOSE.
Thanks Ken for clarification.

Every closure has a delegate which is used to resolve method calls.

1) Can you please let know who is delegate here and method calls are happening inside to out or out to inside?

2) What do label means to frame?
This point “Groovy has native syntax for lists and maps. ” that groovy is using native syntax.

What is the significance of being native.
very cool. Thanks Ken.
thanks for reply.

why is it called dummy arguments?

after all they are useful, they hold the values.
Thanks for your reply.
I get your example.
Another one- In the closure applied to the map in the current example, the two dummy arguments are k and v, which represent the key and value of each entry. They represent the value, but there names are dummy arguments.

Honestly i feel dummy is something which is of no use.
Isn't closure syntax little intuitive.
Page-16

Repetition of sentences in same context.

Example- No one is ever going to suggest rewriting Spring in Groovy.

Page-4

Nobody is ever going to rewrite, say, the Spring Framework, in Groovy.

No big deal.
Chapter-2

Page-19

Because every programming language book is required by law to include a “Hello,
World!” program, here’s Groovy’s version:
println 'Hello, World!'

I know what author means here. But it isn't law its custom tradition going on with every java programming book.
Page-11 Java includes the checked exceptions.

What's the point here how Groovy helps us here.
Page-13

Can't tell from the code which is spread dot operator.
2)
Page-3
Is really Java used to build the basic infrastructure of servers?

I think infrastructure is the physical hardware used to interconnect computers and users.
Page-10

If the reference is null it invokes the size method here.

Why it will invoke the method on null reference?
1)
As the reader reads from Page 3 to Page 4 sequentially, figure 1.1 shows up on the top. When the reader open page 4, suddenly it talks about bytecode- it confuses instantly momently a bit- not really big deal. The figure should be placed after its explanation.

Message was edited by:
boy18nj

Message was edited by:
boy18nj
Page-9

I provide the closure as the implementation of the Comparator interface.

I believe its Comparable interface.

Here I show the two
dummy arguments, s1 and s2, to the left of the arrow, and then use them on the right side.
What is the use of "->"
Page-19

Groovy is all about simplicity and understandability.

I see the Groovy code is pretty tough to read/understand when it uses combination of collect, each, closure. Especially inside closures, when semi-colons are not used, it confuses it next line is part of previous line or new line. May be since I'm newbie to Groovy- there is a bit curve to learn.
4)
Page-7
Unlike Groovy, Java does not have native support for collections. So what's the point eventually collections support was added even if not native.
Page-30

Because I’m working with Groovy,
and Groovy works well with XML, I’ll use the xml value.

It should be like this- Since I’m working with Groovy,
and Groovy works well with XML, I’ll use the xml value.

It actually confused me for a moment. I had to read the line twice.
3)
Guiding Principle:
Java is great for tools, libraries, and infrastructure. Groovy is great for everything else.

It's like blunt statement. Not sure what is meant Groovy is great for everything else.
As i am newbie to spring framework. And i am looking for job in Spring- would you please suggest me which book should i buy?

Also i am SCBCD, so how tough it will be for me 2 grab Spring.
When I run this script, it solved the issue and it is returning 6 matched elements as expected-

$("div img[src$='jpg']").addClass("wrappedElement");

Now I am more confused, in case of href, it is a child of li which is further child of ul. We does not need to iterate thru the hierarchy in order to run this-

$("a[href^='http://']").addClass("wrappedElement");

Then why we need to iterate when finding img src value 'jpg'?
If I run this script-
$("a[href^='http://']").addClass("wrappedElement");

It shows 1 matched element, which is correct.

But if run-
$("img[src^='images']").addClass("wrappedElement");

It shows 0 matching elements, I expected 6 matched elements to be displayed.

Why I do see this discrepancy in results?
It worked using this-


$(function(){
$("span input[id$='employeeDateSearch:j_id22:ssn']")
.bind('click', function(event){say('BOOOM input')});
});
It turns out, jQuery selector is unable to find out id name when it contains colon.

Is there workaround around it, i guess it may be regular expressions to the rescue.
input tag is defined as-


<span class="value">
<input id="employeeDateSearch:j_id22:ssn" type="text" name="employeeDateSearch:j_id22:ssn"/>
</span>


Event binding is done as follows-

<script type="text/javascript">
$(function(){
$('#employeeDateSearch:j_id22:ssn')
.bind('click', function(event){say('BOOOM input')});
});

</script>


If I click inside input field, nothing happens.
I have just finished reading this book. I really liked the power of jQuery, how it really makes easy to manipulate the dom tree, write wrapper functions and writing the unobtrusive JavaScript.

I skipped some chapters 10 and 11, as they purely discuss about widgets. I will come back to them whenever I do need them.

I did run all the labs code provided. Due to my laziness, I missed the exercises. I read the book without practically writing any code, so pushing myself to do it now.

Overall, I enjoyed reading this book. In simplifying & explaining the jQuery, kudos to authors. Very well written book to the readers taste.

As in my current project we use rich faces, I want to harness its power when used with rich faces.
I have seen in the past, Java applets do help us in iterating through local PC tree folder structure.

I am currently looking for same support in jQuery so that we can iterate tree folder structure through web. It appears it is not currently supported.
In the book, there is no mention of IDE, which should provide provide code completion and suggestions for jQuery methods. Given that there are so many methods available in jQuery, the developer cannot always goto documentation or book to find out the correct syntax.

Things become specially interesting when you are dealing with $.extend(options) because you don't know what property-values are expected under options.
thanks for reply. As you described so many, I am looking for at least 1 or 2. What are the author's choice or which IDE do you recommend for developers in terms of nice code completion support?
thanks for reply. I assume speed overlaps easing at some point of time.
I am running lab exercises for chapter-9, I could not figure out difference between speed and easing. It is hard to notice difference when you change the value of easing.
I would request authors if they can share light on this thread.
Since Lucene is new to me, I expect to run the code examples to understand clearly. To make sense out of new programs introduced, I need to run them.

Example-

public void testSlop() throws Exception {
Query q = new QueryParser(Version.LUCENE_30,
"field", analyzer)
.parse(""exact phrase"");
assertEquals("zero slop",
""exact phrase"", q.toString("field"));
QueryParser qp = new QueryParser(Version.LUCENE_30,
"field", analyzer);
qp.setPhraseSlop(5);
q = qp.parse(""sloppy phrase"");
assertEquals("sloppy, implicitly",
""sloppy phrase"~5", q.toString("field"));
}

Above code snippet is from Chapter-3, I could not find out this code anywhere in the source code attached, where can I locate this code?

Also if you run ant -p, you see different target's available, I cannot figure out which target belong to which chapter. It would be much appreciated if a list is provided which highlights this code refers to chapter,3,4,5 etc.

Please clear these 2 doubts, it is becoming so tough to understand from chapter-3 onwards.

Thanks
as a NumericField with the integer value 201,003

should be changed to-


as a NumericField with the integer value 201003
TopDocs docs = searcher.search(query, 1);
assertEquals(10, docs.totalHits);

should be

TopDocs docs = searcher.search(query, 10);
assertEquals(10, docs.totalHits);
It is surprising, I could not anywhere track the class file org.apache.nutch.analysis.NutchDocumentAnalyzer.

Please tell what is the name of jar file?

Message was edited by:
boy18nj
I got the code finally, seems IntelliJ idea cannot look into subdirectories when you add libraries as jar files.
Yesterday I have started reading this book. Thanks to authors for writing this book.

I am pretty much beginner to Lucene world. Here is my feedback on the book-

Chapter-1 Very clearly written, I can clearly understand how Lucene works and its flow of working, too helpful. Indexer and Searcher programs provide me an opportunity to get in touch.

Chapter-2 Everything goes smooth until the topic Field options start. I am completely lost, so many new terms are introduced which is natural. Finding it hard to keep track of new terms introduced because they are referred again and again further down the stream.

Example-
Field.Index.NOT_ANALYZED
Field.Index.ANALYZED
Field.Index.NO
Index.ANALYZED
Index.NOT_ANALYZED
Index.ANALYZED_NO_NORMS

I cannot make out difference in between them or better to say remember them.
It would be an excellent if the reader was shown the index generated file when tweaking these options to different values. Then in first reading I would have remembered what we are really talking about.

I believe doing so would have lengthened the book. For now, I need to concentrate reading it.
Thanks for your book. I will start reading ur 2nd edition book from today. I hope it will help much when i am working with Spring.
Is it also possible to meet you in NJ?
I am wondering how to provide this link.

Project Structure is-

ABC.EAR
DEF.WAR
GHI.WAR

Inside GHI.war, i want to access the RptCatgry.xhtml.

My code looks like this-
<rich:menuItem submitMode="none">
<s:link view="/GHI/CollatRptCatgry.xhtml" value="Screens" />
</rich:menuItem>

But it would end in displaying 404 error-

The requested resource (/DEF/GHI/CollatRptCatgry.seam) is not available.

Is there redirect or link possible to call xhtml in another war deployed in the same ear?
I am actually new to ESB stuff. So is this book ESB in action, a perfect start for me.
The bottom of the page says-

The HTML markup consists of a container that holds the thumbnail images C,
an image element (initially sourceless) to hold the full-sized photo D, and a collection
of images E that will control the slideshow. Everything else is handled by our
new plugin.

should be

The HTML markup consists of a container that holds the thumbnail images C,
an image element (initially sourceless) to hold the full-sized photo D, and a collection
of controls E that will control the slideshow. Everything else is handled by our
new plugin.

I think it would be more accurate to say "a collection of controls"
Definitely it reads better
I am totally confused by the concept of the owner of the relationship-

example-

Car.java content has
-------------------------
@ManyToMany
protected Set<CarItems> carItems;


CarBids.java content has
-------------------------
@ManyToOne
protected Car car;

Now i want to now out of these two classes, who is the owner of the relationship.

Actually book is confusing me.
Thanks in Advance.
here is my entity class-

import java.io.Serializable;

import javax.persistence.Embedded;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.Table;
import javax.persistence.Column;


@Entity
//@Table(name="Car")
//@IdClass(CarPK.class)
public class Car implements Serializable{


/**
*
*/
private static final long serialVersionUID = 1L;
private String horn;
private String id;
private String steering;
private String chasis;

public Car(){
}

public Car(String horn, String steering, String chasis){
this.horn = horn;
this.steering = steering;
this.chasis = chasis;
}

public Car(String horn){
this.horn = horn;
}

@EmbeddedId
protected CarPK carPK;

@Embedded
protected CarAddress carAddress;
}

Mine CarPK class

import java.io.Serializable;

import javax.persistence.Embeddable;

@Embeddable
public class CarPK //implements Serializable
{

private static final long serialVersionUID = 1L;
private String horn;
private String id;
private String steering;
private String chasis;

public CarPK(){}

public boolean equals(Object other){
System.out.println(" equals method is called");
if (other instanceof CarPK){
final CarPK carPK = (CarPK)other;
return (carPK.equals(chasis) && carPK.equals(horn) && carPK.equals(steering) && carPK.equals(id));
}
else {
return false;
}
}

public int hashCode(){
return super.hashCode();
}

}


and when i try to execute my client code, it gives me exception like this in database-

[#|2008-11-16T15:52:11.753-0500|WARNING|sun-appserver9.1|oracle.toplink.essentials.session.file:/C:/Sun1/AppServer/domains/domain1/applications/j2ee-modules/text_ejb_simple1/-actionBazaar.transaction|_ThreadID=31;_ThreadName=p: thread-pool-1; w: 28;_RequestID=2894dd00-ac90-4936-8b6e-a2fd7c3f93b9;|
Local Exception Stack:
Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.0.1 (Build b04-fcs (04/11/200smilie)): oracle.toplink.essentials.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: Column name 'ID' appears more than once times in the column list of an INSERT statement.
Error Code: -1
Call: INSERT INTO CAR (STEERING, CHASIS, ID, HORN, ID, STEERING, CHASIS, HORN, CITY, STATE, STREETLINE2, ZIPCODE, STREETLINE1, COUNTRY) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
bind => [null, null, null, black steerings, null, null, null, black steerings, null, null, null, null, null, null]
Query: InsertObjectQuery(Car@29e202)



please let me know what i am doing wrong...
public class CategoryPK implements Serializable {
String name;
Date createDate;
Listing 7.2 Specifying category identity using IdClass
B Stored identity fields


public CategoryPK() {}
public boolean equals(Object other) {
if (other instanceof CategoryPK) {
final CategoryPK otherCategoryPK = (CategoryPK)other;
return (otherCategory.name.equals(name) &&
otherCategoryPK.createDate.equals(createDate));
}
return false;
}
public int hashCode() {
return super.hashCode();
}
}
@Entity
@IdClass(CategoryPK.class)
public class Category {
public Category() {}
@Id
protected String name;
@Id
protected Date createDate;
...
}


---------------------
1) i am unable to understand how this method works because inside the method public boolean equals(Object other), even i tried to put System.out.println, but when i checked the logs, this method was never called, so i want to understand, when this is used.


2) as the need for this method was for specifying the composite key's,
but even by using the first approach by using @Id on multiple instances work's i am able to see the composite keys in the database, so then why it is useful.
also under log's i am unable to see those system.out's happening inside @PostConstruct
package pack;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.interceptor.AroundInvoke;
import javax.interceptor.InvocationContext;

public class AccountCreatorLogger {


@PostConstruct
public void initialize(InvocationContext ic) throws Exception{
System.out.println("Entering the method name " + ic.getMethod().getName());
System.out.println("Getting the parameters " + ic.getParameters());
System.out.println("Getting the target " + ic.getTarget());
System.out.println("Getting the context data " + ic.getContextData());
ic.proceed();
}

@PreDestroy
public void cleanUp(InvocationContext context){

}




@AroundInvoke
public Object logMethodEntry(InvocationContext ic)throws Exception{
System.out.println("Entering the method name " + ic.getMethod().getName());
System.out.println("Getting the parameters " + ic.getParameters());
System.out.println("Getting the target " + ic.getTarget());
System.out.println("Getting the context data " + ic.getContextData());
return ic.proceed();


}
}

-------------
my doubt here is why do the compiler complain's if i add annotated method @AroundInvoke before @PostConstruct or @PreDestroy.
R
under glassfish- webservices, it shows a button Test,

when clicking on that link, it open url-

http://localhost:8080/PlaceBidService/ItemManagerBean?tester

here it shows 404 error.

when you are saying, check the status for Web Service, which screen name, you are specifying particularly...
i am trying to invoke web service for ItemManagerBean...

from web services on glassfish- i am getting error 404 not found...
even if i see WSDL- it gives 404 error.

here is my ItemManagerBean

---------------------
@WebService(serviceName="ItemManagerService", targetNamespace = "urn:ActionBazaarItemManagerService")
@SOAPBinding(style = SOAPBinding.Style.DOCUMENT)
@PersistenceContext(unitName="actionBazaar",name="actionBazaar")
@Stateless
public class ItemManagerBean implements ItemManager {
// @PersistenceContext(unitName = "actionBazaar")
private EntityManager em;


public ItemManagerBean() {
}

@WebMethod
@WebResult(name = "itemName")
public String findItemByItemName(@WebParam (name ="Name")String item_name){
Query query = em.createNativeQuery("select * from item where item_name = ?1");
query.setParameter(1, item_name);
return (query.getResultList()).toString();
}
--------------------------------

i am deploying it as a JAR file...it is not working for me.

in the same waty, if i deploy chapter 15- it works for me.

i was unable to find the differences .

Let me know what i am missing- which is causing it not to generate WSDL file and also giving 404 error...
Debu,

i might be wrong, it's better someone at your side, try to run in any example from chapter 8 onwards,


for glassfish code, creating fresh table's using the example's...

it's better not to curb the problem without verifying it...

i might be wrong...

the problem is only of inserting the data in the table's...then next hope so will work withiout any error...
yes, i understand, this is a solveable problem-

the same problem for inserting data in table's is in chapter-13

the thing is,i am spending my majority of time in errors, instead of understanding the code how it is working!

i think this needs a immediate attention...
i have got these sql scripts in the order to drop all the table's-

----
DROP TABLE "APP"."BIDS";

DROP TABLE "APP"."CATEGORIES_ITEMS";

DROP TABLE "APP"."ITEMS";

DROP TABLE "APP"."ITEMS";

DROP TABLE "APP"."SHIPPING_REQUESTS";

DROP TABLE "APP"."CATEGORIES";

DROP TABLE "APP"."USERS";

DROP TABLE "APP"."BILLING_DETAILS";

DROP TABLE "APP"."CONTACT_DETAILS";

-------------------------

but this dosen't works when you try to insert the data in the table's...using the same sequence...

I have checked out, already there is a such issue Apache Derby Database,,,

this issue has been addressed here-

http://issues.apache.org/jira/browse/DERBY-1645


most of the time anywhere i am stuck, i just find out issue's with this Apache Derby Database...

Isn't Oracle XE is more a reliable database without any issues?
i am trying to run the example's using the ant script's-

when running this program-
BazaarAdminClient.java

it will give exception's- because insert statement's that have been made, when executed, will give cause constraint error's.

even the insert statement' have been made, are causing such problem's.

there have been so many relationship's between them like two table's have each other's imported and exported key's- they are both dependent upon each other, so it is impossible to insert data between them, that's why BazaarAdminClient is giving exception's...

the way table's have been made- like CATEGORIES_ITEMS, CONTACT_DETAILS, ITEMS, USERS, CATEGORIES, BILLING_DETAILS and BIDS,

they have so many imported keys and exported key's....so even the example is not running in this program-

i was just drawing the graph for relationship between them, it has so many line's going here and there- making it confusing to understand....

can you suggest me, in which order i should run these insert statment's so that it will not give me constraint exception's...?

these are the Apache Derby Database Script's

---------------
INSERT INTO "APP"."BIDS" (BID_ID,BID_PRICE,BID_DATE,BID_ITEM_ID,BID_BIDDER) VALUES (0 /*not nullable*/,0,{d '2008-10-19'},0,'s');


INSERT INTO "APP"."BILLING_DETAILS" (BILLING_ID,EXPIRY_DATE,ACCOUNT_NO,SECRET_CODE,STREETNAME1,STREETNAME2,COUNTRY,CITY,STATE_CD,ZIP_CD) VALUES (0 /*not nullable*/,'s','s','s','s','s','s','s','s','s');


INSERT INTO "APP"."CATEGORIES" (CATGEORY_ID,CATEGORY_NAME,CATEGORY_VALUE) VALUES (0 /*not nullable*/,'s',0);


INSERT INTO "APP"."CATEGORIES_ITEMS" (CI_ITEM_ID,CI_CATEGORY_ID) VALUES (0 /*not nullable*/,0 /*not nullable*/);


INSERT INTO "APP"."CONTACT_DETAILS" (CONTACT_USER_ID,EMAIL,PHONE,STREETNAME1,STREETNAME2,COUNTRY,CITY,STATE_CODE,ZIP_CODE) VALUES ('s' /*not nullable*/,'s','s','s','s','s','s','s','s');

INSERT INTO "APP"."ITEMS" (ITEM_ID,INITIAL_PRICE,ITEM_NAME,BID_START_DATE,BID_END_DATE,CREATED_DATE,SELLER_ID) VALUES (0 /*not nullable*/,0,'s',{ts '2008-10-19 01:54:10.189'},{ts '2008-10-19 01:54:10.189'},{ts '2008-10-19 01:54:10.189'},'s');


INSERT INTO "APP"."USERS" (USER_ID,USER_TYPE,BIRTH_DATE,FIRST_NAME,LAST_NAME,USER_BILLING_ID,CREDIT_RATING,BIDDER_STATUS,MAX_ITEMS,COMM_RATE) VALUES ('s' /*not nullable*/,'s',{d '2008-10-19'} /*not nullable*/,'s' /*not nullable*/,'s' /*not nullable*/,0,0,'s',0,0);
---------------------------------------

let me know in which order i should run these---
i am left with 6 chapter's. As also i am preparing for SCBCD, do get time's at weekend's only, when done will let you knowm, as for glassfish code,

i have done following modifcation's so far-

1) i have to replace all sql script's with Apache Derby database syntax script's.

2) as i am running example's from eclipse console, just made it user friendly.

I am calling all bean's using JNDI lookup. I am not sure if you will like this change.

the only change made here is just added -jndi lookup code, no other modification's in every chapter.

if this work's for you, it is great...
i already have made, first 10 chapter's eclipse code. All glassfish code example's ANT script's - are replaced wiith running code example's from eclipse console.
i am using GlassFish Server and Oracle TopLink JPA.
i am unable to understand this events-

in my Itemss.java

these are the line's(i have skipped the other part here-)

-----------------------------------------
@Entity
@Table(name="ITEMSS")


@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "item_id", nullable = false)
// it will generate new value's going on going on...
public int getItem_id() {
return item_id;
}


@Column(name ="item_name")
public String getItem_name() {
return item_name;
}


@Column(name = "item_value")
public int getItem_value() {
return item_value;
}

--------------------------------------------------------------

on first glance, it suggests that this should create a table ITEMSS with 3 column's
but in relaity it is creating 4 column's.

I am not able to make out, how this 4th column is made and it has all null value's?.

from the log-

CREATE TABLE ITEMSS (item_id INTEGER NOT NULL, item_name VARCHAR(255), item_value INTEGER, ITEM_item_id INTEGER, PRIMARY KEY (item_id))"
if you look at your exception log

-----------------------------------------------
exec] JDO76609: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL, PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'.
-----------------------------------------------

it is creating a table in schema APP.
how you are making sure, there is no table present's in schema APP?

i don't think so this warning will harm you, you can run your example here safely.
ok for Apache Derby, i got it's syntax how to drop table's

This might be useful for other's too-

--------------------
DROP TABLE "APP"."CATEGORIES_ITEMS";

DROP TABLE "APP"."CONTACT_DETAILS";

DROP TABLE "APP"."BILLING_DETAILS";

DROP TABLE "APP"."BIDDERS";

DROP TABLE "APP"."BIDS";

DROP TABLE "APP"."CONTACT_DETAILS";

DROP TABLE "APP"."ITEMS";

DROP TABLE "APP"."SEQUENCE";

DROP TABLE "APP"."USERS";

DROP TABLE "APP"."CATEGORIES";

------------------------------------------------------

these statement's have to run in the order, which has dependent FK_COLUMN_NAME's.

Thanks
So now the question arises, i should delete the exisitng table's, if i want to run this example.

the sql script's given are-

--------------------------------------------------------
DROP TABLE CATEGORIES CASCADE CONSTRAINTS
/
DROP TABLE BILLING_DETAILS CASCADE CONSTRAINTS
/
DROP TABLE USERS CASCADE CONSTRAINTS
/
DROP TABLE CONTACT_DETAILS CASCADE CONSTRAINTS
/
DROP TABLE ITEMS CASCADE CONSTRAINTS
/
DROP TABLE CATEGORIES_ITEMS CASCADE CONSTRAINTS
/
DROP TABLE BIDS
/
DROP TABLE SEQUENCE

-------------------------------------------------------------------------------------------------
these script's simply doesn't work for Derby Database, i actually searched on other forum's also for sql statement's to delete these existing table's, but to no avail, even on this site http://db.apache.org/derby/,

so these sql statement's are part of example's, let me know the sql statement's used for dropping these created table's.
To me it seems, i got this exception because when i ran command-
ant

I got these exception's

C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8>ant
Buildfile: build.xml

common:
[echo] BuildName: chapter8
[echo] BuildHome: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8
[echo] BuildFile: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uild.xml
[echo] BuildJVM: 1.6

java-env-check:

init:
[echo] -----> Initializing project properties

setup:
[echo] -----> Creating the required sub-directories
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8lib
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uild
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8log
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8META-INF
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8-ejbeanMETA-INF
[mkdir] Created dir: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8-ejbclientMETA-INF

compile-ejb-classes:
[echo] -----> Compiling EJBs
[javac] Compiling 17 source files to C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8-ejbean

ejb-descriptor:
[copy] Copying 1 file to C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8-ejbeanMETA-INF

package-ejb:
[echo] -----> Create EJB jar file
[jar] Building jar: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8chapter8-ejb.jar

compile-cli-classes:
[javac] Compiling 2 source files to C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8-ejbclient

cli-descriptor:
[copy] Copying 1 file to C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8-ejbclient

package-client:
[jar] Building jar: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8libchapter8-client.jar

package-app:
[copy] Copying 1 file to C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8META-INF
[jar] Building jar: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uildchapter8.ear
[copy] Copying 1 file to C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8lib

deploy:
[echo] asadmin.bat deploy --user admin --password adminadmin --host localhost --port 4848 --upload=true lib/chapter8.ear
[exec] Command deploy executed successfully with following warning messages: WARNING:
[exec]
[exec] JDO76614: Deployment encountered SQL Exceptions:
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE CATEGORIES_ITEMS (CI_ITEM_ID BIGINT NOT NULL, CI_CATEGORY_ID BIGINT NOT NULL, PRIMARY KEY (CI_ITEM_ID, CI_CATEGORY_ID))": java.sql.SQLException: Table/View 'CATEGORIES_ITEMS' already exists in Schema 'AP
P'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE CONTACT_DETAILS (CONTACT_USER_ID VARCHAR(255) NOT NULL, EMAIL VARCHAR(255), PHONE VARCHAR(255), STREETNAME1 VARCHAR(255), STREETNAME2 VARCHAR(255), COUNTRY VARCHAR(255), CITY VARCHAR(255), STATE_CODE VAR
CHAR(255), ZIP_CODE VARCHAR(255), PRIMARY KEY (CONTACT_USER_ID))": java.sql.SQLException: Table/View 'CONTACT_DETAILS' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE ITEMS (ITEM_ID BIGINT NOT NULL, INITIAL_PRICE FLOAT, ITEM_NAME VARCHAR(255), BID_START_DATE TIMESTAMP, BID_END_DATE TIMESTAMP, CREATED_DATE TIMESTAMP, SELLER_ID VARCHAR(255), PRIMARY KEY (ITEM_ID))": jav
a.sql.SQLException: Table/View 'ITEMS' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE USERS (USER_ID VARCHAR(255) NOT NULL, USER_TYPE VARCHAR(1), BIRTH_DATE DATE, FIRST_NAME VARCHAR(255) NOT NULL, LAST_NAME VARCHAR(255) NOT NULL, USER_BILLING_ID BIGINT, MAX_ITEMS BIGINT, COMM_RATE FLOAT,
CREDIT_RATING BIGINT, BIDDER_STATUS VARCHAR(255), PRIMARY KEY (USER_ID))": java.sql.SQLException: Table/View 'USERS' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE CATEGORIES (CATEGORY_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL, CATEGORY_NAME VARCHAR(255), CREATE_DATE VARCHAR(255), PARENT_ID BIGINT, CREATED_BY VARCHAR(255), PRIMARY KEY (CATEGORY_ID))": java.sq
l.SQLException: Table/View 'CATEGORIES' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE BIDS (BID_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL, BID_PRICE FLOAT, BID_DATE DATE, BID_ITEM_ID BIGINT, BID_BIDDER VARCHAR(255), PRIMARY KEY (BID_ID))": java.sql.SQLException: Table/View 'BIDS' al
ready exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE BILLING_DETAILS (BILLING_ID BIGINT GENERATED ALWAYS AS IDENTITY NOT NULL, ACCOUNT_NO VARCHAR(255), SECRET_CODE VARCHAR(255), EXPIRY_DATE VARCHAR(255), STREETNAME1 VARCHAR(255), STREETNAME2 VARCHAR(255),
COUNTRY VARCHAR(255), CITY VARCHAR(255), STATE_CD VARCHAR(255), ZIP_CD VARCHAR(255), PRIMARY KEY (BILLING_ID))": java.sql.SQLException: Table/View 'BILLING_DETAILS' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE CATEGORIES_ITEMS ADD CONSTRAINT CTGORIESITEMSCTMID FOREIGN KEY (CI_ITEM_ID) REFERENCES ITEMS (ITEM_ID)": java.sql.SQLException: Constraint 'CTGORIESITEMSCTMID' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE CATEGORIES_ITEMS ADD CONSTRAINT CTGRSITEMSCCTGRYID FOREIGN KEY (CI_CATEGORY_ID) REFERENCES CATEGORIES (CATEGORY_ID)": java.sql.SQLException: Constraint 'CTGRSITEMSCCTGRYID' already exists in Schema 'APP'.

[exec] JDO76609: Got SQLException executing statement "ALTER TABLE ITEMS ADD CONSTRAINT FK_ITEMS_SELLER_ID FOREIGN KEY (SELLER_ID) REFERENCES USERS (USER_ID)": java.sql.SQLException: Constraint 'FK_ITEMS_SELLER_ID' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE USERS ADD CONSTRAINT FK_USERS_USER_ID FOREIGN KEY (USER_ID) REFERENCES CONTACT_DETAILS (CONTACT_USER_ID)": java.sql.SQLException: Constraint 'FK_USERS_USER_ID' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE USERS ADD CONSTRAINT USERSUSERBILLINGID FOREIGN KEY (USER_BILLING_ID) REFERENCES BILLING_DETAILS (BILLING_ID)": java.sql.SQLException: Constraint 'USERSUSERBILLINGID' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE CATEGORIES ADD CONSTRAINT CATEGORIESPARENTID FOREIGN KEY (PARENT_ID) REFERENCES CATEGORIES (CATEGORY_ID)": java.sql.SQLException: Constraint 'CATEGORIESPARENTID' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE CATEGORIES ADD CONSTRAINT CTEGORIESCREATEDBY FOREIGN KEY (CREATED_BY) REFERENCES USERS (USER_ID)": java.sql.SQLException: Constraint 'CTEGORIESCREATEDBY' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE BIDS ADD CONSTRAINT BIDS_BID_ITEM_ID FOREIGN KEY (BID_ITEM_ID) REFERENCES ITEMS (ITEM_ID)": java.sql.SQLException: Constraint 'BIDS_BID_ITEM_ID' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "ALTER TABLE BIDS ADD CONSTRAINT FK_BIDS_BID_BIDDER FOREIGN KEY (BID_BIDDER) REFERENCES USERS (USER_ID)": java.sql.SQLException: Constraint 'FK_BIDS_BID_BIDDER' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "CREATE TABLE SEQUENCE (SEQ_NAME VARCHAR(50) NOT NULL, SEQ_COUNT DECIMAL, PRIMARY KEY (SEQ_NAME))": java.sql.SQLException: Table/View 'SEQUENCE' already exists in Schema 'APP'.
[exec] JDO76609: Got SQLException executing statement "INSERT INTO SEQUENCE(SEQ_NAME, SEQ_COUNT) values ('SEQ_GEN', 1)": java.sql.SQLIntegrityConstraintViolationException: The statement was aborted because it would have caused a duplicate key value in a unique or primary
key constraint or unique index identified by 'SQL080907034043550' defined on 'SEQUENCE'.
[exec]

all:
[echo] -----> Creates and deploys all deployable units for the application

BUILD SUCCESSFUL
Total time: 37 seconds
i am running the example, given under chapter-8 for glassfish.

when i do- ant run

i get this error-
BUILD SUCCESSFUL
Total time: 37 seconds
C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8>ant run
Buildfile: build.xml

common:
[echo] BuildName: chapter8
[echo] BuildHome: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8
[echo] BuildFile: C:Users ockyDesktopvisual bluprintBuksExtracodeglassfishchapter8uild.xml
[echo] BuildJVM: 1.6

java-env-check:

init:
[echo] -----> Initializing project properties

run:
[echo] Executing client class using C:SunAppServer/bin/appclient.bat
[exec] Oct 12, 2008 4:10:36 AM com.sun.enterprise.appclient.MainWithModuleSupport <init>
[exec] WARNING: ACC003: Application threw an exception.
[exec] javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[exec] java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
[exec] javax.transaction.RollbackException: Transaction marked for rollback.
[exec] java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[exec] java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
[exec] javax.transaction.RollbackException: Transaction marked for rollback.
[exec] at com.sun.corba.ee.impl.javax.rmi.CORBA.Util.mapSystemException(Util.java:243)
[exec] at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.privateInvoke(StubInvocationHandlerImpl.java:205)
[exec] at com.sun.corba.ee.impl.presentation.rmi.StubInvocationHandlerImpl.invoke(StubInvocationHandlerImpl.java:152)
[exec] at com.sun.corba.ee.impl.presentation.rmi.bcel.BCELStubBase.invoke(BCELStubBase.java:225)
[exec] at actionbazaar.buslogic.__BazaarAdmin_Remote_DynamicStub.createBidder(actionbazaar/buslogic/__BazaarAdmin_Remote_DynamicStub.java)
[exec] at actionbazaar.buslogic._BazaarAdmin_Wrapper.createBidder(actionbazaar/buslogic/_BazaarAdmin_Wrapper.java)
[exec] at actionbazaar.buslogic.BazaarAdminClient.main(BazaarAdminClient.java:19)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:597)
[exec] at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:200)
[exec] Caused by: java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception
[exec] javax.transaction.RollbackException: Transaction marked for rollback.
[exec] at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:251)
[exec] at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1386)
[exec] at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1316)
[exec] at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:210)
[exec] at com.sun.ejb.containers.EJBObjectInvocationHandlerDelegate.invoke(EJBObjectInvocationHandlerDelegate.java:117)
[exec] at $Proxy104.createBidder(Unknown Source)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:597)
[exec] at com.sun.corba.ee.impl.presentation.rmi.ReflectiveTie._invoke(ReflectiveTie.java:154)
[exec] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatchToServant(CorbaServerRequestDispatcherImpl.java:687)
[exec] at com.sun.corba.ee.impl.protocol.CorbaServerRequestDispatcherImpl.dispatch(CorbaServerRequestDispatcherImpl.java:227)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequestRequest(CorbaMessageMediatorImpl.java:1846)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:1706)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleInput(CorbaMessageMediatorImpl.java:108smilie
[exec] at com.sun.corba.ee.impl.protocol.giopmsgheaders.RequestMessage_1_2.callback(RequestMessage_1_2.java:223)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.handleRequest(CorbaMessageMediatorImpl.java:806)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.dispatch(CorbaMessageMediatorImpl.java:563)
[exec] at com.sun.corba.ee.impl.protocol.CorbaMessageMediatorImpl.doWork(CorbaMessageMediatorImpl.java:2567)
[exec] at com.sun.corba.ee.impl.orbutil.threadpool.ThreadPoolImpl$WorkerThread.run(ThreadPoolImpl.java:555)
[exec] Caused by: javax.transaction.RollbackException: Transaction marked for rollback.
[exec] at com.sun.enterprise.distributedtx.J2EETransaction.commit(J2EETransaction.java:440)
[exec] at com.sun.enterprise.distributedtx.J2EETransactionManagerOpt.commit(J2EETransactionManagerOpt.java:371)
[exec] at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:3792)
[exec] at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:3571)
[exec] at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1354)
[exec] ... 19 more
[exec] javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[exec] java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
[exec] javax.transaction.RollbackException: Transaction marked for rollback.
[exec] at actionbazaar.buslogic._BazaarAdmin_Wrapper.createBidder(actionbazaar/buslogic/_BazaarAdmin_Wrapper.java)
[exec] at actionbazaar.buslogic.BazaarAdminClient.main(BazaarAdminClient.java:19)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:597)
[exec] at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:200)
[exec] Exception in thread "main" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:461)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:259)
[exec] at com.sun.enterprise.appclient.Main.main(Main.java:200)
[exec] Caused by: java.lang.reflect.InvocationTargetException
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[exec] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[exec] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[exec] at java.lang.reflect.Method.invoke(Method.java:597)
[exec] at com.sun.enterprise.util.Utility.invokeApplicationMain(Utility.java:266)
[exec] at com.sun.enterprise.appclient.MainWithModuleSupport.<init>(MainWithModuleSupport.java:449)
[exec] ... 2 more
[exec] Caused by: javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
[exec] java.rmi.RemoteException: Transaction aborted; nested exception is: javax.transaction.RollbackException: Transaction marked for rollback.; nested exception is:
[exec] javax.transaction.RollbackException: Transaction marked for rollback.
[exec] at actionbazaar.buslogic._BazaarAdmin_Wrapper.createBidder(actionbazaar/buslogic/_BazaarAdmin_Wrapper.java)
[exec] at actionbazaar.buslogic.BazaarAdminClient.main(BazaarAdminClient.java:19)
[exec] ... 8 more


Just i want to execute this example, as i am preparing for SCBCD...
thanks will look at it!
i am working on Chapter -5 code, here i do it look's like that CheckPermissionInterceptor.class is not being shown as Interceptor here,

so i modifed to my code to use it like this-

-------------------------
@DeclareRoles({"BIDDER", "CSR", "ADMIN"})
@Interceptors({actionbazaar.buslogic.ActionBazaarProfilingInterceptor.class, actionbazaar.buslogic.CheckPermissionInterceptor.class})
@Stateless(name="Chapter-5 PlaceBidBean", mappedName="ejb/Chapter5JNDIName")
//@RolesAllowed("CSR, ADMIN")
@PermitAll
public class PlaceBidBean implements PlaceBid {
-------------------------------------------------------------------------------------

But when i run the Client code, i am getting the error on Console like this-

-------------------------------------------------------------------------------------
javax.ejb.EJBException: nested exception is: java.rmi.ServerException: RemoteException occurred in server thread; nested exception is:
java.rmi.RemoteException: null; nested exception is:
java.lang.IllegalArgumentException: No mapping available for role reference admin
at actionbazaar.buslogic._PlaceBid_Wrapper.addBid(actionbazaar/buslogic/_PlaceBid_Wrapper.java)
at actionbazaar.buslogic.PlaceBidClient.main(PlaceBidClient.java:17)

---------------------------------------------------------------------------------------

it say's 'No mapping available for role reference admin', which make's to think that here should be some xml file for role-mapping...

But i want to resolve this issue, let me know the code to resolve this error.
Reza,

No problem, next time my question's will be focussed on book and related to code only.
Thanks for answer's
ok as i run the build.xml file which is common to all code, month back, i was looking specifically at eah chapter's build.xml, file to look for how jdbc resources got created under Glassfish Server.
As i was running, chapter- 4 examples under eclipse:

i used to get some error like createActiveAdapter rar

in order to resolve this issue, i did two steps-

1) in glassfish server, i added additional property under

jms resources>> connection factories

Name- jms/QueueConnectionFactory

2) in my client code, i did initalcontext lookup for this jms/QueueConnectionFactory.

now i am able to run my code very well.

So my code now looks like-

----------------------------------------------------------------------
InitialContext ctx = new InitialContext();
Destination destination = (Destination)ctx.lookup("ShippingRequestQueue");
InitialContext ctx1 = new InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory)ctx.lookup("jms/QueueConnectionFactory");
Connection connection = connectionFactory.createConnection();
connection.start();

------------------------------------------------------------------------

So now i am doing jndi lookup for 2 jndi name's.

Question-1- if i remember correctly, somewhere in book, i read, that we can't do lookup for jndi name in 1 program 2 time's.

Question-1.1- As i have seen on other forum's, people doing jndi lookup for jms/QueueConnectionFactory,
they are actually adding these line's to code to do,

----------------------------------------------
Hashtable properties = new Hashtable(2);
properties.put(Context.PROVIDER_URL,"iiop://127.0.0.1:3700");
properties.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.appserv.naming.S1ASCtxFactory");
try {
ctx = new InitialContext(properties);
} catch (NamingException ex) {
ex.printStackTrace();
}
------------------------------------------

But in my case, i didn't did this, instead- i added property under glassfish under jms/QueueConnectionFactory,

so is this my step manual replacement for adding above line's of code?

Question-2- in this program- /Chapter - 4 EJB Project/src/actionbazaar/buslogic/ShippingRequestProcessorMDB.java

@Resource(name = "jdbc/TurtleDS")

we are injecting the resource. but my question here is how this jdbc resource was created under glassfish server. I am unable to point out, how this magic is happening.

Question-3- i have run this program /Chapter - 4 Client Project/src/actionbazaar/buslogic/ShippingRequestJMSProducer.java 1 time only, but it seems that at eclipse console output,
Shipping Request Message Sent ..

i see in console output, this below message keep on updating after session time, what sort of this message represents info to us?

Oct 9, 2008 11:53:32 PM com.sun.messaging.jms.ra.ManagedConnection <init>
INFO: MQJMSRA_MC1101: constructor:Created mcId=10smilieacId=5634316378208359168:Using xacf config={imqOverrideJMSPriority=false, imqConsumerFlowLimit=1000, imqOverrideJMSExpiration=false, imqAddressListIterations=3, imqLoadMaxToServerSession=true, imqConnectionType=TCP, imqPingInterval=30, imqSetJMSXUserID=false, imqConfiguredClientID=, imqSSLProviderClassname=com.sun.net.ssl.internal.ssl.Provider, imqJMSDeliveryMode=PERSISTENT, imqConnectionFlowLimit=1000, imqConnectionURL=http://localhost/imq/tunnel, imqBrokerServiceName=, imqJMSPriority=4, imqBrokerHostName=localhost, imqJMSExpiration=0, imqAckOnProduce=, imqEnableSharedClientID=false, imqAckTimeout=0, imqAckOnAcknowledge=, imqConsumerFlowThreshold=50, imqDefaultPassword=guest, imqQueueBrowserMaxMessagesPerRetrieve=1000, imqDefaultUsername=guest, imqReconnectEnabled=true, imqConnectionFlowCount=100, imqAddressListBehavior=RANDOM, imqReconnectAttempts=3, imqSetJMSXAppID=false, imqConnectionHandler=com.sun.messaging.jmq.jmsclient.protocol.tcp.TCPStreamHandler, imqSetJMSXRcvTimestamp=false, imqBrokerServicePort=0, imqDisableSetClientID=false, imqSetJMSXConsumerTXID=false, imqOverrideJMSDeliveryMode=false, imqBrokerHostPort=7676, imqQueueBrowserRetrieveTimeout=60000, imqSetJMSXProducerTXID=false, imqSSLIsHostTrusted=false, imqConnectionFlowLimitEnabled=false, imqReconnectInterval=5000, imqAddressList=mq://rocky-PC:7676/, imqOverrideJMSHeadersToTemporaryDestinations=false}
Sure i will again look for answer's over there in ANT script's.

I am using, @EJB, as i am doing from Eclipse console, as a standalone program calling Session Bean's, i have to do JNDI name lookup. I am not using ANT script's or asadmin scripts's.
My servlet code looks like this-
i have removed the angle bracket's, because this forum executes it.

i am able to access this servlet thru index.html on glassfish server.
But the page displayed is blank.
Anything wrong, i am doing here?
-----------------------------------------------------------------
package ejb3inaction.example;
import java.io.IOException;
import java.io.PrintWriter;

import javax.ejb.EJB;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.*;
import javax.servlet.http.*;

public class InvokeEJB extends HttpServlet{
@EJB

private HelloUser helloUser;
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException{

try {
InitialContext ctx = new InitialContext();
HelloUser helloUser = (HelloUser) ctx.lookup("ejb/SimpleBeanJNDI");
resp.setContentType("text/html");
PrintWriter out = resp.getWriter();
out.println("html");
out.println("head");
out.println("titleHello World!/title");
out.println("This is EJB Servlet ");
out.println("/head");
out.println("body");
out.println("EJB Hello World!");
out.println("/body");
out.println("/html");



out.println(helloUser.sayHello("Curious George"));
System.out.println("Invoked EJB successfully .. see server console for output");

} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}



}
------------------------------------------------------------------------------------------------------

Message was edited by:
boy18nj
i am deploying-

session bean, servlet- under webapplication in glassfish.

when i access this servlet, i don't get any output dispalyed, like all out.prinltn line's output,

i am able to access this serlvet thru index.html
it dosen't give's any error, the accessed servlet page remains blank.

Can you let me know why it is blank?

Message was edited by:
boy18nj

Message was edited by:
boy18nj
Reza,

Your guess is right, i am getting JNDI Naming exception.
Ok i let you know what i have done,

1) I have deployed Session Bean and Servlet, into 1 web-application.

So i think's that's why it's giving JNDI Naming exception.
Because Session Bean's when deployed under web-application are not recognised by GlassFish Server.


The possible solution that i can try is, today evening at home is to-

1) make Servlet deploy under Web-Application in Glassfish.
2) deploy Session bean under EJB modules in Glassfish.

So i think it's possible, that in Glassfish Server, 1 module component can call other module component's, so in my case, Web-application will call EJB module.


Please correct me, if my suggested solution is wrong somewhere.
thanks
If i look at this table 14.2, i understand that-

for Stateful an Stateless Session Beans:

1) ejbPostCreate is now annotated with @PostConstruct

2) ejbRemove is now annotated with @Remove

3) Stateful ejbPassivate Method annotated with @PrePassivate

If i look at this table 14.5, i understand that-

for Entity Beans:

1) ejbPostCreate is now annotated with @PostPersist

2) ejbRemove is now annotated with @PreRemove

3) ejbPassivate Candidate for removal.

Quote - Page 509
___________________________________________________________________

Table 14.2 EJB 2 required implementation of several lifecycle methods. If you implemented any of
your application’s business logic in any of these methods, then you can use the corresponding methods
in EJB 3 to migrate that business logic.
Bean Type EJB 2 Methods EJB 3 Methods
Stateless, Stateful ejbCreate Constructor
Stateless, Stateful ejbPostCreate Method annotated with @PostConstruct
Stateful ejbPassivate Method annotated with @PrePassivate
Stateful ejbActivate Method annotated with @PostActivate
Stateless, Stateful ejbRemove Method annotated with @PreDestroy
Stateful remove method in home
interface
Method annotated with @Remove
Stateful create method in home
interface
Method annotated with @Init if the EJB 3
bean has a home interface
Stateless ejbTimeout Method annotated with @Timeout

____________________________________________________________________


Page- 522
Quote
___________________________________________________________________
Table 14.5 EJB 2 required implementations of many lifecycle methods. EJB 3 allows you to define
lifecycle callback methods. This table lists the corresponding methods for EJB 3 JPA that you can
use to migrate an entity bean’s lifecycle methods.
EJB 2 Lifecycle Method Migrated EJB 3 JPA Entity
ejbCreate Constructors in the entity class.
ejbPostCreate A method annotated with @PostPersist.
ejbRemove A method annotated with @PreRemove.
setEntityContext,
unSetEntityContext
EntityContext is not supported in EJB3 JPA.
Candidate for removal.
ejbActivate, ejbLoad
A method annotated with @PostLoad as per the
application requirement.
ejbPassivate Candidate for removal.
ejbStore
A method annotated with either @PrePersist or
@PreUpdate depending on the application requirement.

____________________________________________________________________


From the above understanding, i do understand-

EJB2 was good in naming conventions- so it has same lifecycle methds for Session Beans and Entity Beans.

When it comes to EJB3, the lifecylce method's naming annotations change's for Session Beans and Entity Beans.

So my question- what is the motive behind changing the naming convention's for Annotations?
As per my knowledge annotations are defined under differnent beans for Session Beans and Entity Beans- so this was done due to naming conflicts.

Message was edited by:
boy18nj

Message was edited by:
boy18nj
Thanks Debu Panda...
I agree this approach is not good, EntityManager is not designed to be thread-safe in nature.
page- 448
---------------------------------------------------------------------------------------------------------------------
If you’re planning to use JPA from a managed class like a servlet, you may be
tempted to inject an instance of an EntityManager by using the @PersistenceContext
annotation like this:
//--- Do NOT do this!!! This is NOT recommended!!!
public class ActionBazaarBidControllerServlet extends HttpServlet {
@PersistenceContext(unitName = "actionBazaar")
private EntityManager entityManager;
...
}
---------------------------------------------------------------------------------------------------------------



But when i see this code on page- 449

why this approach is good, although we are using Persistence Context- it's a dependency injection use or i am confusing here we use JNDI lookup.
----------------------------------------------------------------------------------------------------------
@PersistenceContext(name = "actionBazaar/EntityManager",
unitName = "actionBazaar")
public class ActionBazaarBidControllerServlet extends HttpServlet {
private EntityManager entityManager;
...
}
--------------------------------------------------------------------------------------------------------------

Please clear my doubt...
Thanks Reza. i will look at JNDI Appendix.
Reza,

if you look at this line
----------------------------------------------------------------------------------------------------------------
This next JPQL snippet is invalid because the ORDER BY clause contains
c.createDate but the SELECT clause does not:
-----------------------------------------------------------------------------------------------------------------
it says snippet is invalid.

So how the sql statement is right.
Reza,

Do you have idea, when the 2nd edition of book will come?
Are there any changes in terms of addition of any new Topic's....

Once again, i would like to thank you, for writing so easy and understandable book.
i enjoy reading it.
Please look at page-374

-----------------------------------------------------------------------------------------------------------------------
This next JPQL snippet is invalid because the ORDER BY clause contains
c.createDate but the SELECT clause does not:
SELECT c.categoryName, c.createDate
FROM Category c
ORDER BY c.categoryName ASC, c.createDate DESC
-----------------------------------------------------------------------------------------------------------------------
here the select clause should not have c.createDate, then the above sentence would be right.
No, i didn't skip any chapter.

Although, i found this book very understandable, but as in Chapter-9, there have been alot many new terms like persistence field's, association field's,
collection value path expression's. So might it made me little confused in grasping so many terms.

Anyway i thought i would just get short answer from you, but np i can again refer to these chapeter's again,

One more thing, i heard you are going to give a presentation on this book's example.
Are you guys in your JUG confernece, do make video's also or then post on their JUG website?

Well i am a member of AJUG(Atlanta Java User Group)- i like it most.
it would be g8t if you are at one of the conferences of AJUG.

if you want to be sponsored, please follow the below link:

Becoming an AJUG Sponsor
Check our Sponsorship Guidelines or contact our Executive Committee for futher information on how to become a Corpoarate Sponsor.

http://www.ajug.org/confluence/display/AJUG/Contact
Reza,

i do have a confusion for the difference between persistence field and association field?
From the chapter-10, i am unable to make out the clear crystal difference between them.
i am not clear about the meanings of this field.
As i am doing code for Chapter 5, here i came to know, that i should install oracle, so now can't here Derby database is useful now....
How to set the derby database for chapter 5?
As i was reading book and doing example's. But for Chapter 3...then onwards,
for further chapter's unable to use ACC properly. I was forced to read just chapter's only. Currently i am at chapter 6.
I enjoy reading this book very much.
As recommended by you also to read Packaging chapter 11 or 13.
But as that chapetr comes in sequence. Should i skip the sequence then read the chapter.

OR


go reading chapters in sequence, when i am done with book, then practice examples.


OR




Practice chapters and examples side by side.

Any recommended approach.?

One thing last, this book is so easy and understable. I always enjoy reading. It's not a boring task for me.
Under Chapter 3, when i do run ant run-sfsb

I do get error, it says BUILD failed.


So i am unable to do this -
To run the stateful EJB
ok i am back to chapter 3, code examples:

i am studying doc, there it is written,

"Create the following tables in the ab user schema
Using sq/tables.sql script"

i am doubtful, how should i do this step?
Under Chapter 3 doc's, i got to know that i have to-
Create the following tables in the ab user schema
Using sq/tables.sql script
Thanks Reza
open ij
and connect to the database like this:
ij> CONNECT 'jdbc:derby://localhost:1527/sun-appserv-samples;user=APP;Password=A
PP';



-----------------------------------------------------

so what does this means open ij?
Sudhakar, i want to know that from which site we can download the ij tool?

Moreover i have downloaded the squirrel as referred by Reza, but i don't know how to use it,

but from your disussion it seems that we can use the ij tool.
Let me know from where i can download this tool.
cool
i am able to use Squirrel now from eclipse...