eswari Malluru

Greenhorn
+ Follow
since Jul 07, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by eswari Malluru


Hi Tim,

Thank you very much for you reply.

log4j.xml file is there in /user/apache-tomcat-8.0.36/webapps/TestApplication/WEB-INF/classes/ directory. Initially this file size is 4222 bytes and also have 777 permissions. When tomcat is bounced this file is remaining as it is but when any action is performed in the web application to generate log, before creating the log file this log4j.xml file is becoming empty with size 0 bytes.

The code highlighted with red color in the below code snippet is making the log4j.xml file empty

[color=darkblue][size=11]

             String configurationPath= contextPath+"\\WEB-INF\\classes\\log4j.xml";
             DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
             DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
             Document doc = docBuilder.parse(new File(configurationPath));

             logger.info("doc : "+doc);  // Here is printing as[#document: null]
             // Get the root element
             Node appender = doc.getFirstChild();
             logger.info("appender : "+appender); // this is getting the first child in the log4j.xml
             
            Node debugFile = doc.getElementsByTagName("param").item(0);
            NamedNodeMap attr = debugFile.getAttributes();
            Node nodeAttr = attr.getNamedItem("value");
            logger.info("node Attr before changing to new file name : "+nodeAttr);
           
            nodeAttr.setNodeValue(logPath+"ShipConsole.log");
            logger.info("debugFile  nodeAttr.setNodeValue done from ChangeLogMode == " + nodeAttr);
         
            Node level = doc.getElementsByTagName("level").item(0);
            NamedNodeMap levelAttribt = level.getAttributes();
            Node nodeLevelAttr1 = levelAttribt.getNamedItem("value");
            nodeLevelAttr1.setNodeValue(loggerMode);
            logger.info("level  nodeLevelAttr1.setNodeValue done from ChangeLogMode == " + nodeLevelAttr1);

                          // write the content into xml file
             TransformerFactory transformerFactory = TransformerFactory.newInstance();
             Transformer transformer = transformerFactory.newTransformer();
             
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
             transformer.setOutputProperty(OutputKeys.METHOD, "xml");
             transformer.setOutputProperty(OutputKeys.INDENT, "yes");
             transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");


[color=red]
             DOMSource source = new DOMSource(doc);
             FileOutputStream outputStream = new FileOutputStream(new File(configurationPath));
             StreamResult result = new StreamResult(outputStream);
             logger.info("source : "+source); // This is printing some object
             logger.info("result : "+result);   // This is printing some object
             transformer.transform(source, result);
             
             File log4jFile = new File(configurationPath);
             logger.info("log4jFile : "+log4jFile);     // this is printing  /user/apache-tomcat-8.0.36/webapps/TestApplication/WEB-INF/classes/log4j.xml
             logger.info("log4jFile path : "+log4jFile.getPath());  // this is also printing  /user/apache-tomcat-8.0.36/webapps/TestApplication/WEB-INF/classes/log4j.xml
             logger.info("log4jFile canWrite : "+log4jFile.canWrite());  // this is printing true

             logger.info("log4jFile length : "+log4jFile.length());   // this is printing 0
             logger.info("log4jFile.exists() : "+log4jFile.exists());  // this is printing
                            if (log4jFile.exists()) {
                             logger.info("Inside if before configure");
                                 DOMConfigurator.configure(configurationPath);   // At this line trowing exceptions as below
                                logger.info("Initialized Log files with new modifications == "+configurationPath);
                            } else {
                                  BasicConfigurator.configure();
                            }

             
            Logger rootLogger = Logger.getRootLogger();    
            if(loggerMode != null && !loggerMode.equals("")){
             rootLogger.setLevel(Level.toLevel(loggerMode));
              }


          Exceptions :

log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
log4j:WARN Fatal parsing error -1 and column -1
log4j:WARN Premature end of file.
log4j:ERROR Could not parse file [/user/aasc/apache-tomcat-8.0.36/webapps/TestApplication/WEB-INF/classes/log4j.xml].
        org.xml.sax.SAXParseException; Premature end of file.
       at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
       at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
       at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
       at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:749)
       at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:866)
       at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:755)
       at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:891)
       at com.aasc.model.ChangeLogMode.<init>(ChangeLogMode.java:209)
       at com.aasc.view.AascProfileOptionsAction.execute(AascProfileOptionsAction.java:2561)
       at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
       at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
       at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)

           
[/color]




Not able to find out why this log4j.xml file is getting empty.

Did anyone face this type of issue. If so please let me know why this issue is coming and how to resolve this issue

Thanks,
Eshwari

[/size][/color]
3 years ago
Hi All,

I have a strange issue with log4j. When calling the  org.apache.log4j.xml.DOMConfigurator.configure(configurationPath); log4j.xml in class path is getting empty and no log file is generated when tomcat is bounced and any action is performed to generate log.

