[JAVAEETUTORIAL-296] problem with update client from admin's interface in duke-forest Created: 07/Jul/15  Updated: 07/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Problem with update client from admin's interface in duke-forest

Solution
In CustomerController.java's method update() add the following line of code:

current.setPassword(MD5Util.generateMD5(current.getPassword()));





[JAVAEETUTORIAL-299] In duke-forest all registered users (ADMINS and USERS) can get access to the administrative Interface .../dukes-store/admin/ and .../dukes-shipment/admin/ Created: 08/Jul/15  Updated: 08/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

In duke-forest all registered users (ADMINS and USERS) can get access to the administrative Interface .../dukes-store/admin/ and .../dukes-shipment/admin/

Solution
In entity project, edit pom.xml jdbcRealm's creation section:

<arguments>
    <argument>create-auth-realm</argument>
    <argument>--classname=com.sun.enterprise.security.auth.realm.jdbc.JDBCRealm</argument>
    <argument>--property=jaas-context=jdbcRealm:datasource-jndi=java\:global/ForestDataSource:user-table=forest.PERSON:user-name-column=EMAIL:password-column=PASSWORD:group-table=forest.PERSON_GROUPS:group-table-user-name-column=PERSON_EMAIL:group-name-column=GROUPS_NAME:digest-algorithm=MD5:digestrealm-password-enc-algorithm=MD5:charset=UTF-8:encoding=Hex</argument>
    <argument>jdbcRealm</argument>
</arguments>

Also edit create.sql:

