cancel
Showing results for 
Search instead for 
Did you mean: 

Hibernate, Log4J and SAP Logging issues in SAP Web AS

Former Member
0 Kudos

Hi all, I've being watching and using information found in this forum regarding integration of thrird parties frameworks in SAP Web AS, but I must admit I'm having a hard time trying to find a explanation to the kind of problems we have in our development team regarding Hibernate and Log4J working inside Web AS.

Versions

:

1. SAP web AS 6.40 SP 18
2. NDWS 2.0.16
3. Oracle 8.1.7.1
4. Hibernate 3.1.3
5. Log4J 1.2.8
6. Apache Commons 1.0.0


Context

:

We have two business scenarios, which present similar problems, the scenarios are
something like the situation depicted in the graph:


Outbound Message Inbound Message
Database -> (JDBC Adapter) -> XI -> (XI Adapter) -> JPR à Java Proxy


In this case we are trying to substitute two batch programs (PL/SQL) using Asynchronous messaging with XI.

The general logic of both Java Proxies is as follows:

Step 1: Initializes any counters and auxiliary variables needed.
Step 2: Obtain references through JNDI lookups of the resources required.
Step 3: Invoke a homemade component (general-purpose) to perform all business logic specific to each business scenario.


The idea of using a general-purpose component for the business logic is to reuse code when both business scenarios must be executed whether XI is available or not, the only difference under both execution mode (XI or Contingency using a Java Class with a main method) is how resources are acquired.

XI

Look for all resources from the SAP Web AS using JNDI.


Contingency using a Java Class with a main method


Look for all resources from local configuration files.

We tested the java program reading all configuration information from local files, including a configuration file to write to a log file using SAP Logging API and successfully reading it using SAP standalone log viewer. We test all Hibernate initialization and connections and business logic with the expected results.


When we tried to port the same experience to SAP Web AS, but we encountered several obstacles in our way.

Problem #1

Our first issue is with SAP Logging API, while running as a standalone program we can obtain correctly the name of the file generated (which is later send to a group of users for monitoring purposes) using the following code :

Collection logs    = logger.getLogs();
FileLog    fileLog = null;
File       log     = null;
String     logFile = null;
				
Iterator iterator = logs.iterator();
				
while(iterator.hasNext())
{
 fileLog = (FileLog)iterator.next();	
 				 
 log = new File(fileLog.getPath());
				 
 logFile= log.getName();
				 
 if( logger.beDebug())
 {
  logger.debugT("Log File Name reported to the Client: "+logFile);	
 }
				 
 break;
}
 

Let's say the file name created is named

bdidms-be-0002B33DC300006400002A2B00000F680004215B6E2DB6EE.log

using this a propertis file to configure SAP Logging

but when we executed the same code inside the Java Proxy the file written to the disk (let's assume the name) is

bdidms-be-0002B33DC3000065000026A600000F680004215B3789C594.log

but the one reported in the code above shown is

bdidms-be-0002B33DC300006D0000306B00000F68000421994D547148.log

using for the ear the config file log-configuration.xml

then they are completely different file names with different GUIDs so our group of users will never receive the correct file, we already opened an issue with SAP regarding this odd behaviour but to not available so far. Has someone else encountered this kind of problems?

Problem #2

Regarding Hibernate and Log4J (used by the first) it's a complete mistery, the situation is as follow:

1.- We created a Server Library to deploy all hibernate related files to the server in order to avoid duplication of jar.

2.- We did the same with log4j.jar ( deployed as a server library) .

Our first test code was using this code to initializes Log4J and then procede to config Hibernate

PropertyConfigurator.configure("bDIDMSBDIDMS02/log4j.properties");  (1)
			
Logger log2 = Logger.getLogger("hibernate");

logger.debugT("Creating Hibernate Config Object");
org.hibernate.cfg.Configuraton cfgBdBDI = new org.hibernate.cfg.Configuraton(); // (2)
logger.debugT("Hibernate Config Object created");
				
cfgBdBDI.configure("com/procedatos/modelo/bdi/bdi.eev.dev.cfg.xml");
HibernateSessionFactory bdBDI = cfgBdBDI.buildSessionFactory();

Where

(1) We are reading the log4j.properties file from the jar of the Java Proxy in order to configure the logging framework

(2) SAP Logging stopped when we reach this line and generated the following exception in the monitoring tool:

Delivery of the message to the application using connection JPR failed, due to: com.sap.aii.af.ra.ms.api.DeliveryException: Error invoking method miIaJpAuditorBtx of proxy bean $Proxy289: null: com.sap.aii.proxy.xiruntime.core.XmlInboundException: Error invoking method miIaJpAuditorBtx of proxy bean $Proxy289: null.

A Null (Pointer Exception?) is generated by Log4J because is not configured and when Hibernate try to init the configuration Object which reviewing the source code of Hibernate has the following declaration


 *
 * @author Gavin King
 * @see org.hibernate.SessionFactory
 */
public class Configuration implements Serializable {

	private static Log log = LogFactory.getLog( Configuration.class ); 

Does anyone can share their expertise in how to configure correctly Hibernate to make it run, we searched several forums PDF both from SAP an non-SAP users, but to not available. I tought of using a SAR file (as I did it with Hibernate9 to my surprise SAP doesn't support creating a JMX Service using simple XML, How can I start Hibernate as a Service , because this would be the prefer way so there will be one initialization and could the Hibernate Session factory could be reuse for future developments.

Apologyze for the lengthly post, but working with SAp support has being kind of slow and not usable.

Thx,

Pedro Taborda

ptaborda@procedatos.com.ve (Biz)

ptaborda@cantv.net (Alt)

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

1.- While deploying hibernate files in netweaver 2004s there is a file named tssapinfo in the library folder which holds references to each jar file that is inside the sda, if you add , remove o change a setting make sure you can later read that file, there seems a bug where this file gets corrupted and the deployment fails inside the application server

2.- Use a properties file sotre somewhere in the file structure in the application server (fixed location) read from there and configure log4j.

3.- SAP Logging API if it is done using the API and not the log-configuration.xml behaves erratically when you use a file pattern of xxxx-g% , when you request using the Java API to obtain the name of the log filename, a workaroun I use to solve the problem was

is = new FileInputStream( new File(CARPETA_SAP_WEBAS+"
logging.jp.dc.properties") );

prop.load(is);

is.close();

archivoLog = prop.getProperty("log[Appl].pattern");

sb.append(archivoLog);

sb.append("-");

sb.append(feLog.getTime());

sb.append(FILE_LOG_EXT);

archivoLog = sb.toString();

prop.setProperty("log[Appl].pattern",archivoLog);

which allowed me to generated a stable file pattern name and algo obtain the ocrrect name of the log filename.