我正在尝试在 WEBMethods 中编译和测试 Java 服务。我必须重新加载该方法,现在它告诉我代码中的某个地方有错误。我不确定错误在哪里,甚至不知道如何找到错误,因为右侧实际上没有红色矩形,并且屏幕上没有突出显示错误。
问题:导致我的 WEBMethods 服务出现错误的原因是什么?
类(class):
import com.wm.data.*;
import com.wm.util.Values;
import com.wm.app.b2b.server.Service;
import com.wm.app.b2b.server.ServiceException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.*;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class createListAndWriteFiles_SVC
{
/**
* The primary method for the Java service
*
* @param pipeline
* The IData pipeline
* @throws ServiceException
*/
public static final void createListAndWriteFiles(IData pipeline)
throws ServiceException {
try {
IDataCursor pipelineCursor = pipeline.getCursor();
//Get input file name
String fileName = IDataUtil.getString(pipelineCursor,"FileName");
//Get output directory
String outputDirectory = IDataUtil.getString(pipelineCursor,"OutputDirectory");
//ArrayList for storing results
//Actual Java code starts here if you wanted to run in a java test class
ArrayList<String> listOfFileNames = new ArrayList<String>();
//Open the file
BufferedReader reader = new BufferedReader(new FileReader(fileName));
//New -- create later
PrintWriter writer = null;
//File line that is used to read in the text file.
String FileLine = null;
//Compile a matcher for searching through the file
final String REGEX = ("(?i)^\\./\\s+ADD\\s+NAME\\s*=(\\S+)");
//Will hold the valid String pattern
Pattern validStringPattern = Pattern.compile(REGEX);
//Loop through the file
//Main loop that will create the files -- read until the end of the file
while ((FileLine = reader.readLine()) != null) {
//Perform match on the FileLine of text
Matcher matcher = validStringPattern.matcher(FileLine);
//If the header string is found then create a new file -- else will keep writing a single line of the new file
//Until a new file header is found and then the true part of the file is matched
if (matcher.find()) {
//Found a match, add it to the result list
listOfFileNames.add(matcher.group(1));
//If the file is not equal to null then close
if (writer != null){
//Important to close the file
writer.close();
}
//Creates the new file name
writer = new PrintWriter(new BufferedWriter(new FileWriter(outputDirectory + matcher.group(1) + ".txt")));
} else if (writer != null) {
//will write single line of text to the file if the write is not null
writer.println(FileLine);
}
}
//Ends the actual Java code if you wanted to run in test class
//Return the list of results
IDataUtil.put( pipelineCursor,"ListOfFileNames",listOfFileNames.toArray());
pipelineCursor.destroy();
reader.close();
writer.close();
} catch (java.io.IOException e) {
//Just pass any exceptions to the calling service threw web methods throw new ServiceException(name of exception HERE)
e.printStackTrace();
throw new ServiceException(e);
}
}
// --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
// --- <<IS-END-SHARED-SOURCE-AREA>> ---
/**
* The service implementations given below are read-only and show only the
* method definitions and not the complete implementation.
*/
public static final void FileReadAndWrite(IData pipeline)
throws ServiceException {
}
}
错误:
The source was saved, but was not compiled due to the following errors:
C:\SoftwareAG\IntegrationServer\packages\DssAccessBackup\code\source\DssAccessBackup\services\java.java:109: cannot find symbol
symbol : class io
location: class DssAccessBackup.services.java
} catch (java.io.IOException e) {
^
1 error
我在 WEBMethods 中看到的内容的网络屏幕截图。这只是屏幕的顶部。
下面的两篇文章提到了有关未正确发布类(class)的内容。如果类的命名不正确或者是否有其他地方隐藏了代码,我不确定。这是我的第一个 WEBMethods 项目。
最佳答案
转到项目菜单并选择清理选项。
如果问题仍然存在,请请求您的管理员帮助您解决问题。他们可能必须检查集成服务器级别的类路径是否设置正确,或者重新启动 IS 也会有所帮助。
关于java - WEBSERVICES中编译Java WebService出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21489147/