CREATE TABLE "FOREST"."CATEGORY"(ID int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), NAME varchar(45) NOT NULL, TAGS varchar(45))
CREATE UNIQUE INDEX SQL_CATEGORY_ID_INDEX ON "FOREST"."CATEGORY"(ID)
CREATE TABLE "FOREST"."PERSON"(ID int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), FIRSTNAME varchar(50) NOT NULL, LASTNAME varchar(100) NOT NULL, EMAIL varchar(45) NOT NULL UNIQUE, ADDRESS varchar(45) NOT NULL, CITY varchar(45) NOT NULL, PASSWORD varchar(100), DTYPE varchar(31))
CREATE UNIQUE INDEX SQL_PERSON_EMAIL_INDEX ON "FOREST"."PERSON"(EMAIL)
CREATE UNIQUE INDEX SQL_PERSON_ID_INDEX ON "FOREST"."PERSON"(ID)
CREATE TABLE "FOREST"."GROUPS"(ID int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), NAME varchar(45) NOT NULL UNIQUE, DESCRIPTION varchar(300))
CREATE UNIQUE INDEX SQL_GROUPS_NAME_INDEX ON "FOREST"."GROUPS"(NAME)
CREATE TABLE "FOREST"."PERSON_GROUPS"(GROUPS_NAME varchar(45) NOT NULL, PERSON_EMAIL varchar(45) NOT NULL)
ALTER TABLE "FOREST"."PERSON_GROUPS" ADD CONSTRAINT FK_PERSON_GROUPS_GROUPS FOREIGN KEY (GROUPS_NAME) REFERENCES "FOREST"."GROUPS"(NAME)
ALTER TABLE "FOREST"."PERSON_GROUPS" ADD CONSTRAINT FK_PERSON_GROUPS_PERSON FOREIGN KEY (PERSON_EMAIL) REFERENCES "FOREST"."PERSON"(EMAIL)
CREATE INDEX SQL_PERSONGROUPS_EMAIL_INDEX ON "FOREST"."PERSON_GROUPS"(PERSON_EMAIL)
CREATE INDEX SQL_PERSONGROUPS_NAME_INDEX ON "FOREST"."PERSON_GROUPS"(GROUPS_NAME)
CREATE TABLE "FOREST"."ORDER_STATUS"(ID int NOT NULL PRIMARY KEY, STATUS varchar(45) NOT NULL, DESCRIPTION varchar(200))
CREATE UNIQUE INDEX SQL_ORDERSTATUS_ID_INDEX ON "FOREST"."ORDER_STATUS"(ID)
CREATE TABLE "FOREST"."CUSTOMER_ORDER"(ID int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), AMOUNT float(52) NOT NULL, DATE_CREATED timestamp DEFAULT CURRENT_TIMESTAMP NOT NULL, CUSTOMER_ID int NOT NULL, STATUS_ID int NOT NULL)
ALTER TABLE "FOREST"."CUSTOMER_ORDER" ADD CONSTRAINT FK_CUSTOMER_ORDER_ORDER_STATUS1 FOREIGN KEY (STATUS_ID) REFERENCES "FOREST"."ORDER_STATUS"(ID)
ALTER TABLE "FOREST"."CUSTOMER_ORDER" ADD CONSTRAINT FK_CUSTOMER_ORDER_CUSTOMER1 FOREIGN KEY (CUSTOMER_ID) REFERENCES "FOREST"."PERSON"(ID)
CREATE INDEX SQL_ORDER_STATUS_ID_INDEX ON "FOREST"."CUSTOMER_ORDER"(STATUS_ID)
CREATE INDEX SQL_ORDER_CUSTOMER_ID_INDEX ON "FOREST"."CUSTOMER_ORDER"(CUSTOMER_ID)
CREATE UNIQUE INDEX SQL_ORDER_ID_INDEX ON "FOREST"."CUSTOMER_ORDER"(ID)
CREATE TABLE "FOREST"."PRODUCT"(ID int NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1), NAME varchar(10000) NOT NULL, PRICE decimal(10,2) NOT NULL, DESCRIPTION varchar(10000) NOT NULL, IMG varchar(45), CATEGORY_ID int NOT NULL, IMG_SRC blob(1073741823))
ALTER TABLE "FOREST"."PRODUCT" ADD CONSTRAINT FK_PRODUCT_CATEGORY FOREIGN KEY (CATEGORY_ID) REFERENCES "FOREST"."CATEGORY"(ID)
CREATE UNIQUE INDEX SQL_PRODUCT_ID_INDEX ON "FOREST"."PRODUCT"(ID)
CREATE INDEX SQL_PRODUCT_CATEGORY ON "FOREST"."PRODUCT" ("CATEGORY_ID")
CREATE TABLE "FOREST"."ORDER_DETAIL"(ORDER_ID int NOT NULL, PRODUCT_ID int NOT NULL, QTY int NOT NULL, CONSTRAINT SQL_ORDER_PRODUCT_PK PRIMARY KEY (ORDER_ID,PRODUCT_ID))
ALTER TABLE "FOREST"."ORDER_DETAIL" ADD CONSTRAINT FK_ORDER_DETAIL_PRODUCT FOREIGN KEY (PRODUCT_ID) REFERENCES "FOREST"."PRODUCT"(ID)
ALTER TABLE "FOREST"."ORDER_DETAIL" ADD CONSTRAINT FK_ORDER_DETAIL_ORDER FOREIGN KEY (ORDER_ID) REFERENCES "FOREST"."CUSTOMER_ORDER"(ID)
CREATE UNIQUE INDEX SQL_ORDER_DETAIL_INDEX ON "FOREST"."ORDER_DETAIL"(ORDER_ID, PRODUCT_ID)
CREATE INDEX SQL_ORDER_PRODUCT_ID_INDEX ON "FOREST"."ORDER_DETAIL"(PRODUCT_ID)
CREATE INDEX SQL_ORDER_DETAIL_ID_INDEX ON "FOREST"."ORDER_DETAIL"(ORDER_ID)





[JAVAEETUTORIAL-301] The problem in duke-forest with residual messages/queues JMS Created: 08/Jul/15  Updated: 08/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The problem in dukes-forest with residual messages/queues JMS

