Engine is not initializing correctly in Java servlet

Hi,

I’m trying to initialize Clover engine in my simple Java servlet. The following code is failing:

EngineInitializer.initEngine("D:/CloverETL/cloverETL.rel-2-8-1/cloverETL/plugins", null, null);

Tomcat window shows the following debug info:

INFO  [http-8080-1] - Loading default properties from: defaultProperties
DEBUG [http-8080-1] - Plugin org.jetel.bulkloader loaded.
        id - org.jetel.bulkloader
        version - 2.8.1
        provider-name -
                component { className = org.jetel.component.OracleDataWriter; ty
pe = ORACLE_DATA_WRITER;  }
                component { className = org.jetel.component.DB2DataWriter; type
= DB2_DATA_WRITER;  }
                component { className = org.jetel.component.InformixDataWriter;
type = INFORMIX_DATA_WRITER;  }
                component { className = org.jetel.component.MsSqlDataWriter; typ
e = MS_SQL_DATA_WRITER;  }
                component { className = org.jetel.component.MysqlDataWriter; typ
e = MYSQL_DATA_WRITER;  }
                component { className = org.jetel.component.PostgreSqlDataWriter
; type = POSTGRESQL_DATA_WRITER;  }

DEBUG [http-8080-1] - Plugin org.jetel.component loaded.
        id - org.jetel.component
        version - 2.8.1
        provider-name - null
                component { className = org.jetel.component.DataReader; type = D
ATA_READER;  }
                component { className = org.jetel.component.DataWriter; type = D
ATA_WRITER;  }
                component { className = org.jetel.component.DelimitedDataReader;
 type = DELIMITED_DATA_READER;  }
                component { className = org.jetel.component.DelimitedDataWriter;
 type = DELIMITED_DATA_WRITER;  }
                component { className = org.jetel.component.SimpleCopy; type = S
IMPLE_COPY;  }
                component { className = org.jetel.component.Concatenate; type =
CONCATENATE;  }
                component { className = org.jetel.component.SimpleGather; type =
 SIMPLE_GATHER;  }
                component { className = org.jetel.component.Reformat; type = REF
ORMAT;  }
                component { className = org.jetel.component.DBInputTable; type =
 DB_INPUT_TABLE;  }
                component { className = org.jetel.component.Sort; type = SORT;
}
                component { className = org.jetel.component.DBOutputTable; type
= DB_OUTPUT_TABLE;  }
                component { className = org.jetel.component.FixLenDataWriter; ty
pe = FIXLEN_DATA_WRITER;  }
                component { className = org.jetel.component.Dedup; type = DEDUP;
  }
                component { className = org.jetel.component.FixLenDataReader; ty
pe = FIXLEN_DATA_READER;  }
                component { className = org.jetel.component.Merge; type = MERGE;
  }
                component { className = org.jetel.component.MergeJoin; type = ME
RGE_JOIN;  }
                component { className = org.jetel.component.MergeJoin; type = EX
T_MERGE_JOIN;  }
                component { className = org.jetel.component.MergeJoin; type = SO
RTED_JOIN;  }
                component { className = org.jetel.component.Trash; type = TRASH;
  }
                component { className = org.jetel.component.DBExecute; type = DB
_EXECUTE;  }
                component { className = org.jetel.component.HashJoin; type = HAS
H_JOIN;  }
                component { className = org.jetel.component.HashJoin; type = EXT
_HASH_JOIN;  }
                component { className = org.jetel.component.CheckForeignKey; typ
e = CHECK_FOREIGN_KEY;  }
                component { className = org.jetel.component.DBFDataReader; type
= DBF_DATA_READER;  }
                component { className = org.jetel.component.ExtFilter; type = EX
T_FILTER;  }
                component { className = org.jetel.component.ExtSort; type = EXT_
SORT;  }
                component { className = org.jetel.component.SortWithinGroups; ty
pe = SORT_WITHIN_GROUPS;  }
                component { className = org.jetel.component.Partition; type = PA
RTITION;  }
                component { className = org.jetel.component.DataIntersection; ty
pe = DATA_INTERSECTION;  }
                component { className = org.jetel.component.Aggregate; type = AG
GREGATE;  }
                component { className = org.jetel.component.SystemExecute; type
= SYS_EXECUTE;  }
                component { className = org.jetel.component.RunGraph; type = RUN
_GRAPH;  }
                component { className = org.jetel.component.KeyGenerator; type =
 KEY_GEN;  }
                component { className = org.jetel.component.AproxMergeJoin; type
 = APROX_MERGE_JOIN;  }
                component { className = org.jetel.component.DBJoin; type = DBJOI
N;  }
                component { className = org.jetel.component.XLSReader; type = XL
S_READER;  }
                component { className = org.jetel.component.XLSWriter; type = XL
S_WRITER;  }
                component { className = org.jetel.component.CloverDataWriter; ty
pe = CLOVER_WRITER;  }
                component { className = org.jetel.component.CloverDataReader; ty
pe = CLOVER_READER;  }
                component { className = org.jetel.component.StructureWriter; typ
e = STRUCTURE_WRITER;  }
                component { className = org.jetel.component.Normalizer; type = N
ORMALIZER;  }
                component { className = org.jetel.component.Denormalizer; type =
 DENORMALIZER;  }
                component { className = org.jetel.component.Rollup; type = ROLLU
P;  }
                component { className = org.jetel.component.JmsReader; type = JM
S_READER;  }
                component { className = org.jetel.component.JmsWriter; type = JM
S_WRITER;  }
                component { className = org.jetel.component.LookupJoin; type = L
OOKUP_JOIN;  }
                component { className = org.jetel.component.LookupTableReaderWri
ter; type = LOOKUP_TABLE_READER_WRITER;  }
                component { className = org.jetel.component.DataGenerator; type
= DATA_GENERATOR;  }
                component { className = org.jetel.component.SequenceChecker; typ
e = SEQUENCE_CHECKER;  }
                component { className = org.jetel.component.TextTableWriter; typ
e = TEXT_TABLE_WRITER;  }
                component { className = org.jetel.component.XmlXPathReader; type
 = XML_XPATH_READER;  }
                component { className = org.jetel.component.XMLExtract; type = X
ML_EXTRACT;  }
                component { className = org.jetel.component.Pacemaker; type = PA
CEMAKER;  }
                component { className = org.jetel.component.SpeedLimiter; type =
 SPEED_LIMITER;  }
                component { className = org.jetel.component.JavaExecute; type =
JAVA_EXECUTE;  }
                component { className = org.jetel.component.XmlWriter; type = XM
L_WRITER;  }
                component { className = org.jetel.component.XSLDataTransformer;
type = XSL_TRANSFORMER;  }
                component { className = org.jetel.component.HttpConnector; type
= HTTP_CONNECTOR;  }

