5 Replies Latest reply on Jan 20, 2011 3:00 AM by song Chaoyue

    Unable to locate class

    Arbi Sookazian Master

      Seam 2.0.2-FP

      I am using the WEB-INF/dev directory in my WAR for incremental hot deployment.  I saw this link:
      but pre-pending the package name of the class does not help.

      Any ideas how to fix this?

      org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [com.cox.ers.session.CustomerEquipmentDTO] [SELECT new com.cox.ers.session.CustomerEquipmentDTO( AppSite.siteName ,er.icomsSiteId ,er.equipmentRecoveryId ,er.accountNumber ,er.customerName ,er.addressLine1 ,er.addressLine2 ,er.addressLine3 ,er.addressLine4 ,er.billToAddress ,er.b2addressLine1 ,er.b2addressLine2 ,er.b2addressLine3 ,er.b2addressLine4 ,er.itemNumber ,er.serialNumber ,er.equipmentTypeListValueCode ,er.serviceOccurance ,erscl.equipmentStatus.equipmentStatusId ,erscl.applicationUserByUpdatedByUserId.userId ,erscl.updatedDate ,( SELECT _listValue.description FROM com.cox.ers.entity.List as _list ,com.cox.ers.entity.ListValue as _listValue WHERE _list.listId = _listValue.list.listId AND _list.listName = 'Recovery_Status' AND _listValue.code = erscl.equipmentStatus.equipmentStatusId ) AS EquipmentStatus ,( SELECT _listValue.listValue FROM com.cox.ers.entity.List as _list ,com.cox.ers.entity.ListValue as _listValue WHERE _list.listId = _listValue.list.listId AND _list.listName = 'ServiceCategoryCode' AND _listValue.code = er.serviceCategoryCodeListValueCode ) AS ServiceCategoryCode ,( SELECT _listValue.description FROM com.cox.ers.entity.List _list ,com.cox.ers.entity.ListValue _listValue WHERE _list.listId = _listValue.list.listId AND _list.listName = 'Equipment_Type' AND _listValue.code = er.equipmentTypeListValueCode ) AS EquipmentType ) FROM com.cox.ers.entity.EquipmentRecoveryStatusChangeLog as erscl ,com.cox.ers.entity.EquipmentRecovery as er ,com.cox.ers.entity.ApplicationSite as AppSite WHERE erscl.equipmentRecovery.equipmentRecoveryId = er.equipmentRecoveryId AND AppSite.internalSiteId = er.icomsSiteId AND erscl.isCurrent = 1 AND er.icomsSiteId = :icomsSiteId AND er.accountNumber = :accountNumber ]

      I've tried it with and w/o the @Name annotation below:

      package com.cox.ers.session;
      import java.io.Serializable;
      import java.util.Date;
      import org.jboss.seam.annotations.Name;
      public class CustomerEquipmentDTO implements Serializable {
           private static final long serialVersionUID = 3017685951694270769L;
           private String siteName;
           private short icomsSiteId;
           private Long equipmentRecoveryId;
           private long accountNumber;
           private String customerName;     
           private String addressLine1;
           private String addressLine2;
           private String addressLine3;
           private String addressLine4;
           private String billToAddress;
           private String b2addressLine1;
           private String b2addressLine2;
           private String b2addressLine3;
           private String b2addressLine4;
           private String itemNumber;
           private String serialNumber;
           private String serviceCategoryCodeListValueCode;
           private int serviceOccurance;
           private Integer equipmentStatusId;
           private int updatedByUserId;
           private Date updatedDate;
           private String equipmentStatus;
           private String serviceCategoryCode;
           private String equipmentType;
           /*********************************************************BEGIN METHODS*********************************************************/
           public CustomerEquipmentDTO( String siteName,
                                               short icomsSiteId,
                                               Long equipmentRecoveryId,
                                               long accountNumber,
                                               String customerName,     
                                               String addressLine1,
                                               String addressLine2,
                                               String addressLine3,
                                               String addressLine4,
                                               String billToAddress,
                                               String b2addressLine1,
                                               String b2addressLine2,
                                               String b2addressLine3,
                                               String b2addressLine4,
                                               String itemNumber,
                                               String serialNumber,
                                               String serviceCategoryCodeListValueCode,
                                               int serviceOccurance,
                                               Integer equipmentStatusId,
                                               int updatedByUserId,
                                               Date updatedDate,
                                               String equipmentStatus,
                                               String serviceCategoryCode,
                                               String equipmentType) {
           public String getSiteName() {
                return siteName;
           public void setSiteName(String siteName) {
                this.siteName = siteName;
           public short getIcomsSiteId() {
                return icomsSiteId;
           public void setIcomsSiteId(short icomsSiteId) {
                this.icomsSiteId = icomsSiteId;
           public Long getEquipmentRecoveryId() {
                return equipmentRecoveryId;
           public void setEquipmentRecoveryId(Long equipmentRecoveryId) {
                this.equipmentRecoveryId = equipmentRecoveryId;
           public long getAccountNumber() {
                return accountNumber;
           public void setAccountNumber(long accountNumber) {
                this.accountNumber = accountNumber;
           public String getCustomerName() {
                return customerName;
           public void setCustomerName(String customerName) {
                this.customerName = customerName;
           public String getAddressLine1() {
                return addressLine1;
           public void setAddressLine1(String addressLine1) {
                this.addressLine1 = addressLine1;
           public String getAddressLine2() {
                return addressLine2;
           public void setAddressLine2(String addressLine2) {
                this.addressLine2 = addressLine2;
           public String getAddressLine3() {
                return addressLine3;
           public void setAddressLine3(String addressLine3) {
                this.addressLine3 = addressLine3;
           public String getAddressLine4() {
                return addressLine4;
           public void setAddressLine4(String addressLine4) {
                this.addressLine4 = addressLine4;
           public String getBillToAddress() {
                return billToAddress;
           public void setBillToAddress(String billToAddress) {
                this.billToAddress = billToAddress;
           public String getB2addressLine1() {
                return b2addressLine1;
           public void setB2addressLine1(String line1) {
                b2addressLine1 = line1;
           public String getB2addressLine2() {
                return b2addressLine2;
           public void setB2addressLine2(String line2) {
                b2addressLine2 = line2;
           public String getB2addressLine3() {
                return b2addressLine3;
           public void setB2addressLine3(String line3) {
                b2addressLine3 = line3;
           public String getB2addressLine4() {
                return b2addressLine4;
           public void setB2addressLine4(String line4) {
                b2addressLine4 = line4;
           public String getItemNumber() {
                return itemNumber;
           public void setItemNumber(String itemNumber) {
                this.itemNumber = itemNumber;
           public String getSerialNumber() {
                return serialNumber;
           public void setSerialNumber(String serialNumber) {
                this.serialNumber = serialNumber;
           public String getServiceCategoryCodeListValueCode() {
                return serviceCategoryCodeListValueCode;
           public void setServiceCategoryCodeListValueCode(
                     String serviceCategoryCodeListValueCode) {
                this.serviceCategoryCodeListValueCode = serviceCategoryCodeListValueCode;
           public int getServiceOccurance() {
                return serviceOccurance;
           public void setServiceOccurance(int serviceOccurance) {
                this.serviceOccurance = serviceOccurance;
           public Integer getEquipmentStatusId() {
                return equipmentStatusId;
           public void setEquipmentStatusId(Integer equipmentStatusId) {
                this.equipmentStatusId = equipmentStatusId;
           public int getUpdatedByUserId() {
                return updatedByUserId;
           public void setUpdatedByUserId(int updatedByUserId) {
                this.updatedByUserId = updatedByUserId;
           public Date getUpdatedDate() {
                return updatedDate;
           public void setUpdatedDate(Date updatedDate) {
                this.updatedDate = updatedDate;
           public String getEquipmentStatus() {
                return equipmentStatus;
           public void setEquipmentStatus(String equipmentStatus) {
                this.equipmentStatus = equipmentStatus;
           public String getServiceCategoryCode() {
                return serviceCategoryCode;
           public void setServiceCategoryCode(String serviceCategoryCode) {
                this.serviceCategoryCode = serviceCategoryCode;
           public String getEquipmentType() {
                return equipmentType;
           public void setEquipmentType(String equipmentType) {
                this.equipmentType = equipmentType;

        • 1. Re: Unable to locate class
          Arbi Sookazian Master

          Reproduced using simpler example:

          Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate class [com.cox.ers.session.TestDTO] [select new com.cox.ers.session.TestDTO(er.lastName, er.firstName) from com.cox.ers.entity.EquipmentRecovery er]

          package com.cox.ers.session;
          import java.util.List;
          import javax.persistence.EntityManager;
          import org.jboss.seam.ScopeType;
          import org.jboss.seam.annotations.Create;
          import org.jboss.seam.annotations.In;
          import org.jboss.seam.annotations.Logger;
          import org.jboss.seam.annotations.Name;
          import org.jboss.seam.annotations.Scope;
          import org.jboss.seam.annotations.Startup;
          import org.jboss.seam.log.Log;
          public class TestDTOAction {
               private EntityManager entityManager;
               private Log log;
               public void getDTO(){
                    List<TestDTO> list = entityManager.createQuery("select new com.cox.ers.session.TestDTO(er.lastName, er.firstName) from EquipmentRecovery er").getResultList();
                    log.info("list.size() = "+list.size());

          package com.cox.ers.session;
          public class TestDTO {
               private String fname;
               private String lname;
               public TestDTO(String fname, String lname){
                    this.fname = fname;
                    this.lname = lname;
               public String getFname() {
                    return fname;
               public void setFname(String fname) {
                    this.fname = fname;
               public String getLname() {
                    return lname;
               public void setLname(String lname) {
                    this.lname = lname;

          • 2. Re: Unable to locate class
            Arbi Sookazian Master
            java.lang.ClassNotFoundException: No ClassLoaders found for: com.cox.ers.session.TestDTO

            I verified that both DTO classes do exist in the following directory:


            Is this a bug or what?

            As per the Seam 2.0.2 ref doc:

            You need to be aware of the following limitations:
            • the components must be JavaBean components, they cannot be EJB3 beans (we are working
            on fixing this limitation)
            • entities can never be hot-deloyed
            • components deployed via components.xml may not be hot-deployed
            • the hot-deployable components will not be visible to any classes deployed outside of WEB-INF/
            • Seam debug mode must be enabled and jboss-seam-debug.jar must be in WEB-INF/lib
            • You must have the Seam filter installed in web.xml
            • You may see errors if the system is placed under any load and debug is enabled.

            None of these rules are being violated in my project AFAIK.

            The only that seems problematic/relevant is this one:

            the hot-deployable components will not be visible to any classes deployed outside of WEB-INF/

            But all my classes (backing beans and DTOs) are JavaBeans in the WEB-INF/dev directory.

            Not sure why this is happening...

            • 3. Re: Unable to locate class
              Arbi Sookazian Master

              Ok so I integrated the two TestDTO and TestDTOAction classes into my older Seam 2.0.2 app that is an EAR (i.e. not using incremental hot deployment or the WEB-INF/dev directory) and it works:

              16:22:04,898 INFO  [Contexts] starting up: org.jboss.seam.web.session
              16:22:04,898 INFO  [Contexts] starting up: testDTOAction
              16:22:10,117 INFO  [STDOUT] Hibernate: 
                      equipmentr0_.ICOMSWorkOrderNumber as col_0_0_,
                      equipmentr0_.ICOMSWorkOrderTechID as col_1_0_ 
                      boBETS.dbo.EquipmentRepair equipmentr0_
              16:22:15,508 INFO  [TestDTOAction] list.size() = 35

              So it most likely has to do with the incremental hot deployment and the special Seam classloader which is apparently isolating access to the DTO class from Hibernate.

              So what is a good workaround/fix for this?  This is the first problem I've run into using incremental hot deployment with JavaBeans, it was smooth smailing prior to this.  thx.

              • 4. Re: Unable to locate class
                Arbi Sookazian Master

                In the original app I moved the TestDTO class into a package other than the WEB-INF/dev (src/action) and it works.

                So it was the Seam classpath/classloader problem.

                So that is a work around I guess, just move it into a package that is visible by Hibernate and other frameworks...

                • 5. Re: Unable to locate class
                  song Chaoyue Newbie

                  I am from China.Now I have the same question.I need some help. if somebody can ask my question.I will be very happy!To send an email for me.