Actually I am trying to update the log level and logging file path in log4j.xml file dynamically using javax.xml.parsers.DocumentBuilderFactory from my web application while tomcat is up and running. After updating the log4j.xml calling org.apache.log4j.xml.DOMConfigurator.configure(Path/log4j.xml); to incorporate log4j.xml file changes to logger with out restarting the tomcat. This is working fine in my local windows 7 system and our developmet linux instances where the configuration is Struts 1.3, [color=red]Tomcat-8.0.36, Java - 8 update 74
and linux-2.6.18-238.el5xen.

Now I am getting issue with logging in new instance having same configurations mentioned above except linux version here it is : Linux-2.6.32-642.el6.x86_64

Catalina.out is showing the below errors

13 Jul 2017 05:33:10  INFO ChangeLogMode - XML modification Done and new file has placed in the path
13 Jul 2017 05:33:10  INFO ChangeLogMode - Now Logger mode will switch to = INFO
13 Jul 2017 05:33:10  INFO ChangeLogMode -  log4j.xml file exists rebooting the log4j.xml to tomcat server == /user/apache-tomcat-8.0.36/webappsTestApplication/WEB-INF/classes/log4j.xml
log4j: System property is :null
log4j: Standard DocumentBuilderFactory search succeded.
log4j: DocumentBuilderFactory is: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
log4j:WARN Fatal parsing error -1 and column -1
log4j:WARN Premature end of file.
log4j:ERROR Could not parse file [/user/apache-tomcat-8.0.36/webapps/TestApplication/WEB-INF/classes/log4j.xml].
org.xml.sax.SAXParseException; Premature end of file.
   at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
   at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:205)
   at org.apache.log4j.xml.DOMConfigurator$1.parse(DOMConfigurator.java:749)
   at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:866)
   at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:755)
   at org.apache.log4j.xml.DOMConfigurator.configure(DOMConfigurator.java:891)
   at com.aasc.model.ChangeLogMode.<init>(ChangeLogMode.java:178)
   at com.aasc.util.Log4JInitServlet.init(Log4JInitServlet.java:49)
   at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1238)
   at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1151)
   at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1038)
   at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027)
   at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5337)
   at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147)
   at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:725)
   at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:701)
   at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
   at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:940)
   at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1816)
   at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
   at java.lang.Thread.run(Thread.java:745)



my log4j.xml file is


<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">;
<log4j:configuration debug="true" xmlns:log4j="http://jakarta.apache.org/log4j/"; threshold="null" reset="false">

<appender name="logFIle" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="/user/apache-tomcat-8.0.36/logs/"/>
<param name="Append" value="true"/>
<param name="ImmediateFlush" value="true"/>
<param name="MaxFileSize" value="10GB"/>
<!-- <param name="threshold" value="debug"/> -->
<param name="maxBackupIndex" value="1"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
</layout>
</appender>

<appender name="consoleAppender" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{dd MMM yyyy HH:mm:ss} %5p %c{1} - %m%n"/>
</layout>
</appender>
   
<root>
<level value="INFO"/>
<appender-ref ref="logFIle"/>
<!-- <appender-ref ref="infoFile" />
<appender-ref ref="warnFile" />
<appender-ref ref="errFile" />
<appender-ref ref="traceFile" /> -->
<appender-ref ref="consoleAppender"/>
</root>

</log4j:configuration>



And ChangeLogMode.java to edit.xml file is as below


javax.xml.parsers.DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
             javax.xml.parsers.DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
             Document doc = docBuilder.parse(new File(configurationPath));
             // Get the root element
             Node appender = doc.getFirstChild();
Node debugFile = doc.getElementsByTagName("param").item(0);
            NamedNodeMap attr = debugFile.getAttributes();
            Node nodeAttr = attr.getNamedItem("value");
            nodeAttr.setNodeValue(logPath+"ShipConsole.log");
            logger.info("debugFile  nodeAttr.setNodeValue done from ChangeLogMode == " + nodeAttr);
Node level = doc.getElementsByTagName("level").item(0);
            NamedNodeMap levelAttribt = level.getAttributes();
            Node nodeLevelAttr1 = levelAttribt.getNamedItem("value");
            nodeLevelAttr1.setNodeValue(loggerMode);
            logger.info("level  nodeLevelAttr1.setNodeValue done from ChangeLogMode == " + nodeLevelAttr1);
             // write the content into xml file
            javax.xml.transform.TransformerFactory transformerFactory = TransformerFactory.newInstance();
            javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
            javax.xml.transform.dom.DOMSource source = new DOMSource(doc);
             FileOutputStream outputStream = new FileOutputStream(new File(configurationPath));
             javax.xml.transform.stream.StreamResult result = new StreamResult(outputStream);
             transformer.transform(source, result);
             logger.info("XML modification Done and new file has placed in the path");
             File log4jFile = new File(configurationPath);
                            if (log4jFile.exists()) {
                                logger.info("log4j.xml file exists rebooting the log4j.xml to tomcat server == "+configurationPath);      // Till this line it is perfect
                                org.apache.log4j.xml.DOMConfigurator.configure(configurationPath);                                             // server is throwing the above errors mention in catalina.out when this line is executed
                                logger.info("Initialized Log files with new modifications == "+configurationPath);
                            }