DEBUG [http-8080-1] - Plugin org.jetel.connection loaded.
        id - org.jetel.connection
        version - 2.8.1
        provider-name - null
                connection { className = org.jetel.connection.jdbc.DBConnection;
 type = JDBC;  }
                connection { className = org.jetel.connection.jms.JmsConnection;
 type = JMS;  }

DEBUG [http-8080-1] - Plugin org.jetel.ctlfunction loaded.
        id - org.jetel.ctlfunction
        version - 2.5.2
        provider-name - null
                ctlfunction { libraryName = math; className = org.jetel.ctl.exte
nsions.MathLib;  }
                ctlfunction { libraryName = date; className = org.jetel.ctl.exte
nsions.DateLib;  }
                ctlfunction { libraryName = string; className = org.jetel.ctl.ex
tensions.StringLib;  }
                ctlfunction { libraryName = convert; className = org.jetel.ctl.e
xtensions.ConvertLib;  }
                ctlfunction { libraryName = container; className = org.jetel.ctl
.extensions.ContainerLib;  }

DEBUG [http-8080-1] - Plugin org.jetel.engine loaded.
        id - org.jetel.engine
        version - 2.8.1
        provider-name - null
                dictionaryType { className = org.jetel.graph.dictionary.StringDi
ctionaryType; type = string;  }
                dictionaryType { className = org.jetel.graph.dictionary.ObjectDi
ctionaryType; type = object;  }
                dictionaryType { className = org.jetel.graph.dictionary.Readable
ChannelDictionaryType; type = readable.channel;  }
                dictionaryType { className = org.jetel.graph.dictionary.Writable
ChannelDictionaryType; type = writable.channel;  }
                tlCompiler { className = org.jetel.ctl.TLCompiler; type = simple
.compiler;  }

