我正在尝试在WEBMethods中编译和测试Java服务。我不得不重新加载方法,现在它告诉我在我的代码中有一些错误。我不确定错误在哪里,甚至如何找到错误,因为右侧实际上没有红色矩形,并且屏幕上没有突出显示错误。
问题:我的WEBMethods服务中导致错误的原因是什么?
类别:
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中看到的网页截图。这只是屏幕的顶部。
下面的两篇文章提到了一些关于没有正确发布课程的内容。如果类没有正确命名,或者存在隐藏代码的其他地方,我不确定。这是我的第一个WEBMethods项目。
答案 0 :(得分:1)
转到项目菜单,然后选择清洁选项。
如果问题仍然存在,请让管理员帮助您。他们可能必须检查是否在Integration服务器级别正确设置了类路径,或者可能是IS重新启动也会有所帮助。