Solution
Insert following into execution plugin in dukes-store/pom.xml:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>${maven.exec.plugin.version}</version>
    <executions>
        <execution>
            <id>Flush JMS Queues</id>
            <phase>compile</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <skip>false</skip>
                <executable>${glassfish.home}/bin/asadmin${glassfish.executables.suffix}</executable>
                <successCodes>
                    <successCode>0</successCode>
                    <successCode>1</successCode>
                </successCodes>
                <arguments>
                    <argument>flush-jmsdest</argument>
                    <argument>--desttype=queue</argument>
                    <argument>PhysicalOrderQueue</argument>
                </arguments>                 
            </configuration>
        </execution>
        <execution>
            <id>Activate SSO and Default Principal To Role Mapping</id>
            <phase>compile</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <skip>false</skip>
                <executable>${glassfish.home}/bin/asadmin${glassfish.executables.suffix}</executable>
                <arguments>
                    <argument>set</argument>
                    <argument>server.security-service.activate-default-principal-to-role-mapping=true</argument>
                    <argument>server.http-service.sso-enabled=true</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin> 





[JAVAEETUTORIAL-297] Problem with create and update admin from admin's interface in duke-forest Created: 08/Jul/15  Updated: 08/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Problem with create and update admin from admin's interface in duke-forest. Also i think remove last admin ability not good idea.

Solution
AdministratorBean.java and AdministratorController.java should look like this:

/**
 * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
 *
 * You may not modify, use, reproduce, or distribute this software except in
 * compliance with  the terms of the License at:
 * http://java.net/projects/javaeetutorial/pages/BerkeleyLicense
 */
package com.forest.ejb;

import com.forest.entity.Administrator;
import com.forest.entity.Groups;
import com.forest.entity.Person;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author ievans
 */
@Stateless
public class AdministratorBean extends AbstractFacade<Administrator> {
    @PersistenceContext(unitName = "forestPU")
    private EntityManager em;

    private boolean lastAdministrator;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public Person getAdministratorByEmail(String email) {
        Query createNamedQuery = getEntityManager().createNamedQuery("Person.findByEmail");

        createNamedQuery.setParameter("email", email);

        if (createNamedQuery.getResultList().size() > 0) {
            return (Person) createNamedQuery.getSingleResult();
        } else {
            return null;
        }
    }

    public AdministratorBean() {
        super(Administrator.class);
    }

    @Override
    public void create(Administrator admin) {
        Groups adminGroup = (Groups) em.createNamedQuery("Groups.findByName")
                .setParameter("name", "ADMINS")
                .getSingleResult();
        admin.getGroupsList().add(adminGroup);
        adminGroup.getPersonList().add(admin);
        em.persist(admin);
        em.merge(adminGroup);
    }

    public boolean isLastAdmimistrator() {
        return lastAdministrator;
    }

    @Override
    public void remove(Administrator admin) {
        Groups adminGroup = (Groups) em.createNamedQuery("Groups.findByName")
                .setParameter("name", "ADMINS")
                .getSingleResult();
        if (adminGroup.getPersonList().size() > 1) {
            adminGroup.getPersonList().remove(admin);
            em.remove(em.merge(admin));
            em.merge(adminGroup);
            lastAdministrator = false;
        } else {
            lastAdministrator = true;
        }
    }

}
/**
 * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
 *
 * You may not modify, use, reproduce, or distribute this software except in
 * compliance with  the terms of the License at:
 * http://java.net/projects/javaeetutorial/pages/BerkeleyLicense
 */
package com.forest.web;

import com.forest.ejb.AdministratorBean;
import com.forest.entity.Administrator;
import com.forest.entity.Person;
import com.forest.web.util.AbstractPaginationHelper;
import com.forest.web.util.JsfUtil;
import com.forest.web.util.PageNavigation;
import java.io.Serializable;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.enterprise.context.SessionScoped;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import javax.faces.model.SelectItem;
import javax.inject.Named;
import com.forest.web.util.MD5Util;

@Named(value = "administratorController")
@SessionScoped
public class AdministratorController implements Serializable {

    private static final String BUNDLE = "bundles.Bundle";
    private static final long serialVersionUID = -2691147357609941284L;

    private Administrator current;
    private DataModel items = null;
    @EJB
    private com.forest.ejb.AdministratorBean ejbFacade;

    private static final Logger logger = Logger.getLogger(CustomerController.class.getCanonicalName());

    private AbstractPaginationHelper pagination;
    private int selectedItemIndex;

    public AdministratorController() {
    }

