We are using jboss-4.0.4.GA-Patch1-installer.jar using the ejb3 profile (not 
clustered) during installation.
We are using JDK 1.5.0_06-b05 to compile the source with a ANT build script run 
using ANT 1.6.5.

Just having a look at your code snippets, does the annontation order matter?


Here's the build script for one of the layers.

  | <project basedir="." default="build" name="IEDA-BP">
  |     <!--Loads are the Property files required for this project-->
  |     <loadproperties srcfile="build/default.properties" />
  |     <property environment="env" />
  |     <path id="jboss-libs.classpath">
  |             <pathelement location="${env.JBOSS_HOME}/client/jnp-client.jar" 
/>
  |             <pathelement 
location="${env.JBOSS_HOME}/client/jbosssx-client.jar" />
  |             <pathelement location="${env.JBOSS_HOME}/client/jboss-j2ee.jar" 
/>
  |             <pathelement 
location="${env.JBOSS_HOME}/client/jboss-transaction-client.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/lib/commons-logging.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/deploy/ejb3.deployer/jboss-ejb3.jar" 
/>
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/deploy/ejb3.deployer/jboss-ejb3x.jar"
 />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/deploy/ejb3.deployer/jboss-annotations-ejb3.jar"
 />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/lib/hibernate3.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/lib/ejb3-persistence.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/lib/hibernate-annotations.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/lib/jboss-remoting.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/lib/log4j.jar" />
  |             <pathelement 
location="${env.JBOSS_HOME}/server/default/lib/mail.jar" />
  |     </path>
  |     <path id="ieda.classpath">
  |             <path refid="jboss-libs.classpath" />
  |             <fileset dir="${bp.dir}" includes="**/*.class"/>
  |             <fileset dir="${lib.dir}" includes="**/*.jar" />
  |             <fileset dir="${dist.dir}" includes="**/*.jar" />
  |     </path>
  |     <target name="init">
  |             <mkdir dir="${bp.dir}" />
  |             <mkdir dir="${client.dir}" />
  |             <mkdir dir="${manifest.location}" />
  |             <copy includeemptydirs="false" todir="${bp.dir}">
  |                     <fileset dir="${src.dir}" excludes="**/*.launch, 
**/*.java" />
  |                     <fileset dir="${pd.location}/src" 
includes="META-INF/*persistence.xml" />
  |             </copy>
  |     </target>
  |     <target name="clean">
  |             <delete dir="${bp.dir}" />
  |             <delete dir="${client.dir}" />
  |             <delete dir="${manifest.location}" />
  |             <delete>
  |                     <fileset dir="${dist.dir}">
  |                             <include name="**/*.jar" />
  |                     </fileset>
  |             </delete>
  |     </target>
  |     <!--Clean Routines are done here -->
  |     <target depends="clean" name="cleanall">
  |     </target>
  | 
  |     <!-- Run the builds in the sequence -->
  |     <!--<antcall target="build-project" />-->
  | 
  |     <!--Builds all the dependent subprojects-->
  |     <target name="build-subprojects">
  |     </target>
  | 
  |     <target depends="init, build-subprojects,build" name="buildEar">
  |             <!-- create the ear -->
  |             <ear destfile="${dist.dir}/${bp.filename}.ear" 
appxml="src/META-INF/application.xml" update="true">
  |                     <fileset dir="${dist.dir}" includes="**/*" />
  |             </ear>
  |     </target>
  | 
  |     <!-- build the manifest file -->
  |     <target name="create-manifest">
  |             <delete>
  |                     <fileset dir="${basedir}">
  |                             <include name="${manifest.file}" />
  |                     </fileset>
  |             </delete>
  |             <tstamp>
  |                     <format property="today_aus" pattern="${time.pattern}" 
