SEVERE: Servlet.service() for servlet [com.servlet.FileCalling] in context with path [/ScfUploaddFile] threw exception [Servlet execution threw an exception] with root cause
java.lang.ClassNotFoundException: javax.ejb.CreateException
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
at com.bs.theme.migration.loader.utility.QueryBuilder.doTFinvdtoQuery(QueryBuilder.java:355)
at com.bs.theme.migration.loader.action.manager.FGBDataMigration.main(FGBDataMigration.java:61)
at com.servlet.FileCalling.doPost(FileCalling.java:38)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:646)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:503)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1070)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:314)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:662)
但如果我在java控制台应用程序中运行相同的代码,它会被执行,我在我的控制台中获取值,但是当我通过将它与我的Web应用程序集成运行相同的代码时,它会抛出我上面提到的错误
public String process(String message, int start) {
System.out.println("from process method");
String result = "Unable to Process";
String ejbClientUrl = DBPropertiesLoader.EJBCLIENT_URL;
System.out.println("Connecting : " + ejbClientUrl);
try {
System.getProperties().put("java.naming.factory.initial", "com.ibm.websphere.naming.WsnInitialContextFactory");
System.getProperties().put("java.naming.provider.url", DBPropertiesLoader.TI_EJB_URL);
System.getProperties().put("java.naming.provider.url", ejbClientUrl);
Context ctx = new InitialContext();
Object ejbObject = ctx.lookup("ejb/EnigmaServiceAccess");
System.out.println("EJB Object : "+ejbObject);
QueryBuilder.java
public static String doTFinvdtoQuery(String table, String inputFile,
String lowRange, String highRange) {
Connection connection = null;
String xmlToPost = null;
Statement queryStatement = null;
ResultSet resultSet = null;
try {
connection = ThemeDB.getDBConnection();
queryStatement = connection.createStatement();
System.out.println("****Generating Query****" + "\n");
String query = getQuery(table, inputFile, lowRange, highRange);
resultSet = queryStatement.executeQuery(query);
BeanProcessor bp = new BeanProcessor();
List<ServiceRequest> sRequestItems = new ArrayList<ServiceRequest>();
String finalResult = "Unable to Process";
int num = 0;
int count = 0;
while (resultSet.next()) {
try {
num++;
count = resultSet.getInt("SNO");
ArrayList<InvoiceCustomer> list = new ArrayList<InvoiceCustomer>();
list.add((InvoiceCustomer) bp.toBean(resultSet, InvoiceCustomer.class));
TFinvdtoHandler tfinv = new TFinvdtoHandler();
sRequestItems.add(tfinv
.createTFinvdtoRequest(list));
if (num % 1 == 0) {
xmlToPost = MessageUtil.xmlServiceRequest(
sRequestItems, "TFINVNEW");
logger.debug(xmlToPost);
System.out
.println("**Sending data to TI Plus through EJB Client***"
+ "\n");
finalResult = TIPlusEJBClient.process(xmlToPost, count);
if (!finalResult.equals("Unable to Process")) {
List<ServiceResponse> serviceResponses = MessageUtil
.processResponse(finalResult);
for (ServiceResponse serviceResponse : serviceResponses) {
// System.out.println("**Response Status***"
// +serviceResponse.getResponseHeader().getStatus());
// System.out.println("**Response CorrID***"
// +serviceResponse.getResponseHeader().getStatus());
MigrationUtil.updateMigrationDataStagingStatus(
table, serviceResponse
.getResponseHeader()
.getStatus(), serviceResponse
.getResponseHeader()
.getCorrelationId(),
serviceResponse.getResponseHeader()
.getDetails().getError()
.toString());
}
}
logger.debug("\n");
sRequestItems = new ArrayList<ServiceRequest>();
finalResult = "Unable to Process";
}
} catch (Exception e) {
// TODO: handle exception
logger.debug("Exception Occured ->" + e.getMessage());
e.printStackTrace();
}
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
logger.debug("Exception Occured ->" + e1.getMessage());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
logger.debug("Exception Occured ->" + e1.getMessage());
} catch (Exception e) {
logger.debug("Exception Occured ->" + e.getMessage());
} finally {
MigrationUtil.surrenderConnection(connection, resultSet,
queryStatement);
}
/*
* System.out.println("Remaining request count ->" +
* sRequestItems.size()); if (sRequestItems.size() > 0) {
*
* xmlToPost = MessageUtil .xmlServiceRequest(sRequestItems,
* "TFILCDTO"); logger.debug(xmlToPost); finalResult =
* TIPlusEJBClient.process(xmlToPost, count);
*
* System.out
* .println("**Sending remaining data to TI Plus through EJB Client***"
* + "\n"); if (!finalResult.equals("Unable to Process")) {
*
* List<ServiceResponse> serviceResponses = MessageUtil
* .processResponse(finalResult); for (ServiceResponse serviceResponse :
* serviceResponses) { // System.out.println("**Response Status***" //
* +serviceResponse.getResponseHeader().getStatus()); //
* System.out.println("**Response CorrID***" //
* +serviceResponse.getResponseHeader().getStatus());
*
* MigrationUtil.updateMigrationDataStagingStatus(table,
* serviceResponse.getResponseHeader().getStatus(),
* serviceResponse.getResponseHeader() .getCorrelationId(),
* serviceResponse .getResponseHeader().getDetails()
* .getError().toString()); }
*
* }
*
* logger.debug("\n");
*
* }
*/
return xmlToPost;
}
答案 0 :(得分:0)
项目 - &gt;属性 - &gt; Java构建路径 - &gt;添加库 - &gt;服务器运行时 - &gt;单击下一步 - &gt;选择你的EJB容器
答案 1 :(得分:0)
它将在WebSphere中作为Web应用程序运行时没有任何问题。
如果要从Tomcat运行它,则需要将以下jar添加到应用程序中,但仅适用于Tomcat:com.ibm.ws.ejb.thinclient_x.y.z.jar
和com.ibm.ws.orb_8.5.0.jar
。如果您的WebSphere受到保护,您还应该查看此页面Running the IBM Thin Client for Enterprise JavaBeans,因为您可能在以后遇到SSL问题。