    public Administrator getSelected() {
        if (current == null) {
            current = new Administrator();
            selectedItemIndex = -1;
        }
        return current;
    }

    private AdministratorBean getFacade() {
        return ejbFacade;
    }

    public AbstractPaginationHelper getPagination() {
        if (pagination == null) {
            pagination = new AbstractPaginationHelper(10) {

                @Override
                public int getItemsCount() {
                    return getFacade().count();
                }

                @Override
                public DataModel createPageDataModel() {
                    return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem() + getPageSize()}));
                }
            };
        }
        return pagination;
    }

    public PageNavigation prepareList() {
        recreateModel();
        return PageNavigation.LIST;
    }

    public PageNavigation prepareView() {
        current = (Administrator) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        return PageNavigation.VIEW;
    }

    private boolean isAdministratorDuplicated(Person p) {
        return (getFacade().getAdministratorByEmail(p.getEmail()) != null);
    }

    public PageNavigation prepareCreate() {
        current = new Administrator();
        selectedItemIndex = -1;
        return PageNavigation.CREATE;
    }

    public PageNavigation create() {
        try {
            if (!isAdministratorDuplicated(current)) {
                current.setPassword(MD5Util.generateMD5(current.getPassword()));
                getFacade().create(current);
                JsfUtil.addSuccessMessage(ResourceBundle.getBundle(BUNDLE).getString("AdministratorCreated"));
                return PageNavigation.VIEW;
            } else {
                JsfUtil.addErrorMessage(ResourceBundle.getBundle(BUNDLE).getString("AdministratorDuplicatedError"));

            }
            return PageNavigation.VIEW;
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle(BUNDLE).getString("PersistenceErrorOccured"));
            return null;
        }
    }

    public PageNavigation prepareEdit() {
        current = (Administrator) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        return PageNavigation.EDIT;
    }

    public PageNavigation update() {
        try {
            logger.log(Level.INFO, "Updating administrator ID:{0}", current.getId());
            current.setPassword(MD5Util.generateMD5(current.getPassword()));
            getFacade().edit(current);
            JsfUtil.addSuccessMessage(ResourceBundle.getBundle(BUNDLE).getString("AdministratorUpdated"));
            return PageNavigation.VIEW;
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle(BUNDLE).getString("PersistenceErrorOccured"));
            return null;
        }
    }

    public PageNavigation destroy() {
        current = (Administrator) getItems().getRowData();
        selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
        performDestroy();
        recreateModel();
        return PageNavigation.LIST;
    }

    public PageNavigation destroyAndView() {
        performDestroy();
        recreateModel();
        updateCurrentItem();
        if (selectedItemIndex >= 0) {
            return PageNavigation.VIEW;
        } else {
            recreateModel();
            return PageNavigation.LIST;
        }
    }

    private void performDestroy() {
        try {
            getFacade().remove(current);
            if (getFacade().isLastAdmimistrator()) {
                JsfUtil.addErrorMessage(ResourceBundle.getBundle(BUNDLE).getString("AdministratorLastNonDelete"));
            } else {
                JsfUtil.addSuccessMessage(ResourceBundle.getBundle(BUNDLE).getString("AdministratorDeleted"));
            }
        } catch (Exception e) {
            JsfUtil.addErrorMessage(e, ResourceBundle.getBundle(BUNDLE).getString("PersistenceErrorOccured"));
        }
    }

    private void updateCurrentItem() {
        int count = getFacade().count();
        if (selectedItemIndex >= count) {
            selectedItemIndex = count - 1;
            if (pagination.getPageFirstItem() >= count) {
                pagination.previousPage();
            }
        }
        if (selectedItemIndex >= 0) {
            current = getFacade().findRange(new int[]{selectedItemIndex, selectedItemIndex + 1}).get(0);
        }
    }

    public DataModel getItems() {
        if (items == null) {
            items = getPagination().createPageDataModel();
        }
        return items;
    }

    private void recreateModel() {
        items = null;
    }

    public PageNavigation next() {
        getPagination().nextPage();
        recreateModel();
        return PageNavigation.LIST;
    }

    public PageNavigation previous() {
        getPagination().previousPage();
        recreateModel();
        return PageNavigation.LIST;
    }

    public SelectItem[] getItemsAvailableSelectMany() {
        return JsfUtil.getSelectItems(ejbFacade.findAll(), false);
    }

    public SelectItem[] getItemsAvailableSelectOne() {
        return JsfUtil.getSelectItems(ejbFacade.findAll(), true);
    }

    @FacesConverter(forClass = Administrator.class)
    public static class AdministratorControllerConverter implements Converter {

        @Override
        public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
            if (value == null || value.length() == 0) {
                return null;
            }
            AdministratorController controller = (AdministratorController) facesContext.getApplication().getELResolver().
                    getValue(facesContext.getELContext(), null, "administratorController");
            return controller.ejbFacade.find(getKey(value));
        }

        java.lang.Integer getKey(String value) {
            java.lang.Integer key;
            key = Integer.valueOf(value);
            return key;
        }

        String getStringKey(java.lang.Integer value) {
            StringBuilder sb = new StringBuilder();
            sb.append(value);
            return sb.toString();
        }

        @Override
        public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
            if (object == null) {
                return null;
            }
            if (object instanceof Administrator) {
                Administrator o = (Administrator) object;
                return getStringKey(o.getId());
            } else {
                throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: " + AdministratorController.class.getName());
            }
        }
    }

}