locale="en" />
  |             </tstamp>
  |             <manifest file="${manifest.file}">
  |                     <attribute name="Version" value="${version}" />
  |                     <attribute name="Class-Path" value="${classpath}" />
  |                     <attribute name="Built-By" value="${built-by}" />
  |                     <attribute name="Built-On" value="${today_aus}" />
  |             </manifest>
  |     </target>
  | 
  |     <!-- Package the Project -->
  |     <target depends="init, build-subprojects" name="build">
  |             <antcall target="create-manifest">
  |                     <param name="classpath" value="${client.classpath}" />
  |             </antcall>
  |             <!-- Build client jar -->
  |             <javac debug="true" debuglevel="${debuglevel}" 
destdir="${bp.dir}" source="${source}" target="${target}">
  |                     <src path="${pd.location}/${src.dir}" />
  |                     <src path="${generic.location}/${src.dir}" />
  |                     <src path="${src.dir}" />
  |                     <classpath refid="ieda.classpath" />
  |             </javac>
  |             <jar destfile="${dist.dir}/${client.filename}.jar" 
basedir="${bp.dir}" update="true" manifest="${manifest.file}">
  |                     <include name="**/test/**" />
  |                     <include name="**/generic/**" />
  |                     <include name="**/interfaces/**" />
  |                     <include name="**/entities/**" />
  |                     <include name="**/exceptions/**" />
  |             </jar>
  |             <!-- Build bp jar -->
  |             <antcall target="create-manifest">
  |                     <param name="classpath" value="${bp.classpath}" />
  |             </antcall>
  |             <jar destfile="${dist.dir}/${bp.filename}.jar" 
basedir="${bp.dir}" update="true" manifest="${manifest.file}">
  |                     <exclude name="**/test/**" />
  |                     <exclude name="**/generic/**" />
  |                     <exclude name="**/interfaces/**" />
  |                     <exclude name="**/entities/**" />
  |                     <exclude name="**/exceptions/**" />
  |             </jar>
  |     </target>
  | </project>
  | 

And here's the build script to create the ear packages

  | <project basedir="." default="build" name="IEDA-EAR">
  |     <!--Loads are the Property files required for this project-->
  |     <loadproperties srcfile="build/app.properties" />
  |     <loadproperties srcfile="build/bp.properties" />
  |     <loadproperties srcfile="build/ui.properties" />
  |     <loadproperties srcfile="build/test.properties" />
  |     <property environment="env" />
  | 
  |     <!--Clean Routines are done here -->
  |     <target name="clean">
  |             <delete>
  |                     <fileset dir="${basedir}">
  |                             <include name="${dist.dir}/*.jar" />
  |                             <include name="${dist.dir}/*.war" />
  |                     </fileset>
  |             </delete>
  |     </target>
  | 
  |     <!-- Run the builds in the sequence -->
  |     <!--<antcall target="build-project" />-->
  | 
  |     <!--Builds all the BP dependent subprojects-->
  |     <target name="bp-pim-sub-build">
  |             <echo message="${ant.project.name}: Building PIM BP Projects" />
  |             <ant antfile="${bp.pim.location}/build.xml" target="build" 
inheritall="false" />
  |             <!--Copy the files to the library-->
  |             <copy todir="${dist.dir}" description="Copying the Depenedent 
Libraries" overwrite="true">
  |                     <fileset dir="${bp.pim.location}/${dist.dir}" 
includes="**/*.jar" />
  |             </copy>
  |     </target>
  |     
  |     
  |     <!-- BP Individual app build targets -->
  |     <target depends="clean, bp-pim-sub-build" name="build-bp-pim">
  |             <antcall target="buildEar">
  |                     <param name="appxml" value="${bp.pim.appxml}" />
  |                     <param name="ear.filename" value="${bp.ear.filename}" />
  |             </antcall>
  |     </target>
  |     
  |     <!--Builds all the UI dependent subprojects-->
  |     <target name="ui-pim-sub-build">
  |             <echo message="${ant.project.name}: Building PIM UI Projects" />
  |             <ant antfile="${ui.pim.location}/build.xml" target="build" 
