Java Service exception

Hi,

I’m getting compilation error in the following code:

public static final void runAdapter( IData pipeline ) throws ServiceException
{
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String adaptorName = IDataUtil.getString( pipelineCursor, “adaptorName” );
Properties propertyObj = (Properties) IDataUtil.get( pipelineCursor, “propertyObj” );
pipelineCursor.destroy();
String successFlag = “TRUE”;
System.out.println(“About to invoke adapter”);
writeLog(“About to invoke adapter”);
try{
System.out.println("props = " + propertyObj);
// RunAdaptor adaptor = new RunAdaptor(adaptorName, propertyObj);
ShutdownRunAdaptor adaptor = new ShutdownRunAdaptor(adaptorName, propertyObj);
System.out.println(“Instance created”);
writeLog("Instance created ");
adaptor.run();

            System.out.println("Adapter running... About to terminate"); 
            writeLog("Adapter running... About to terminate"); 
            adaptor.getController().terminate();
            System.out.println("Adapter terminated");
            writeLog("Adapter terminated");
    }catch (IbafException ibe){
            successFlag = "FALSE"; 
            ibe.printStackTrace();
            writeLog("In 1st Catch Block");
            throw new ServiceException("IbafException " + ibe.getMessage());
    }catch (ClassCastException cce){
            successFlag = "FALSE";
            cce.printStackTrace();
            writeLog("In 2nd Catch Block");
            throw new ServiceException(" ERROR IN CREATING THE LOCALSOURCE;CHECK COMPONENT NAME AND LOGGING " + cce.getMessage());
    }catch(Exception e){
            successFlag = "FALSE";
            e.printStackTrace();
    writeLog("In 3rd Catch Block");
            throw new ServiceException(" ERROR IN SETUP OF THE IBUSADAPTOR " + e.getMessage());
    
    }

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “successFlag”, successFlag );
pipelineCursor_1.destroy();

}

Can any one please compile this code and tell me why i’m getting the following error.

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:26: testing is not abstract and does not override abstract method close() in java.io.Writer

public final class testing

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:140: cannot find symbol

symbol : method writeLog(java.lang.String)

location: class testing

writeLog(“About to invoke adapter”);

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:145: cannot find symbol

symbol : class RunAdaptor

location: class testing

RunAdaptor adaptor = new RunAdaptor(adaptorName, propertyObj);

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:145: cannot find symbol

symbol : class RunAdaptor

location: class testing

RunAdaptor adaptor = new RunAdaptor(adaptorName, propertyObj);

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:148: package org.jpedal.utils does not exist

org.jpedal.utils.LogWriter.writeLog("Instance created ");

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:152: cannot find symbol

symbol : method writeLog(java.lang.String)

location: class testing

writeLog(“Adapter running… About to terminate”);

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:156: cannot find symbol

symbol : method writeLog(java.lang.String)

location: class testing

writeLog(“Adapter terminated”);

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:160: cannot find symbol

symbol : variable ibe

location: class testing

ibe.printStackTrace();

^

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:162: cannot find symbol

symbol : variable ibe

location: class testing

throw new ServiceException("IbafException " + ibe.getMessage());

^

9 errors


Should I use any jar files for this?I am new to web methods and also to java services.Please let me know what needs to be done.

You are missing the method writeLog(String ) this may be a method that you should be having in the shared source for the service. You also require to include the jar file containing the classes “RunAdaptor” and “IbafException” to the classpath. Hope it helps.

You are missing the method writeLog(String ) this may be a method that you should be having in the shared source for the service. You also require to include the jar file containing the classes “RunAdaptor” and “IbafException” to the classpath. It would be helpful if you could tell what version are you running against. Also could you kindly post the entire class so the inports are visable. Hope it helps
~jk

Hi Jerry,

I have added dbadapter.jar and nice-2003-04-24.jar which contains the “RunAdaptor.class” and “LogWriter.class” in C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\jars folder.I have given the testing.java file below:

// -----( IS Java Code Template v1.2
// -----( CREATED: 2008-08-20 18:34:07 IST
// -----( ON-HOST: blrkec36422d.ad.infosys.com
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.
;
import java.text.;
import java.util.
;
import java.lang.*;
// — <> —
public final class testing
{
// —( internal utility methods )—
final static testing _instance = new testing();
static testing _newInstance() { return new testing(); }
static testing _cast(Object o) { return (testing)o; }
// —( server methods )—

public static final void getHomeDir (IData pipeline)
throws ServiceException
{
// — <<IS-START(getHomeDir)>> —
// @subtype unknown
// @sigtype java 3.5
// [i] field:0:required homeDir
String homeDir = System.getProperty(“user.home”);
// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “homeDir”, homeDir );
pipelineCursor_1.destroy();

// — <> —

}

public static final void loadProperties (IData pipeline)
throws ServiceException
{
// — <<IS-START(loadProperties)>> —
// @subtype unknown
// @sigtype java 3.5
// [i] field:0:required strNewFileName
// [i] field:0:required propsFileName
// [i] field:0:required prvKeyPath
// [i] field:0:required batchFileLocation
// [o] field:0:required propertyObj

IDataCursor pipelineCursor_1 = pipeline.getCursor();
String strNewFileName = IDataUtil.getString( pipelineCursor_1, “newFileName” );
String propsFileName = IDataUtil.getString( pipelineCursor_1, “propsFileName” );
// String prvKeyPath = IDataUtil.getString( pipelineCursor_1, “prvKeyPath” );
String batchFileLocation = IDataUtil.getString( pipelineCursor_1, “batchFileLocation” );
pipelineCursor_1.destroy();

  /*
      Retrieves values from configuration file named "MOSCOWdbInternet_Dev.props" from
      directory [server]/packages/DbPrismaPUDomainDBIntIBusMOSCOW/config
  */

      // build the location of the config file
  String configFile = "packages" + File.separator + "DBADAPTER" + File.separator +
                      "config" + File.separator + propsFileName;

  try
      {
              // read in the file stream and convert it to a properties object
      FileInputStream configFileInputStream = new FileInputStream( configFile );

      // properties object is already defined in the Shared code
      properties = new Properties();
      properties.load( configFileInputStream );
      properties.setProperty("adaptor.C1.BatchFileSet.Patterns1",strNewFileName);

// properties.setProperty(“adaptor.C6.PublicKeyAuthentication.PrivateKey.FileName”,prvKeyPath);
properties.setProperty(“adaptor.C1.BatchFileSet.Location”,batchFileLocation);

      boolean propertiesLoaded = true;

  }
      catch ( FileNotFoundException e )
      {
      // print error to standard out and throw an error
              throw new ServiceException ("Error finding property file: "+e.getMessage());
  }
      catch ( IOException e )
      {
      //print error to standard out and throw an error
              throw new ServiceException ("Error reading yourCustomConfig.cnf property file: "+e.getMessage());
     }

IDataCursor pipelineCursor = pipeline.getCursor();
IDataUtil.put(pipelineCursor, “propertyObj”, properties);
pipelineCursor.destroy();
// — <> —

}

public static final void runAdaptor (IData pipeline)
throws ServiceException
{
// — <<IS-START(runAdaptor)>> —
// @subtype unknown
// @sigtype java 3.5
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
String adaptorName = IDataUtil.getString( pipelineCursor, “adaptorName” );
Properties propertyObj = (Properties) IDataUtil.get( pipelineCursor, “propertyObj” );
pipelineCursor.destroy();

      String successFlag  = "TRUE";
      System.out.println("About to invoke adapter");
    writeLog("About to invoke adapter");

      try{ 
      
       System.out.println("props = " + propertyObj);
    RunAdaptor adaptor = new RunAdaptor(adaptorName, propertyObj);
   //   ShutdownRunAdaptor adaptor = new ShutdownRunAdaptor(adaptorName, propertyObj);
      System.out.println("Instance created");
              //writeLog("Instance created "); 
              adaptor.run();
                              
              System.out.println("Adapter running... About to terminate"); 
              //writeLog("Adapter running... About to terminate");

              adaptor.getController().terminate();
              System.out.println("Adapter terminated");
              //writeLog("Adapter terminated");

      }catch (Exception e){
              successFlag = "FALSE";
              e.printStackTrace();
              //writeLog("In 1st Catch Block");
              throw new ServiceException("IbafException " + e.getMessage());

      }catch (ClassCastException cce){
              successFlag = "FALSE";
              cce.printStackTrace();
              //writeLog("In 2nd Catch Block");
              throw new ServiceException(" ERROR IN CREATING THE LOCALSOURCE;CHECK COMPONENT NAME AND LOGGING " + cce.getMessage());
      }catch(Exception e){
              successFlag = "FALSE";
              e.printStackTrace();
      //writeLog("In 3rd Catch Block");
              throw new ServiceException(" ERROR IN SETUP OF THE IBUSADAPTOR " + e.getMessage());
      
      }

// pipeline
IDataCursor pipelineCursor_1 = pipeline.getCursor();
IDataUtil.put( pipelineCursor_1, “successFlag”, successFlag );
pipelineCursor_1.destroy();
// — <> —

}
// — <> —
public static Properties properties=null;

// — <> —
}

But still I’m getting the error

C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:132: cannot find symbol
symbol : method writeLog(java.lang.String)
location: class testing
writeLog(“About to invoke adapter”);
^
C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:137: cannot find symbol
symbol : class RunAdaptor
location: class testing
RunAdaptor adaptor = new RunAdaptor(adaptorName, propertyObj);
^
C:\Program Files\webMethods6\IntegrationServer\packages\DBADAPTER\code\source\testing.java:137: cannot find symbol
symbol : class RunAdaptor
location: class testing
RunAdaptor adaptor = new RunAdaptor(adaptorName, propertyObj);
^
3 errors

Please check it.

Also I have appended these jars in classpath.But still it is showing the same error.

What is the version of webMethods that you are running ? Also could you kindly let me know where is that you got the following jar files.
dbadapter.jar
nice-2003-04-24.jar

Thanks
~jk

Hi I am running 6.5 version of developer.The dbadapter.jar was added since it contains the RunAdaptor.class and nice-2003-04-24.jar contains LogWriter.class.I had dowloaded the second jar.The first one is used in our Tool dbAdapter which is an integration tool.

Hi Kavitha,
I feel that you issue is related to not setting the classpath correctly. Kindly check you classpath using "echo %classpath%. See if you have your jar files in the list which is dispalyed. Another thing to check would be to check if the classes RunAdapter and LogWriter exist in thier respective jar files.
HTH
~jk

Hi Jerry,

The classes are existing in the jars and the echo %classptah% is showing that the jar is set.

C:\PROGRA~1\webMethods6\jvm\win142\bin;C:\PROGRA~1\webMethods6\jvm\win142\jre\bin;C:\PROGRA~1\webMethods6\IntegrationServer\packages\Sample1\code\jars\dbadapter.jar

Would it be possible for you to send the 2 jar files over so I could take a closer look.
~jk

Hi jerry,

please give me ur mail id.since the jar files exceeds the size limit supported by dis forum,i am not able to send them.

Regards,
Kavitha

please send me ur e-id so that i can send the jar files.Here i cant post since the size exceeds the limit.