[JAVAEETUTORIAL-298] Problem with timezone (GMT) in duke-forest Created: 08/Jul/15  Updated: 08/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

Problem with timezone in duke-forest (GMT). In my case, Moscow time (GMT +3) not displayed correctly.

Solution
Add to each web.xml following:

<context-param>
        <param-name>javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE</param-name>
        <param-value>true</param-value>
</context-param>





[JAVAEETUTORIAL-300] The problem in duke-forest with the re-creation/duplication of data after the restart GlassFish 4.1 Created: 08/Jul/15  Updated: 08/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Major
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The problem in duke-forest with the re-creation / duplication of data after the restart GlassFish 4.1

Solution
In entity project remove from persistence.xml following line:

<property name="javax.persistence.sql-load-script-source" value="META-INF/sql/data.sql" />

Also copy information from data.sql to create.sql (after creating tables commands, of course)






[JAVAEETUTORIAL-288] Relationship in diagram should reflect one-to-one Created: 22/Sep/14  Updated: 22/Sep/14

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: fjwalraven Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: diagram, persistence, relationship

 Description   

The database diagram in the order Application (Part IV Persistence, 33) shows a one-to-many relationship between Part and VendorPart. Whereas the description talks about a one-to-one relationship: "Part has a field, vendorPart, that has a one-to-one relationship with VendorPart’s part field. That is, each part has exactly one vendor part, and vice versa."



 Comments   
Comment by Kim Haase [ 22/Sep/14 ]

Thank you for pointing out this error. The diagram (Figure 38-1) will need to be fixed in the next version of the tutorial.





[JAVAEETUTORIAL-286] 'trading' example, can't release connection correctly Created: 18/Sep/14  Updated: 19/Sep/14

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: streetpoet Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: 1 day
Time Spent: Not Specified
Original Estimate: 1 day
Environment:

N/A



 Description   

In Trading example, It looks like an issue that does not send
events to container whenever a connection is closed via a
javax.resource.spi.ConnectionEventListener implementation.

Solution:

In TradeManagedConnection.java, the code should be modified something like:

private ConnectionEventListener innerListener;

public void disassociateConnection() {
this.connection = null;
if (innerListener != null)

{ innerListener.connectionClosed(new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED)); }

}

@Override
public void addConnectionEventListener(ConnectionEventListener listener)

{ innerListener = listener; }

In this way, the managed connection can notify application server to put connection back to the pool.



 Comments   
Comment by Kim Haase [ 18/Sep/14 ]

Thank you for raising this question.

Have you verified that connections do accumulate in the pool after this example is run? The developer of the app thought that closing the connection would release the resources. Can you view the pool using some tool? The GlassFish Admin Console does not show this. Thanks.

This should perhaps be implemented in the next release if some confirmation is provided that this is the best practice.

Should removeConnectionEventListener() also be implemented?