inheritall="false" />
  |             <!--Copy the files to the library-->
  |             <copy todir="${dist.dir}" description="Copying the Depenedent 
Libraries" overwrite="true">
  |                     <fileset dir="${ui.pim.location}/${dist.dir}" 
includes="**/*.jar" />
  |                     <fileset dir="${ui.pim.location}/${dist.dir}" 
includes="**/*.war" />
  |             </copy>
  |     </target>
  |     
  |     <!-- UI Individual app build targets -->
  |     <target depends="clean, ui-pim-sub-build" name="build-ui-pim">
  |             <antcall target="buildEar">
  |                     <param name="appxml" value="${ui.pim.appxml}" />
  |                     <param name="ear.filename" value="${ui.ear.filename}" />
  |             </antcall>
  |     </target>
  |     
  |         <!--Builds all the TEST dependent subprojects-->
  |     <target name="test-pim-sub-build">
  |             <echo message="${ant.project.name}: Building PIM UI Projects" />
  |             <ant antfile="${test.pim.location}/build.xml" target="build" 
inheritall="false" />
  |             <!--Copy the files to the library-->
  |             <copy todir="${dist.dir}" description="Copying the Depenedent 
Libraries" overwrite="true">
  |                     <fileset dir="${test.pim.location}/${dist.dir}" 
includes="**/*.jar" />
  |                     <fileset dir="${test.pim.location}/${dist.dir}" 
includes="**/*.war" />
  |             </copy>
  |     </target>
  |     
  |     <!-- TEST Individual app build targets -->
  |     <target depends="clean, test-pim-sub-build" name="build-test-pim">
  |             <antcall target="buildEar">
  |                     <param name="appxml" value="${test.pim.appxml}" />
  |                     <param name="ear.filename" value="${test.ear.filename}" 
/>
  |             </antcall>
  |     </target>
  |     
  |     <target depends="create-manifest" name="buildEar">
  |             <!-- create the ear -->
  |             <ear destfile="${dist.dir}/${ear.filename}.ear" 
appxml="${appxml}" update="true" manifest="${manifest.file}">
  |                     <fileset dir="${dist.dir}" includes="**/*.jar" />
  |                     <fileset dir="${dist.dir}" includes="**/*.war" />
  |             </ear>
  |     </target>
  | 
  |     <!-- build the manifest file -->
  |     <target name="create-manifest">
  |             <delete>
  |                     <fileset dir="${basedir}">
  |                             <include name="${manifest.file}" />
  |                     </fileset>
  |             </delete>
  |             <tstamp>
  |                     <format property="today_aus" pattern="${time.pattern}" 
locale="en" />
  |             </tstamp>
  |             <manifest file="${manifest.file}">
  |                     <attribute name="Version" value="${version}" />
  |                     <attribute name="Built-By" value="${built-by}" />
  |                     <attribute name="Built-On" value="${today_aus}" />
  |             </manifest>
  |     </target>
  | 
  |     <target name="build"></target>
  | </project>
  | 

Here's some code snippets for the actual app.

Remote Interface

  | package pitem.pd.interfaces;
  | 
  | import java.util.List;
  | 
  | import javax.ejb.Remote;
  | 
  | 
  | import pitem.pd.entities.lookup.SpratSpecies;
  | import pitem.pd.entities.search.SpratSearch;
  | import pitem.pd.exceptions.PimInvalidSearchTermException;
  | import sys.generic.JndiLookupSupport;
  | 
  | 
  | /**
  |  * @author QuimbyG
  |  * Remote Interface for the use of the Process Layer for the UserManagement 
of the PAD2 system.
  |  *
  |  */
  | @Remote
  | public interface QueryManager extends sys.pd.interfaces.QueryManager {
  | 
  |     /** JNDI location string */
  |     public final static String location = 
JndiLookupSupport.getJndiName(QueryManager.class);
  |     
  |     /**
  |      * Find a SPRAT entry for the given criteria
  |      * @param searchTerms object containing the search criteria
  |      * @return a SPRAT species entry
  |      * @throws PimNoEntityException
  |      * @throws PimIllegalArgumentException
  |      * @throws PimInvalidSearchTermException
  |      * @throws DataLayerException
  |      */
  |     public SpratSpecies searchForSpecies(SpratSearch searchTerms) throws 
PimInvalidSearchTermException, Exception;
  | }
  | 


