0

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 で表示される内容の Web スクリーン ショット。これは画面の上部のみです。

ここに画像の説明を入力

ここに画像の説明を入力

以下の投稿のうち 2 つは、クラスを正しく投稿していないことについて言及しています。クラスの名前が正しくない場合、またはコードが隠されている他の場所がある場合、私にはわかりません。これは私の最初の WEBMethods プロジェクトです。

4

1 に答える 1