Question

I am trying to compile and test a Java Services in WEBMethods. I had to reload the method and now it tells me there is an error some where in my code. I am not sure where the error is over even how to find the error because there is actually no red rectangle on the right side and there is no error highlighted ont he screen.

Question: What is the causing the error in my WEBMethods Services?

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 {
    }
}

Error:

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

Web Screen Shot of What I see in WEBMethods. This is only the top part of the screen.

enter image description here

enter image description here

Two of the post below mentioned something about not posting the class correctly. If the class is not named correctly or if there is some other place where the code is hidden I am not certain. This is my first WEBMethods project.

Was it helpful?

Solution

Goto Project Menu and Select Clean Option.

If issues still persist, ask your admin to help you out. They may have to check if the classpath is set correctly at the Integration server level, or may be an IS re-start would also help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top