Stateless Session Bean

  | package pitem.pd.managers;
  | 
  | import java.util.ArrayList;
  | import java.util.List;
  | 
  | import javax.ejb.ApplicationException;
  | import javax.ejb.Stateless;
  | import javax.persistence.EntityManager;
  | import javax.persistence.NoResultException;
  | import javax.persistence.NonUniqueResultException;
  | import javax.persistence.PersistenceContext;
  | import javax.persistence.Query;
  | 
  | import org.apache.log4j.Logger;
  | 
  | 
  | import pitem.pd.entities.lookup.SpratSpecies;
  | import pitem.pd.entities.search.SpratSearch;
  | import pitem.pd.exceptions.PimDataException;
  | import pitem.pd.exceptions.PimIllegalArgumentException;
  | import pitem.pd.exceptions.PimInvalidSearchTermException;
  | import pitem.pd.exceptions.PimNoEntityException;
  | import pitem.pd.interfaces.QueryManager;
  | import sys.pd.exceptions.DataLayerException;
  | 
  | 
  | /**
  |  * @author QuimbyG
  |  * This class implements the remote interface for PIM queries.
  |  */
  | @ApplicationException(rollback=false)
  | public @Stateless class QueryManagerBean implements QueryManager {
  |     
  |     /** Inject the entity manager */
  |     @PersistenceContext(unitName="PITEM")
  |     private EntityManager manager;
  | 
  |     /** Log4j logging */
  |     static Logger logger = Logger.getLogger(QueryManagerBean.class);
  |     
  |     /*
  |      *  (non-Javadoc)
  |      * @see 
au.gov.deh.pim.pd.dm.PimQueryManager#searchForSpecies(au.gov.deh.pim.pd.search.SpratSearch)
  |      */
  |     public SpratSpecies searchForSpecies(SpratSearch searchTerms) throws 
PimInvalidSearchTermException,
  |                                                                             
                                                                        
PimNoEntityException, 
  |                                                                             
                                                                        
PimIllegalArgumentException, 
  |                                                                             
                                                                        
DataLayerException {
  |             if (searchTerms == null) {
  |                     logger.warn("No search terms passed");
  |                     throw new 
PimInvalidSearchTermException("searchForSpecies","Null passed",
  |                                     "Must have a valid SpratSearch object");
  |             }
  | 
  |             logger.info("search for Species with SpratTerms");
  |             SpratSpecies result = new SpratSpecies();
  |             
  |             /* Query for the taxon id if set */
  |             if (searchTerms.getTaxon() != null) {
  |                     Integer taxon = searchTerms.getTaxon();
  |                     /* Check if TAXON_ID is valid */
  |                     if (taxon > 0) {
  |                             try {
  |                                     result = (SpratSpecies) 
manager.createQuery("select OBJECT(s) from SpratSpecies s" +
  |                                             " WHERE s.taxon = :taxon")
  |                                             .setParameter("taxon",taxon)
  |                                             .getSingleResult();
  |                             } catch (NonUniqueResultException e) { 
  |                                     logger.warn("Multiple records");
  |                                     throw new 
PimInvalidSearchTermException("searchForSpecies","Not unique",
  |                                                     "Query term must return 
only one result",e);
  |                             } catch (NoResultException e) {
  |                                     logger.warn("No record");
  |                                     throw new 
PimNoEntityException("searchForSpecies","No Record","Proposal does not 
exist",e);
  |                             } catch (IllegalArgumentException e){
  |                                     logger.error("Illegal argument",e);
  |                                     throw new 
PimIllegalArgumentException("searchForSpecies", "Illegal Argument", 
e.toString(), null, e);
  |                             } catch (Throwable e) {
  |                                     logger.error("Error with Species Search 
query",e);
  |                                     throw new 
DataLayerException(PimDataException.ERR_NUMBER, "searchForSpecies", "Unknown", 
e.toString(), null, e);
  |                             }
  |                     } else {
  |                             logger.warn("invalid taxon id passed");
  |                             throw new 
PimInvalidSearchTermException("searchForSpecies","taxon is less than zero",
  |                                             "Valid taxon must be greater 
than zero");
  |                     }
  |             } else if (searchTerms.getScientificName() != null) {
  |                     /* Query for the species name otherwise */
  |                     String s = "%" + 
replaceWildCards(searchTerms.getScientificName()) + "%";
  | 
  |                     try {
  |                             result = (SpratSpecies) 
manager.createQuery("select OBJECT(s) from SpratSpecies s" +
  |                                     " WHERE UPPER(s.scientificName) LIKE 
UPPER(:sciName)")
  |                                     .setParameter("sciName", s)
  |                                     .getSingleResult();
  |                     } catch (NonUniqueResultException e) { 
  |                             logger.warn("Multiple records");
  |                             throw new 
PimInvalidSearchTermException("searchForSpecies","Not unique",
  |                                             "Query term must return only 
one result",e);
  |                     } catch (NoResultException e) {
  |                             logger.warn("No record");
  |                             throw new 
PimNoEntityException("searchForSpecies","No Record","Proposal does not 
exist",e);
  |                     } catch (IllegalArgumentException e){
  |                             logger.error("Illegal argument",e);
  |                             throw new 
PimIllegalArgumentException("searchForSpecies", "Illegal Argument", 
e.toString(), null, e);
  |                     } catch (Throwable e) {
  |                             logger.error("Error with Species search 
query",e);
  |                             throw new 
DataLayerException(PimDataException.ERR_NUMBER, "searchForSpecies", "Unknown", 
e.toString(), null, e);
  |                     }
  |             } else {
  |                     logger.warn("No search terms passed");
  |                     throw new 
PimInvalidSearchTermException("searchForSpecies","Empty object",
  |                                     "Must have a valid SpratSearch object");
  |             }
  |             return result;
  |     }
  |     
  |     /** Method to turn standard wildcards into EJBQL wildcards 
  |      * 
  |      * @param s the String to convert
  |      * @return the converted string
  |      */
  |     private String replaceWildCards(String s) {
  |             logger.debug("replacing wildcards");
  |             
  |             s = s.replace("%","_"); // escape all percentage signs 
  |             s = s.replace(' ','%'); // turn spaces into wildcards
  |             s = s.replace('*','%'); // convert * to % for SQL search
  |             s = s.replace('?','_'); // convert ? to _ for SQL search
  |             
  |             return s;
  |     }
  | }
  | 

The place where it is called in the Backing Bean to test things

  |              try {
  |                     SpratSearch s = new SpratSearch(new Integer(-1));
  |                     SpratSpecies t = Qm.searchForSpecies(s);
  |                     result.setDesc("Found " + 
t.getMigratoryScientificName());
  |                     
  |             } catch (PimInvalidSearchTermException e) {
  |                     
  |                     result.setDesc(e.getMessage());
  |                     result.setPass(true);
  |                     
  |             } catch (Exception e) {
  |                     if (e instanceof PimInvalidSearchTermException) {
  |                             PimInvalidSearchTermException t = 
(PimInvalidSearchTermException) e;
  |                             result.setDesc(t.traceBack());
  |                             result.setPass(true);
  |                     } else {
  |                             result.setDesc(e.toString());
  |                             result.setPass(false);
  |                             e.printStackTrace();
  |                     }
  |             }
  | 

If it can identify the correct Exception the test passes otherwise it fails.

Hope this helps clarify what is happening.

Thanks for you time.

Grant

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3974712#3974712

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3974712
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to