DEBUG [http-8080-1] - Plugin org.jetel.jdbc loaded.
        id - org.jetel.jdbc
        version - 2.8.1
        provider-name - null
                jdbcSpecific { name = DB2; class = org.jetel.connection.jdbc.spe
cific.impl.DB2Specific; database = DB2;  }
                jdbcSpecific { name = Informix; class = org.jetel.connection.jdb
c.specific.impl.InformixSpecific; database = INFORMIX;  }
                jdbcSpecific { name = MS SQL Server 2008; class = org.jetel.conn
ection.jdbc.specific.impl.MSSQLSpecific; database = MSSQL;  }
                jdbcSpecific { name = MS SQL Server 2000-2005; class = org.jetel
.connection.jdbc.specific.impl.MSSQLSpecific2005; database = MSSQL2005;  }
                jdbcSpecific { name = MySQL; class = org.jetel.connection.jdbc.s
pecific.impl.MySQLSpecific; database = MYSQL;  }
                jdbcSpecific { name = Oracle; class = org.jetel.connection.jdbc.
specific.impl.OracleSpecific; database = ORACLE;  }
                jdbcSpecific { name = PostgreSQL; class = org.jetel.connection.j
dbc.specific.impl.PostgreSpecific; database = POSTGRE;  }
                jdbcSpecific { name = Sybase; class = org.jetel.connection.jdbc.
specific.impl.SybaseSpecific; database = SYBASE;  }
                jdbcSpecific { name = SQLite; class = org.jetel.connection.jdbc.
specific.impl.SQLiteSpecific; database = SQLITE;  }
                jdbcDriver { driverLibrary = lib/mysql/mysql-connector-java-5.1.
7-bin.jar; jdbcSpecific = MYSQL; name = MySQL; dbDriver = org.gjt.mm.mysql.Drive
r; jdbc.zeroDateTimeBehavior = convertToNull; urlHint = jdbc:mysql://hostname:33
06/database; database = MYSQL;  }
                jdbcDriver { driverLibrary = lib/postgre/postgresql-8.3-603.jdbc
3.jar; jdbcSpecific = POSTGRE; name = PostgreSQL; dbDriver = org.postgresql.Driv
er; urlHint = jdbc:postgresql://hostname/database; database = POSTGRE;  }
                jdbcDriver { driverLibrary = lib/jtds/jtds-1.2.4.jar; jdbcSpecif
ic = MSSQL; name = Microsoft SQL Server; dbDriver = net.sourceforge.jtds.jdbc.Dr
iver; urlHint = jdbc:jtds:sqlserver://hostname:1433/database; database = MSSQL;
 }
                jdbcDriver { driverLibrary = lib/jtds/jtds-1.2.4.jar; jdbcSpecif
ic = SYBASE; name = Sybase; dbDriver = net.sourceforge.jtds.jdbc.Driver; urlHint
 = jdbc:jtds:sybase://hostname:7100/database; database = SYBASE;  }

DEBUG [http-8080-1] - Plugin org.jetel.lookup loaded.
        id - org.jetel.lookup
        version - 2.8.1
        provider-name - null
                lookup { className = org.jetel.lookup.SimpleLookupTable; type =
simpleLookup;  }
                lookup { className = org.jetel.lookup.DBLookupTable; type = dbLo
okup;  }
                lookup { className = org.jetel.lookup.RangeLookupTable; type = r
angeLookup;  }

DEBUG [http-8080-1] - Plugin org.jetel.sequence loaded.
        id - org.jetel.sequence
        version - 2.8.1
        provider-name - null
                sequence { className = org.jetel.sequence.SimpleSequence; type =
 SIMPLE_SEQUENCE;  }
                sequence { className = org.jetel.sequence.PrimitiveSequence; typ
e = PRIMITIVE_SEQUENCE;  }

DEBUG [http-8080-1] - Plugin org.jetel.thirdparty loaded.
        id - org.jetel.thirdparty
        version - 2.8.1
        provider-name - null
                component { className = org.jetel.component.Filter; type = FILTE
R;  }
                component { className = com.linagora.component.LdapReader; type
= LDAP_READER;  }
                component { className = com.linagora.component.LdapWriter; type
= LDAP_WRITER;  }

Looks like processing stops at this point. No other info displayed in server console.
IE browser shows 500 error:

Tomcat 500 error.gif

Tomcat log shows exception:

javax.servlet.ServletException: Servlet execution threw an exception
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)

What can be the reason for this error? I tried to run the same .grf with the same engine files via command window using the following command

java -cp "cloveretl.engine.jar;commons-logging.jar;log4j-1.2.12.jar;javolution.jar;trans" org.jetel.main.runGraph -checkconfig -plugins "D:\CloverETL\cloverETL.rel-2-8-1\cloverETL\plugins" "D:/CloverETL_workspace/Clover_Eval/graph/Test2.grf"

and it finishes successfully.

Appreciate your help.

Hi,

the exception “javax.servlet.ServletException: Servlet execution threw an exception” doesn’t say anything about root exception.
There must be root (nested) exception stack trace somewhere in tomcat logs.
Unless you have empty catch block like this somewhere …
try {

} catch (Exception e) {
throw new ServletException();
}

Can you upload whole servlet code?
Are the clover engine libraries in your web-app classpath?

Regards,
Martin

Hi,

Please see servlet code:

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.jetel.graph.*;
import org.jetel.graph.runtime.*;
import edu.umd.cs.findbugs.annotations.*;


public class runMyGrf extends HttpServlet 
{

    public void service(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException
    {

	try
	{
	// engine initialization - should be called only once
		EngineInitializer.initEngine("D:/CloverETL/cloverETL.rel-2-8-1/cloverETL/plugins", null, null);
	}
	catch(Exception e5)
	{
		System.out.println("ERROR!!!!="+e5.toString());
	}

      String graphPath = "D:/CloverETL_workspace/Clover_Eval/graph/Test2.grf";

	try
	{
		InputStream is = new BufferedInputStream(new FileInputStream(graphPath));
		TransformationGraph graph = null;


		// engine customization
		GraphRuntimeContext runtimeContext = new GraphRuntimeContext();

		// graph loading
		graph = TransformationGraphXMLReaderWriter.loadGraph(is,runtimeContext.getAdditionalProperties());

		// engine initialization
		EngineInitializer.initGraph(graph, runtimeContext);

		// graph running
		IThreadManager threadManager = new SimpleThreadManager();
		WatchDog watchDog = new WatchDog(graph, runtimeContext);
		threadManager.executeWatchDog(watchDog);

	}
	catch(Exception e3)
	{
		throw new ServletException();
	}

      response.setContentType("text/html");
      PrintWriter out = response.getWriter();

      out.println("<html>");
      out.println("<head>");

      out.println("<title>Test</title>");
      out.println("</head>");
      out.println("<body bgcolor=\"white\">");

      out.println("TEST");

      out.println("</body>");
      out.println("</html>");

    }

}

Tomcat shows this info in logs:

Nov 2, 2009 5:02:57 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet runMyGrf threw exception
javax.servlet.ServletException: Servlet execution threw an exception
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:849)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:454)
	at java.lang.Thread.run(Thread.java:619)

I also checked classpath - it contains “D:\CloverETL\cloverETL.rel-2-8-1\cloverETL\lib;” - link to the engine’s jar files.