I am getting this issue only in client instance, it is working fine with same configurations and same deployment in other instances. Could you please suggest me whether the Linux instance has any dependency on using DOMConfigurator.configure

Could someone please help me to resolve this issue and generate the log file using logj4.xml.

Thanks in Advance.
Eshwari

[/color]
3 years ago
Hi,

I have requirement to change the color of a table row as below

A table is having multiple lines, each having a button/image. When the user clicks on this button/image on a particular line, a pop up is opened. After saving the data successfully, the row from which the pop up is opened has to change its color. Here table, rows and cells are already having id's and style classes.

For this I used various ways as below

1) window.opener.document.getElementById('rowId'+lineNumber).style.backgroundColor="#00FF00";
2) window.opener.document.getElementById('rowId'+lineNumber).className="innerrowcss";
3) var tbl = window.opener.document.getElementById('linesTableId');
tbl.rows[lineNumber].style.backgroundColor="#00FF00";
or
tbl.rows[lineNumber].style.className="innerrowcss";

None of the above options helped me changing the color of the required row.

Please help me in achieving this.

Thanks,
Eshwari
Hi,

I have a requirement to access serial ports from Applets. For this using jssc.jar library and try to get the list of available ports. When I am doing this getting the below exception

Exception in thread "Thread-23" java.lang.ExceptionInInitializerError
at jssc.SerialPortList.<clinit>(SerialPortList.java:43)
at SerialIO.fetchSerialPorts(SerialIO.java:204)
at Applet.startJavaScriptListener(Applet.java:174)
at Applet.mav$startJavaScriptListener(Applet.java:36)
at Applet$1.run(Applet.java:105)
at java.security.AccessController.doPrivileged(Native Method)
at printer.Applet.run(Applet.java:100)
at java.lang.Thread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "user.home" "read")
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at sun.awt.AWTSecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at jssc.SerialNativeInterface.<clinit>(SerialNativeInterface.java:85)
... 8 more

How should I modify the java.policy to get out of this exception. Do I need to use anything else other than this jar.

I am using java 1.6.0_27 and Windows 7

Please help me in resolving this issue.

Thanks,
Eshwari
5 years ago
Hi All,

I am executing python scripts from java by passing parameters to convert a text file to excel file. Also installed the additional packages required for this i.e Win32 package and included this path in the java classpath while executing, but getting error like

import pythoncom
ImportError: No module named pythoncom

Can anyone please tell how to resolve this error.

Thanks,
Eswari
9 years ago
Hi All,

I new to python and want to call python script from java class. For this using python interpreter and able to do so. But want to call a particular python method from java class.

Python script using is as show below:


#processing.py

import os
import datetime

class Processing(object):
"""
Processing class.
"""
def __init__(self, gui):
self.gui = gui
self.numbers = None
self.vendor = None
self.raNumber = None
self.comPort = None
self.logFile = None
self.thread = None
self.results = None
self.testSuite = None
self.retryEvent = None

def run(self,logFile,comPort,numbers,vendor,raNumber,testSuite,SerialErrorEvent,ProcessingErrorEvent):
"""
"""
self.logFile = logFile
self.comPort = comPort
self.serialNumbers = serialNumbers
self.vendor = vendor
self.raNumber = raNumber
self.SerialErrorEvent = SerialErrorEvent
self.ProcessingErrorEvent = ProcessingErrorEvent

try:
................
...........


and my java class is as below:

PythonInterpreter.initialize(System.getProperties(), System.getProperties(), new String[0]);
PythonInterpreter interp = new PythonInterpreter();

System.out.println();
interp.execfile("E:\\processing.py");


Now want to call the method run from java class. Please tell me how to do this with a sample code


Thanks,
Eshwari
9 years ago
Hi All,

Can anyone please tell why I am getting this error. Its urgent to resolve this AttributeError. When will errors like this come.

Thanks,
Eshwari
9 years ago
Yes, please move this to Python forum

Thank You,
Eshwari
9 years ago
Hi Rob Spoor,

Thank you for reading my post.

Here is the python script I am using.......





and the Java code is..





Here I am getting error at this line in the python script

(BuilderErrorEvent,EVT_BUILDER_ERROR) = wx.lib.newevent.NewEvent()

where wx is the local folder


Thanks,
Eshwari

[RS]added code tags[/RS]
9 years ago
Hi All,

I am a java developer and new to python. I have a code in python which as to be used in my project, so tried to call these python scripts from a java class using Python Interpreter and getting the AttibuteError as below:
AttributeError: 'javapackage' object has no attribute 'newevent'

Please help me how to resolve this error.

Thanks,
Eshwari
9 years ago

Hi Raj Sikka,

I am also trying for similar example. Please give an example if you downloaded and implemented this. I failed in downloading this book.

Thanks,
Eshwari

9 years ago