Comment by streetpoet [ 19/Sep/14 ]

yes, please see doc connector-1_7-spec-final.pdf, chapter 6.5.6
quote:
The connector architecture provides an event callback mechanism that enables an application server to receive notifications from a ManagedConnection instance. An application server uses these event notifications to manage its connection pool, to clean up invalid or terminated connections, and to manage local transactions.

this is the only way we do an interaction with app server pool by using ConnectionEventListener.
Though we haven't a tool to measure, we can do some test instead. Like this way:

We add a definition as 'maxPoolSize = 5' on '@ConnectionFactoryDefinition', and visit the page of trading example. when I refresh the page 6th, the browser hang up. And throw an exception later with message: Error in allocating a connection. Cause: In-use connections equal max-pool-size and expired max-wait-time. Cannot allocate more connections.

In personally idea, we don't need implement removeConnectionEventListener() method. Since we just wanna send a notification to app server using connectionEventListener instance when we close connection. And we don't need send any message to app server when removeConnectionEventListener() method be invoked.





[JAVAEETUTORIAL-289] 28.1.2 Coding the Service Endpoint Implementation Class Created: 06/Oct/14  Updated: 06/Oct/14

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: donahuel Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

http://docs.oracle.com/javaee/7/tutorial/doc/jaxws001.htm#BNAYQ

"The implementation class also must define a default, public, no-argument constructor."

Is that really an example of a public constructor? It looks like a void method with the same name as the class.



 Comments   
Comment by Kim Haase [ 06/Oct/14 ]

Good catch. Needs to be fixed in both example source and documentation source.

Fixed in example source at revision 1783.





[JAVAEETUTORIAL-295] logo-small.ico in duke-forest template.xhtml Created: 07/Jul/15  Updated: 07/Jul/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: evgeniyosipov Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

logo-small.ico in duke-forest don't exist and code trouble with that in template.xhtml

Solution
Create logo-small.ico (favicon.ico) file in resources and change code in template.xhtml to:

<link rel="shortcut icon" type="image/x-icon" href="#{resource['img/logo-small.ico']}"/>





[JAVAEETUTORIAL-292] ResourceAdapter Serializable clarification required Created: 07/Nov/14  Updated: 07/Nov/14

Status: Open
Project: javaeetutorial
Component/s: doc, examples
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor
Reporter: jim_b_o Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

The 'trading' example RA is NOT marked as Serializable.

The 'traffic' example RA is marked as Serializable although if invoked it would fail as the contained 'private Work tSubscriber' is a TrafficServiceSubscriber which is not Serializable.

The docs say RAs are JavaBeans and the JavaBean spec varies between 'should' and 'must' implement persistence/Serializable.

In practice most JEE servers I've used don't require the RA to be Serializable. I recall an old WLS did report a warning for JNDI reasons but deployed anyway. GS and JBoss don't seem to care.

It would be very helpful to have clarification of the Serialization requirements for RAs themselves and a clear example or best practice for the other components in respect to both Serialization and Referencable as may be needed for JNDI support. Ideally this example would deal with the case where the ultimate EIS connection code involved non Serializable classes (as could be the case in the real world using third party code).






[JAVAEETUTORIAL-294] Small problem in example code Created: 23/Feb/15  Updated: 23/Feb/15

Status: Open
Project: javaeetutorial
Component/s: examples
Affects Version/s: 7.0.5
Fix Version/s: None

Type: Bug Priority: Trivial
Reporter: fjwalraven Assignee: super_glassfish
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: code, examples

 Description   

The variable someDate is not used in the exampel:

CriteriaQuery<Pet> cq = cb.createQuery(Pet.class);
Root<Pet> pet = cq.from(Pet.class);
Date someDate = new Date(...);
cq.where(cb.gt(pet.get(Pet_.birthday), date));

should be:

CriteriaQuery<Pet> cq = cb.createQuery(Pet.class);
Root<Pet> pet = cq.from(Pet.class);
Date someDate = new Date(...);
cq.where(cb.gt(pet.get(Pet_.birthday), someDate ));






Generated at Wed Aug 31 16:11:53 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.