Search code examples
javajakarta-eeantejb

EJBGen Ant Build Successfull Returning Warning no EJB File Found


I am in the middle of building continuous integration using apache ant to execute the build.

Currently we are facing some weird ant warning. I already point the ant task to generate EJBGen to EJB file called DnAOperationEJB.java

Herewith the ant build file:

<ejbgen source="1.6" outputDir="${staging.dir}" descriptorDir="ejbModule\META-INF" forceGeneration="true"
            ejbSuffix = "."
            localSuffix = "Local"
            localHomeSuffix = "LocalHome">
            <fileset dir="ejbModule/sample/oss/dna/ejb">
                    <contains text="@Session"/>
                    <contains text="@LocalMethod"/>
            </fileset>
</ejbgen>

After compiling, the result of the build was SUCCESSFUL as shown below

   [ejbgen] Invoking EJBGen with the following command line:
   [ejbgen]   -d
   [ejbgen]   C:\Users\Jenkins Project\Sample\DnA_Ejb\staging
   [ejbgen]   -forceGeneration
   [ejbgen]   -source
   [ejbgen]   1.6
   [ejbgen]   -ejbSuffix
   [ejbgen]   .
   [ejbgen]   -localSuffix
   [ejbgen]   Local
   [ejbgen]   -localHomeSuffix
   [ejbgen]   LocalHome
   [ejbgen]   -descriptorDir
   [ejbgen]   C:\Users\Jenkins Project\Sample\DnA_Ejb\ejbModule\META-INF
   [ejbgen]   C:\Users\Jenkins Project\Sample\DnA_Ejb\ejbModule\sample\oss\dna\ejb\DnAOperationEJB.java
   [ejbgen] EJBGen WebLogic Server 10.3.6.0  Tue Nov 15 08:52:36 PST 2011 1441050
   [ejbgen]  Warning:  No EJBGen file found!

BUILD SUCCESSFUL
Total time: 1 second

But the generated file from EJB Gen is not shown up in target folder. I think this is due to Ant cannot find the EJBGen file, as shown in the Warning: No EJBGen file found!

The source code of DnAOperationEJB.java as below:

/*
 * GenericSessionBean subclass automatically generated by OEPE.
 *
 * Please complete the ejbCreate method as needed to properly initialize new instances of your bean and add
 * all required business methods. Also, review the Session, JndiName and FileGeneration annotations 
 * to ensure the settings match the bean's intended use.
 */
@Session(ejbName = "DnAOperationEJB", initialBeansInFreePool = "5", maxBeansInFreePool = "20", transactionType = SessionTransactionType.CONTAINER, defaultTransaction = TransactionAttribute.SUPPORTS)
@JndiName(local = "ejb.DnAOperationEJBLocalHome")
@FileGeneration(remoteClass = Constants.Bool.FALSE, remoteHome = Constants.Bool.FALSE, localClass = Constants.Bool.TRUE, localHome = Constants.Bool.TRUE)
public class DnAOperationEJB extends GenericSessionBean implements SessionBean {

    private static final long serialVersionUID = 1L;
    private static String className = DnAOperationEJB.class.getName();
    /*
     * (non-Javadoc)
     * 
     * @see weblogic.ejb.GenericSessionBean#ejbCreate()
     */
    public void ejbCreate() 
    {
        // IMPORTANT: Add your code here
    }


//  @LocalMethod()
    @LocalMethod(transactionAttribute =  TransactionAttribute.NOT_SUPPORTED)
    public Context createContext(String xmlIn, String tID)
    {
        Log.debug("Executing createContext", className, tID);

        try
        {
            Context ctx = new Context();
            ctx.setTransactionID(tID);
            ctx.setRequest(xmlIn);

            return ctx;
        }
        catch (Exception e) 
        {
            throw new RuntimeException(e);
        }
        finally
        {
            Log.debug("createContext executed", className, tID);
        }       
    }

//  @LocalMethod()
    @LocalMethod(transactionAttribute =  TransactionAttribute.REQUIRES_NEW)
    public void executeOperation(Context ctx) throws Exception 
    {
        Log.debug("Executing executeOperation", className, ctx.getTransactionID());
        Operation operation = null;
        try
        {
            operation = OSSFactory.newOperation(ctx);
            Log.debug("OperationBegin: " + ctx.getRequest().toString(), className, ctx.getTransactionID());
            operation.execute();
        }
        catch(Exception e)
        {
            Log.exception(e, className, ctx.getTransactionID());
            e.printStackTrace();
            getSessionContext().setRollbackOnly();
            Log.debug("Transaction rolled back",  className, ctx.getTransactionID());
            throw e;
        }
        finally
        {
            if(operation != null)
                operation.terminate(false);
            Log.debug("executeOperation executed", className, ctx.getTransactionID());
        }
    }

    @LocalMethod(transactionAttribute =  TransactionAttribute.NOT_SUPPORTED)
    public String generateResponse(Context ctx)  throws Exception 
    {
        Log.debug("Executing generateResponse", className, ctx.getTransactionID());

        Operation operation = null;             
        try
        {
            operation = OSSFactory.newOperation(ctx);
            return operation.generateResponse(null);
        }
        finally
        {
            if(operation != null)
                operation.terminate(false);
            Log.debug("generateResponse executed", className, ctx.getTransactionID());
        }
    }

    @LocalMethod(transactionAttribute =  TransactionAttribute.NOT_SUPPORTED)
    public String generateErrorResponse(Context ctx, Exception exception) 
    {
        Log.debug("Executing generateErrorResponse", className, ctx.getTransactionID());

        Operation operation = null;             

        try
        {
            operation = OSSFactory.newOperation(ctx);
            return operation.generateResponse(exception);
        }
        catch(Exception e)
        {
            Log.exception(e, className, ctx.getTransactionID());
            e.printStackTrace();
            throw new RuntimeException(e);
        }
        finally
        {
            if(operation != null)
                operation.terminate(false);
            Log.debug("generateErrorResponse executed", className, ctx.getTransactionID());
        }
    }

//  @LocalMethod()
    @LocalMethod(transactionAttribute =  TransactionAttribute.REQUIRES_NEW)
    public void terminate (Context ctx)
    {
        Log.debug("Executing terminate", className, ctx.getTransactionID());

        Operation operation = null;
        try
        {
            operation = OSSFactory.newOperation(ctx);
            operation.terminate(true);
        }
        catch(Exception e)
        {
            Log.exception(e, className, ctx.getTransactionID());
            e.printStackTrace();
        }
    }
}

But i already put the EJB file to ant task.

Any ideas, help and/or comments?


Solution

  • After finding a best solution, there is SOLUTION for this kind of error.

    First: verbose your EJBGEN function.

    <ejbgen source="1.6" outputDir="${staging.dir}" descriptorDir="ejbModule\META-INF" forceGeneration="true" 
    verbose="true"
                ejbSuffix = "."
                localSuffix = "Local"
                localHomeSuffix = "LocalHome">
                <fileset dir="ejbModule/sample/oss/dna/ejb">
                        <contains text="@Session"/>
                        <contains text="@LocalMethod"/>
                </fileset>
    </ejbgen>
    

    Then second, change the source from 1.6 to 1.5

    In my case, there are another error thrown if i put 1.6 in the source. Exception in thread "main" com.bea.wls.ejbgen.EJBGenException: ejbName is a required attribute

    answer this error here how to generate deployment descriptor using ejbGen for weblogic?

    Then third, put the -lib parameter in your ant task. This is optional parameter if you not specify libraries that are not in your classpath. example:

    ant build -lib ../lib -v > build.log