我正在使用apache ant
构建持续集成来执行构建。
目前我们面临一些奇怪的ant warning
。我已经将ant任务指向生成名为DnAOperationEJB.java
这里是ant构建文件:
<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>
编译完成后,构建结果为 SUCCESSFUL ,如下所示
[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
但是,EJB Gen生成的文件未显示在目标文件夹中。我认为这是由于Ant无法找到EJBGen文件,如Warning: No EJBGen file found!
DnAOperationEJB.java
的源代码如下:
/*
* 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();
}
}
}
但我已经把EJB文件放到了ant任务中。
任何想法,帮助和/或评论?
答案 0 :(得分:0)
找到最佳解决方案后,就会出现此类错误的解决方案。
首先:详细您的EJBGEN功能。
<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>
然后秒,将来源从 1.6更改为1.5
在我的情况下,如果我在源代码中放入1.6,则会抛出另一个错误。 Exception in thread "main" com.bea.wls.ejbgen.EJBGenException: ejbName is a required attribute
在这里回答此错误how to generate deployment descriptor using ejbGen for weblogic?
然后第三次,将-lib参数放入ant任务中。如果未指定不在类路径中的库,那么这是可选参数。 例如:
ant build -lib ../lib -v > build.log