Expand my Community achievements bar.

SOLVED

Getting strange errors in executeScript activity

Avatar

Level 4

In Workbench for AEM Forms 6.4, in an executeScript activity, I have been getting some odd errors with my code. It is telling me that there are missing methods and classes that should be there. This code works fine outside of the executeScript activity (in Eclipse running the same java version). I even checked in the jar of the Microsoft sql and can see the class file in the server class path/modules folder. I have found other ways around these errors, but I would prefer to use the "missing" classes. I am not sure what I am doing wrong with this. Does anyone have any suggestions?

[org.jboss.as.ejb3.invocation] (default-threads - 29) WFLYEJB0034: EJB Invocation failed on component EjbTransactionCMTAdapter for method public abstract java.lang.Object com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterLocal.doRequired(com.adobe.idp.dsc.transaction.TransactionDefinition,com.adobe.idp.dsc.transaction.TransactionCallback) throws com.adobe.idp.dsc.DSCException: javax.ejb.EJBTransactionRolledbackException: Sourced file: inline evaluation of: ``import java.io.File; import java.io.IOException; import java.nio.file.Files; imp . . . '' : Error in method invocation: Static method readAttributes( sun.nio.fs.WindowsPath, java.lang.Class ) not found in class'java.nio.file.Files' : at Line: 274 : in file: inline evaluation of: ``import java.io.File; import java.io.IOException; import java.nio.file.Files; imp . . . '' : Files .readAttributes ( f .toPath ( ) , BasicFileAttributes .class )

[org.jboss.as.ejb3.invocation] (default-threads - 33) WFLYEJB0034: EJB Invocation failed on component EjbTransactionCMTAdapter for method public abstract java.lang.Object com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionCMTAdapterLocal.doRequired(com.adobe.idp.dsc.transaction.TransactionDefinition,com.adobe.idp.dsc.transaction.TransactionCallback) throws com.adobe.idp.dsc.DSCException: javax.ejb.EJBTransactionRolledbackException: Sourced file: inline evaluation of: ``import javax.naming.InitialContext;  import javax.sql.DataSource;  import java.s . . . '' : Class: com.microsoft.sqlserver.jdbc.SQLServerException not found in namespace : at Line: 93 : in file: inline evaluation of: ``import javax.naming.InitialContext;  import javax.sql.DataSource;  import java.s . . . '' : com .microsoft .sqlserver .jdbc .SQLServerException

1 Accepted Solution

Avatar

Correct answer by
Level 4

The script generates some values to pass along to a stored procedure, and collects the output for use later on in the process. We are not using the OOTB JDBC stored procedure activity because the multiple possible values for sp inputs would have made the process too large to debug (the process recorder can only record so many activities). The script has been running with no issues in our ES4 production environment for almost a decade, so I don't think the script is the issue.

I expect an exception (and get one) if one of my sp parameters is incorrect. I generate the error above when the exception is caught. If I change the code to import com.microsoft.sqlserver.jdbc.SQLServerException; and only catch SQLServerException, I still get the same error.

Here is the script, with the non-stored procedure logic stripped out.

import javax.naming.InitialContext;

import javax.sql.DataSource;

import java.sql.CallableStatement;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.*;

PreparedStatement stmt = null;

Connection conn = null;

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("java:/FIN_DS");

//logic to set up sp input parameters goes here

conn = ds.getConnection();

try

{

stmt = conn.prepareCall("{call TransacTable_Insert(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");

//set the sp input/output parameters here

stmt.execute();

//collect output here

}

catch(com.microsoft.sqlserver.jdbc.SQLServerException e)

{

patExecContext.setProcessDataStringValue("/process_data/@exceptionText", e,getMessage());

return;

}

//write results to process variables

View solution in original post

2 Replies

Avatar

Employee Advisor

Are you querying using javax.sql.DataSource ? You may use SQL related operations available on OOTB JDBC category. It appears to be issue with the script. Make sure you import the required classes. Share your sample script here if possible

Thanks,

Wasil

Avatar

Correct answer by
Level 4

The script generates some values to pass along to a stored procedure, and collects the output for use later on in the process. We are not using the OOTB JDBC stored procedure activity because the multiple possible values for sp inputs would have made the process too large to debug (the process recorder can only record so many activities). The script has been running with no issues in our ES4 production environment for almost a decade, so I don't think the script is the issue.

I expect an exception (and get one) if one of my sp parameters is incorrect. I generate the error above when the exception is caught. If I change the code to import com.microsoft.sqlserver.jdbc.SQLServerException; and only catch SQLServerException, I still get the same error.

Here is the script, with the non-stored procedure logic stripped out.

import javax.naming.InitialContext;

import javax.sql.DataSource;

import java.sql.CallableStatement;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.*;

PreparedStatement stmt = null;

Connection conn = null;

InitialContext ctx = new InitialContext();

DataSource ds = (DataSource) ctx.lookup("java:/FIN_DS");

//logic to set up sp input parameters goes here

conn = ds.getConnection();

try

{

stmt = conn.prepareCall("{call TransacTable_Insert(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");

//set the sp input/output parameters here

stmt.execute();

//collect output here

}

catch(com.microsoft.sqlserver.jdbc.SQLServerException e)

{

patExecContext.setProcessDataStringValue("/process_data/@exceptionText", e,getMessage());

return;

}

//write results to process variables