Controlling Apache Service on Windows platform through Java
Hi,
I am running a web application with apache.If sometime it goes down usually by restarting Apache,problem get solved.Now i want to automate it,where my appliaction will check page faults,CPU Usuage and then based on certain conditions it will stop and then Start Apache.
Now i dont know how to do it.i am just wondering whether RMI can help me.?please help me if anybody has done it before or has an idea.
Thanks in advance.
Akash
I think tomcat has some ant task defined for the same. May be you can try that
Similar Messages
-
How can I develop co-broswing on Windows platform with java language?
How can I develop co-broswing on Windows platform with java language?
The function will be realized
Now I want to develop a co-broswing system with java language on Windows platform.That is to say I will develop
a application run on client to track the present browser.Wheh the URL address of your present if changed(for example
when you click a link or submit a form),the application will capture the new URL address and send it to the other
client that make co-browsing connect with you.The browser on the other client side will catch the new URL and refesh
the page to show the page.
The question I fall across and want to ask you
(1)How to watch system process with java on the Windows platform?Because I want to get the process information of
the present broswer,and then get the URL address of the present broswer.
(2)Develop an application to watch the URL address of the present broswer continuance,If the URL address is changed,
then send the new URL address to the client on the other side,let his broswer to show the new page using the new URL.Paulc, A proxy server is not the right thing.
What our man here is looking for is a solution for two
users to kind of surf the net "in tandem" - when one
user navigates to a different web page, so does the
other user,
These are typically used in call center applications
where the advisor guides a caller through , say
filling in an insurance form or pointing him to the
right product specification pages.
Xing, why are you using Java for this ? You need
something that has better windows integration. If you
look on MSDN.microsoft.com and search for "explorer
bar" you will find solutions to the questions that you
raised.
There are also commercial products on the market that
already do this kind of stuff. there is one from
www.genesyslabs.com which is considered to be the best
of breed.
It is difficult or almost impossible to do this in
Java for a commercial application.
If you are developing this as an academic exercise,
give it a try. Post your email address here, and I
will contact and help you out if you like.my e-mail is below ,I want to contact you and need all of your help.
[email protected] -
How to find IP allocated to windows OS through java code
Hi,
I want to find no of IPs allocated to windows OS through java code. How i can do this.Please give me idea.
any help will be appricated.
Thanks in advance
Ravi AdhaYou can use the InetAddress class in the java.net package to find all the IP addresses of your computer.
-
Need to track windows processes through java code.
Need to track windows processes through java code.
Eg: I want to find out whether an exe file (wrun.exe) is running or stopped.
Can I do it through java. If so can any one please tell me how to do it. That will be a great help.
Thanks,
RameshThere are 2 options for things like this:
1) Use Runtime.exec() to execute some command or application and parse the input from it.
2) Write some native code and use JNI to call it. -
Running windows command through java code
Hello
i want to execute jar.exe through java code , i have written following piece of code , but it isn't working
ProcessBuilder processBuilder = new ProcessBuilder(new String[]{"cmd.exe","/c","%java_home%\\bin\\jar.exe"});
Process process = processBuilder.start();
BufferedReader inputReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
String line = inputReader.readLine();
while(line != null){
System.out.println(line);
line = inputReader.readLine();
does anybody knows why
Regards
Edited by: Mayur Mitkari on Mar 5, 2013 10:19 PM
Edited by: Mayur Mitkari on Mar 5, 2013 10:20 PM
Edited by: Mayur Mitkari on Mar 5, 2013 10:20 PMsorry for that , but the
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec(new String[]{"cmd.exe","/c","jar"});
proc.waitFor();
int i = proc.exitValue();
this code was different from first one
and in case of Process if runtime .exec is succesful it is wainting for long time , in this case i want if the runtime.exec is succesful something should be returned
Regards -
Windows scheduler through java
Hi,
I need an imediate help as this is my event of my project,
where i m facing problem is i have an windows scheduler which i want t run through my java programs.
plz if anyone can help me..
regards
AshishHi,
no i have an windows scheduler, i want to run rather control that scheduler through my java program, i mean on any click event sort of thing.
plz if anyone can help me..
Ashish -
Deploying a VB dll using some web service and accessing it through java
I'm new to Web Services Based Programming. I would like to know whether this is possible and if so has anyone tried it. I want to create a vb dll that contains the remote methods that the client will access from a java program. After going thru a lot of articles, I'm still unsure on how to do this. I found one method was to Create a VB program/dll, deploy it in a web service and create the java program that accesses by another web service.
I'm doing this as part of my lab syllabus. The thing is My lab exercises do not state anything about the technologies that I can use to do this.
This is all that is stated there:-
Creation Of DLL Using VB And Deploy it in Java
I just cant get any ideas other than deploying both the parts as web services. If anyone has Better ideas for this, I would really appreciate it.
I dont know anything about CORBA for languages other than Java and I'm already using the servlets and EJB's in my normal life. I'm also learning the ORB based programming in java. Therefore your help will probably help me learn something new then what I know.Sorry I wasn't too specific in my last question.
This is my java class calling the native method print
//HeyWorld.java
class HeyWorld {
private native void print();
public static void main(String[] args) {
new HeyWorld().print();
static {
System.loadLibrary("HeyWorld");
In this case, my C method for calling a C++ method: HelloWorld.cpp
#include "jni.h"
#include "stdio.h"
#include "stdafx.h"
#Include "HeyWorld.h" //this is where i get my function prototype
#include "Test.h" //this is the C++ header where the print method and the Test class is
JNIEXPORT void JNICALL
Java_HeyWorld_print(JNIEnv *env, jobject obj)
CTest a; //CTest is the print class I created
a.print();
//This is the header for Test.h
class CTest: public CWinApp
public:
CTest(); //constructor
void print(); //our method
//And this is the implementation of the class Test.cpp
void CTest::print()
printf("Hey World!\n");
return ;
I could compile the Test.cpp, HeyWorld.cpp successfully. However when I tried to compile HeyWorld.cpp using
cl -I<path of jdk include> -I<path of jdk include win32> -LD HeyWorld.cpp -FeHeyWorld.dll,
the VC++ 6.0 compiler gave me this error:
HeyWorld.obj:error LNK2001: unresolved external symbol "public:_thiscall CTest::CTest(void)"
HeyWorld.obj:error LNK2001: unresolved external symbol "public:_thiscall CTest::print(void)"
Thanks for the help. -
MS Analysis Services (OLAP) application development through java
AOA
To what extent java supports Microsoft Analysis Services application development. is it a right tool for that or not.
RegardsUNX - XMLA
UNV - OLEDB
those are the choices. -
How to run windows program through java applications.
pls help me!!!!! code RED!~
C:\Documents and Settings\student\Desktop\Running.java:12: cannot resolve symbol
symbol : variable JMStudio
location: class Running
String path="C:/Program Files/MF2.1.1/bin"+JMStudio;
^
1 error
this error is generated
any idea on how to solve it? -
DB Control 11g service in Win does not start....
Hi ,
When i try to start the DB Control 11g service in Windows XP , it fails displaying :
The OracleDBConsoleoracle11g service terminated with service-specific error 2 (0x2).Is there something i can do except for trying to drop the EM repository and recreate it manually....?????
Thanks....
SimHi,
The problem is that there is a problem in the connection via the OracleNet.... However , i can connect to the db using:
1)oracle tools of 11g (sql developer,sql plus)
2)oracle tools of 10g (DevSuite10g , sqlplus 10g)
Here is a portion of this trace file....
2007-12-21 12:08:09,093 [OmsServiceDriver thread] WARN jdbc.ConnectionCache _getConnection.353 - Got a fatal exeption when getting a connection; Error code = 17002; Cleaning up cache and retrying
2007-12-21 12:08:10,093 [OmsServiceDriver thread] ERROR conn.ConnectionService verifyRepositoryEx.818 - Invalid Connection Pool. ERROR = Εξαίρεση ΕΕ: The Network Adapter could not establish the connection
2007-12-21 12:08:43,093 [OmsServiceDriver thread] WARN jdbc.ConnectionCache _getConnection.352 - Εξαίρεση ΕΕ: The Network Adapter could not establish the connection
java.sql.SQLException: Εξαίρεση ΕΕ: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:390)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:519)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:167)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:816)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:325)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:235)
at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPhysicalConnection(OracleConnectionPoolDataSource.java:157)
at oracle.jdbc.pool.OracleConnectionPoolDataSource.getPooledConnection(OracleConnectionPoolDataSource.java:94)
at oracle.jdbc.pool.OracleImplicitConnectionCache.makeCacheConnection(OracleImplicitConnectionCache.java:1702)
at oracle.jdbc.pool.OracleImplicitConnectionCache.getCacheConnection(OracleImplicitConnectionCache.java:575)
at oracle.jdbc.pool.OracleImplicitConnectionCache.getConnection(OracleImplicitConnectionCache.java:435)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:432)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:397)
at oracle.sysman.util.jdbc.ConnectionCache._getConnection(ConnectionCache.java:336)
at oracle.sysman.util.jdbc.ConnectionCache._getConnection(ConnectionCache.java:322)
at oracle.sysman.util.jdbc.ConnectionCache.getUnwrappedConnection(ConnectionCache.java:575)
at oracle.sysman.emSDK.svc.conn.FGAConnectionCache.getFGAConnection(FGAConnectionCache.java:207)
at oracle.sysman.emSDK.svc.conn.ConnectionService.getPrivateConnection(ConnectionService.java:1063)
at oracle.sysman.emSDK.svc.conn.ConnectionService.getRepositoryVersionAndMode(ConnectionService.java:698)
at oracle.sysman.emSDK.svc.conn.ConnectionService.verifyRepositoryEx(ConnectionService.java:778)
at oracle.sysman.emSDK.svc.conn.ConnectionService.verifyRepository(ConnectionService.java:835)
at oracle.sysman.emSDK.svc.conn.ConnectionService.blockUntilValid(ConnectionService.java:860)
at oracle.sysman.emdrep.failover.OMSHeartbeatRecorder.getMyId(OMSHeartbeatRecorder.java:185)
at oracle.sysman.emdrep.failover.OMSHeartbeatRecorder.preTask(OMSHeartbeatRecorder.java:412)
at oracle.sysman.emdrep.omsservice.OmsServiceDriver.run(OmsServiceDriver.java:146)
2007-12-21 12:08:43,093 [OmsServiceDriver thread] WARN jdbc.ConnectionCache _getConnection.353 - Got a fatal exeption when getting a connection; Error code = 17002; Cleaning up cache and retrying
2007-12-21 12:08:44,093 [OmsServiceDriver thread] ERROR conn.ConnectionService verifyRepositoryEx.818 - Invalid Connection Pool. ERROR = Εξαίρεση ΕΕ: The Network Adapter could not establish the connectionThanks...
Sim -
Getting windows services through java
Hi,
I just want to get the status of windows services( SERVICE_NAME: DWMRCS)
and also i have to stop and start the services through java code is there any help?
thanksUse "sc" util with Runtime.exec().
-
SAP NW 7.0 Java trial version on windows platform
Hi,
I am searching for a SAP NW 7.0 Java trial version on windows platform in the "Downloads" sessions. But I couldn't find it there. Can anybody help me finding this trial version?
Thanks,
KrisHi Kris
Except the trial version, if you have a Sxxxxxxx user in Service Market Place(http://service.sap.com), I would like to recommend
you install the netweaver developer workplace version, which can be installed on your laptop with windows XP, which should
be better than the trial version.
Thanks
Thunder -
Zip created through java.util.zip but problem in windows XP compress folder
Hi friends,
I am a software developer ,working on java/j2ee.currently i am working in a document management software related to logistics.Here i am facing a problem at the time of open the zip file through windows XP's in built software called "Folder compress".It's creared through java.util.zip.zipoutputstream.but at time of open through xp compress folder software ,it's showing error that "you can't open this file , this file are protected for your computer security" , but when i trying to open it through winzip or winrar, it's not giving any problem.My also specefing the code snippet below :-
ZipOutputStream zip = null;
FileOutputStream fileWriter = null;
try
fileWriter = new FileOutputStream(destZipFile);
zip = new ZipOutputStream(fileWriter);
//required for XP compress
zip.setMethod(ZipOutputStream.DEFLATED);
zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
}catch (Exception ex){
ex.printStackTrace();
System.exit(0);
addFolderToZip("", srcFolder, zip);
try
zip.flush();
zip.close();
zip=null;
fileWriter.close();
fileWriter = null;
}catch (Exception ex)
//ex.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
}I desperately looking for a help regarding this issue , if any body have any solution the please send at this forum.
Thanks,
Chiranjitthis file working file for winzip or winrar there is no problem.i am also sending the whole code of that java file that can help you better.
Program Name: EdocRetrieveServiceSLBean.java
Description: EdocRetrieveService CMP Bean Class
Classes: EdocRetrieveServiceSLBean
Package: net.mlog.edoc.ejb.entity
Modification History
<CR No> <Date> <Modified By> <Comments>
Version 1.0 2005.12.01 Sutapa Ray Create
/** The sequence of methods to be called.
===============================================================================================================================
1. mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId)
2. mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId)
a) Start DIR --
private String DoFolder(String folderNname)
b) Create the folder
private String CreateFolder(String FolderName,String newFolderPath)
c) Zip the folder
private void zipFolder(String srcFolder, String destZipFile)
d) Add folders to zip file
private void addToZip(String path, String srcFile, ZipOutputStream zip)
e) Add the srcFolder to the zip stream.
private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
f) Delete Directory from server
public boolean deleteDir(File dir) {
3. mpsDocumentView(String argUserId,Integer[] argSfxFileId)
4. mlogOriginDocumentView(int argDocumentId,String argUserId)
5. findDocTypeForDocId(Integer argDocId) throws RemoteException;
package net.mlog.edoc.ejb.session;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
import javax.ejb.ObjectNotFoundException;
import javax.ejb.FinderException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.naming.Context;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
//import lib for all entity beans
import net.mlog.edoc.ejb.entity.IDocumentCMP;
import net.mlog.edoc.ejb.entity.IDocumentCMPHome;
import net.mlog.edoc.ejb.entity.IDocumentTypeCMP;
import net.mlog.edoc.ejb.entity.IDocumentTypeCMPHome;
import net.mlog.edoc.ejb.entity.IDocumentAuditCMP;
import net.mlog.edoc.ejb.entity.IDocumentAuditCMPHome;
//import lib for reader class of properties file
import net.mlog.edoc.ejb.session.PropertiesFileReader;
//import lib for user Define File class
import net.mlog.edoc.ejb.Session.EFile;
//import lib for SFXWebClient
import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSLHome;
import net.mlog.edoc.webservice.sfxWeb.ISFXWebClientSL;
import java.sql.Date;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import java.util.zip.Deflater;
import java.util.Vector;
import java.util.Iterator;
import java.util.Collection;
import java.util.StringTokenizer;
import java.util.Enumeration;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.InputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
//import lib for NGP Mail
import javax.jms.Queue;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueConnection;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.JMSException;
import weblogic.jms.extensions.WLQueueSession;
import weblogic.jms.extensions.XMLMessage;
//import javax.mail.*;
//import javax.mail.internet.*;
//import lib for USI
import com.msl.security.USIException;
import com.msl.security.USIServerAPI;
import com.msl.security.UserPolicyData;
import net.msl.util.logging.MLogger;
public class EdocRetrieveServiceSLBean implements SessionBean {
private static final boolean VERBOSE = true;
private SessionContext ctx;
public void ejbActivate() {
public void ejbRemove() {
public void ejbPassivate() {
public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
public void ejbCreate () throws CreateException {
private static final MLogger logger;
static
logger = MLogger.getLogger(net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.class.getName(), "net/mlog/edoc/ejb/session/eDocRetrieveServiceMessagesXML");
//*********************KEEPING AUDITS OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
* <b>
* Used for Auditing the user action.
* </b>
* This function is called from various functions of eDocController
* <p>
* @param argActionDetails Gives the details of Action in document audit.
* @param argDocumentId gives the Document Id in Document Audit.
* @param argActionId Action Id in Document Audit.
* @param argActionByUserId User Id of the Docment Audit action.
* @return Returns a boolean value. 1 for success, 0 for Failure.
public boolean mlogOriginDocumentAudit(String argActionDetails,int argDocumentId,int argActionId,String argActionByUserId) throws RemoteException
//NGP/JDK Logging
boolean flag=false;
try{
//getting context of the server
InitialContext documentAuditCMPInitialContext=getInitialContext();
Object objDocumentAuditCMPRef=null;
try{
objDocumentAuditCMPRef=documentAuditCMPInitialContext.lookup("DocumentAuditCMPBeanJNDI");
catch(Exception e)
//NGP/JDK Logging if JNDI Not found
//logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentAuditCMPBeanJNDI"});
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentAuditCMPBeanJNDI not found");
//find the maximum audit id in the Document_Audit table
//Home interface reference of DocumentAuditCMP EJB
//IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)PortableRemoteObject.narrow(objDocumentAuditCMPRef,IDocumentAuditCMPHome.class);
IDocumentAuditCMPHome iDocumentAuditCMPHomeRef=(IDocumentAuditCMPHome)objDocumentAuditCMPRef;
//Remote interface reference of DocumentAuditCMP EJB
IDocumentAuditCMP iDocumentAuditCMPCreateRef=iDocumentAuditCMPHomeRef.create(new Timestamp(System.currentTimeMillis()),argActionDetails,argActionByUserId,new Integer(argActionId),new Integer(argDocumentId));
//set flag to true if Document is audited
flag=true;
}//end of try
catch(Exception expt)
//logger.finer(expt);
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.CreateException","Exception in creating Document Audit record");
return flag;
//*********************BATCH DOWNLOAD OF DOCUMENTS BY MLOG ORIGIN PEOPLE*******************************
* <b>
* Used for Validating the documents.
* </b>
* This function is called from Struts
* <p>
* @param TREEDATA Treeset obtained after search.
* @param SessionIDVal gives the Session Value Id.
* @return Returns a boolean value. 1 for success, 0 for Failure.
public byte[] mlogDestinationBatchDownload(Vector TREEDATA,String SessionIDVal,String argUserId) throws RemoteException
//NGP/JDK Logging
/*FileHandler handler = null;
Logger logger=null;
try
PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
handler = new FileHandler("eDoc.log",0,1, true);
logger = Logger.getLogger("ErrorMsg");
logger.addHandler(handler);
logger.setLevel(Level.ALL);
}catch(Exception excp)
NGP/JDK Logging warning
logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
//Remote interface reference of SFXWebClientSL
ISFXWebClientSL iSFXWebClientSLRef=null;
//Home interface reference of SFXWebClientSL
ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
Vector filePath=new Vector();
byte[] fileContent=null;
String eDocRoot="";
String eDocPathMain="";
String eDocPath="";
File tempRootFileforDelete = null;
if (TREEDATA.capacity() != 0 )
String BLNODirPath="";
String PONODirPath="";
String SONODirPath="";
// added for doc type level--2005.11.27--samar
String docTypeDirPath="";
String filepath="";
try
PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
filepath=propertiesFileReaderRef.getProperties("/edoc.properties","TEMP_FILE_DIR");
logger.finer("File Path:" +filepath);
}catch(Exception excp)
excp.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.IOException","TEMP_FILE_DIR property (edoc.properties) not found");
eDocRoot=CreateFolder("eDocTemp",filepath+File.separator);
// added for top level--2005.12.02--samar
//eDocRoot=CreateFolder("eDocTemp",System.getProperty("user.home")+File.separator);
//eDocPath=CreateFolder(SessionIDVal,eDocRoot+File.separator);
Enumeration TREEDATAEn = TREEDATA.elements(); //Setting The Tree Folder
String BLNO="";
String PONO="";
String SONO="";
String DNO ="";
while(TREEDATAEn.hasMoreElements())
StringTokenizer st = new StringTokenizer((TREEDATAEn.nextElement()).toString(),"_");
while (st.hasMoreTokens()) // Extract All the Fields Of Every Vector Element
BLNO = st.nextToken(); // CSBWNO
PONO = st.nextToken(); // PONO
SONO = st.nextToken(); // SONO
DNO = st.nextToken(); // DNO
eDocPathMain=CreateFolder(SessionIDVal,eDocRoot+File.separator);
eDocPath=CreateFolder("eDoc",eDocPathMain+File.separator);
BLNODirPath = CreateFolder(BLNO,eDocPath+File.separator);
PONODirPath = CreateFolder(PONO,BLNODirPath+File.separator);
SONODirPath = CreateFolder(SONO,PONODirPath+File.separator);
// added for doc type level--2005.11.27--samar
docTypeDirPath=CreateFolder(findDocTypeForDocId(new Integer(DNO)),SONODirPath+File.separator);
File tempRootFile=new File(eDocRoot);
tempRootFile.canWrite();
filePath.add(tempRootFile.getParent());
tempRootFileforDelete = tempRootFile;
//File tempeDocPathMainFile=new File(eDocPathMain);
//filePath.add(tempeDocPathMainFile.getParent());
//2005-12-01::code change for top level directory deletion
//File tempFile=new File(eDocPath);//BLNODirPath);
//filePath.add(tempFile.getParent());
filePath.add(eDocPathMain);
filePath.add(eDocPath);
filePath.add(BLNODirPath);
filePath.add(PONODirPath);
filePath.add(SONODirPath);
// added for doc type level--2005.11.27--samar
filePath.add(docTypeDirPath);
/* Access The Data from DataBase Temp Storage with Document Id And Store In This SO Folder */
/*Long Raw*/
try
InitialContext initialContext=new InitialContext();
int sfxid=0;
/*DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
OraclePooledConnection pc = new OraclePooledConnection("jdbc:oracle:thin:hr/hr@essoraclesvr:1521:essorcl","edoc","edoc");
Connection con=new DBCon().Connect();//pc.getConnection();
PreparedStatement pstm=con.prepareStatement("select SFX_FILE_ID from DOCUMENT where DOCUMENT_ID=?");
//getting context of the server
InitialContext documentCMPInitialContext=getInitialContext();
Object objDocumentCMPRef=null;
try{
objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
catch(Exception e)
//logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
//Home interface reference of DocumentCMP EJB
//IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
IDocumentCMP documentCMPRef=null;
//Remote interface reference of DocumentCMP EJB
try{
documentCMPRef=iDocumentCMPHomeRef.findByPrimaryKey(new Integer(DNO));
catch(Exception e)
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ObjectNotFound","Document Id not found");
/*pstm.setInt(1,Integer.parseInt(DNO));
ResultSet rs1=pstm.executeQuery();
if(rs1.next()){
sfxid=rs1.getInt(1);
sfxid=documentCMPRef.getSfxFileId().intValue();
logger.finer("sfxid==="+sfxid);
String strFile=documentCMPRef.getDocumentName().toString();
//SFX lookup
//InitialContext initialContext=new InitialContext();
Object sfxWebClient=null;
try{
sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
catch(Exception e)
//NGP/JDK logging if JNDI not found
//logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();//SFXWebClient reference creation
if(iSFXWebClientSLRef!=null)
//logger.finer("ffffffff---");
int arrSFXFileId[]=new int[1];
arrSFXFileId[0]=sfxid;
Object objEFile[]=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
if(objEFile.length>0)
byte b[]=(byte[])objEFile[1];
String f=strFile.substring(strFile.lastIndexOf(File.separator)+1,strFile.length());
// changed(instead of SONODirPath now docTypeDirPath) for doc type level--2005.11.27--samar
FileOutputStream fout=new FileOutputStream(docTypeDirPath+File.separator + f);
//logger.finer("SONODirPath+File.separator + f---"+SONODirPath+File.separator + f);
filePath.add(docTypeDirPath+File.separator + f);
int j;
for(j=0;j<b.length;j++)
fout.write(b[j]);
fout.close();
//for auditing the document
//logger.finer("Document download audited");
boolean flagAudit=mlogOriginDocumentAudit("Document has been downloaded",Integer.parseInt(DNO),5,argUserId);
//logger.finer("Audit complete"+flagAudit);
if(logger.isFinerLoggable()) {
logger.finer("Audit complete"+flagAudit);
//Delete after finish
tempRootFile.delete();
}catch(Exception e)
//e.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Folder creation processing");
/* End Long Raw */
}// end of while hasMoreTokens
}// end of while hasMoreElements
}else{ }
/* Zip */
try
zipFolder(eDocPath+File.separator,eDocPath+".zip");
}catch(Exception excp)
////logger.finer(excp.toString());
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip processing");
// send the byte array for the file
String fileName=eDocPath+".zip";
try{
File file=new File(fileName);
InputStream is = new FileInputStream(file);
// Get the size of the file
long length = file.length();
// You cannot create an array using a long type.It needs to be an int type.
// Before converting to an int type,check to ensure that file is not larger than Integer.MAX_VALUE.
//Kept for future requirement if any
if (length > Integer.MAX_VALUE) {
// File is too large
// Create the byte array to hold the data
fileContent = new byte[(int)length];
// Read in the bytes
int offset = 0;
int numRead = 0;
while (offset < fileContent.length
&& (numRead=is.read(fileContent, offset, fileContent.length-offset)) >= 0) {
offset += numRead;
// Ensure all the bytes have been read in
if (offset < fileContent.length) {
throw new IOException("Could not completely read file "+file.getName());
// Close the input stream and return bytes
is.close();
}catch(Exception e){
deleteDir(tempRootFileforDelete);
//trying for deleting folder and zip file
File file=new File(fileName);
if(file.exists())
file.delete();
//logger.finer("File Deleted successfully");
if(file.exists()){
//logger.finer("File Not Deleted ");
/* File FileToDelete = new File(eDocPath+".zip");
boolean DelStatus1 = deleteDir(FileToDelete);
//logger.finer("Deletion 1:"+DelStatus1 );
File FolderToDelete = new File(eDocPath);
boolean DelStatus2 = deleteDir(FolderToDelete);
//logger.finer("Deletion 2:"+DelStatus2);
for(int index=filePath.size()-1;index>=0;index--)
File delFile=new File(filePath.elementAt(index).toString());
//logger.finer(delFile.getAbsolutePath());
if(delFile.exists())
//logger.finer("Before delete---123");
//logger.finer("File Deleted========>"+delFile.delete());
//logger.finer("After delete---123");
//logger.finer(delFile.getAbsolutePath()+"-----------"+delFile.exists());
return fileContent;
/* ***************************Start DIR *********************/
private String DoFolder(String folderNname)
File f;
f = new File(folderNname);
f.mkdir(); // Create The Folder
//f.deleteOnExit(); //R n D to Delete The zip folders only */
return(folderNname+File.separator);
//to create the folder
private String CreateFolder(String FolderName,String newFolderPath)
String NewDir ="";
NewDir=newFolderPath + FolderName;
newFolderPath=DoFolder(NewDir);
return(NewDir);
//To zip the folder
private void zipFolder(String srcFolder, String destZipFile)
ZipOutputStream zip = null;
FileOutputStream fileWriter = null;
try
fileWriter = new FileOutputStream(destZipFile);
zip = new ZipOutputStream(fileWriter);
//required for XP compress
zip.setMethod(ZipOutputStream.DEFLATED);
zip.setLevel(Deflater.DEFAULT_COMPRESSION); //use default level
}catch (Exception ex){
ex.printStackTrace();
System.exit(0);
addFolderToZip("", srcFolder, zip);
try
zip.flush();
zip.close();
zip=null;
fileWriter.close();
fileWriter = null;
}catch (Exception ex)
//ex.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Zip folder processing");
// File f2= new File(destZipFile);
* Write the content of srcFile in a new ZipEntry, named path+srcFile,of the zip stream
* The result is that the srcFile will be in the path folder in the generated archive.
* @param path String, the relative path with the root archive.
* @param srcFile String, the absolute path of the file to add
* @param zip ZipOutputStram, the stream to use to write the given file.
//the folders are added to zip file
private void addToZip(String path, String srcFile, ZipOutputStream zip)
File folder = new File(srcFile);
//folder.deleteOnExit();
if (folder.isDirectory()) {
addFolderToZip(path, srcFile, zip);
else {
//Transfer bytes from in to out
byte[] buf = new byte[1024];
int len;
FileInputStream in = null;
try {
in = new FileInputStream(srcFile);
// void putNextEntry(ZipEntry e) Begins writing a new ZIP file entry
// and positions the stream to the start of the entry data.
zip.putNextEntry(new ZipEntry(path +File.separator+ folder.getName()));
while ((len = in.read(buf)) > 0)
zip.write(buf, 0, len);
}catch (Exception ex){
ex.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
}finally{
try
//2005-12-01::file pointer close
in.close();
}catch(Exception e){
e.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Adding to Zip Folder");
folder.delete(); //we addedd for DELETE
* add the srcFolder to the zip stream.
* @param path String, the relatif path with the root archive.
* @param srcFile String, the absolute path of the file to add
* @param zip ZipOutputStram, the stream to use to write the given file.
private void addFolderToZip(String path, String srcFolder, ZipOutputStream zip)
File folder = new File(srcFolder);
folder.canWrite();
//folder.deleteOnExit();
String fileListe[] = folder.list();
try
int i = 0;
while (true)
addToZip(path+File.separator+ folder.getName(), srcFolder+File.separator+fileListe, zip);
i++;
}catch (Exception ex)
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in Naming after adding to Zip Folder");
/* $$$$$$$$$$$$$$$$$ End Zipping $$$$$$$$$$$$$$$ */
/****************Start Of Deleting Directory from server***********/
public boolean deleteDir(File dir) {
// to see if this directory is actually a symbolic link to a directory,
// we want to get its canonical path
//- that is, we follow the link to the file it's actually linked to
File candir;
try {
candir = dir.getCanonicalFile();
} catch (IOException e) {
return false;
// a symbolic link has a different canonical path than its actual path,
// unless it's a link to itself
if (!candir.equals(dir.getAbsoluteFile())) {
//this file is a symbolic link, and there's no reason for us to follow it,
//because then we might be deleting something outside of the directory we were told to delete
return false;
// now we go through all of the files and subdirectories in the directory and delete them one by one
File[] files = candir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
File file = files[i];
//file read only set false
//in case this directory is actually a symbolic link, or it's empty,
//we want to try to delete the link before we try anything
boolean deleted = file.delete();
if (!deleted) {
// deleting the file failed, so maybe it's a non-empty directory
if (file.isDirectory()) deleteDir(file);
// otherwise, there's nothing else we can do
// now that we tried to clear the directory out, we can try to delete it again
return dir.delete();
/************End Of Deleting Directory *********************/
private InitialContext getInitialContext() throws NamingException {
try {
return new InitialContext();
} catch (NamingException ne) {
//logger.finer("Please make sure that the server is running.");
throw ne;
//*****************************WEB SERVICE FILE RETRIEVE IMPLEMENTATION FOR MPS PEOPLE*************************************************
* <b>
* Used for Retrieval of a document.
* </b>
* This function is called from retrieveDocument function of MPStoEdocWebServiceSLBean.
* <p>
* @param argUserId User Id of the user who wants to retrieve the document
* @param argSfxFileId[] Sfx File Id which gives the reference number of the document(s) in the SFX database.
* @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
public Object[] mpsDocumentView(String argUserId,Integer[] argSfxFileId) throws RemoteException
//NGP/JDK logging
logger.finer("mpsDocumentView called--");
try{
argUserId=argUserId.toUpperCase();
catch(Exception e)
e.printStackTrace();
logger.finer("mpsDocumentView argSfxFileId[0]--"+argSfxFileId[0]);
Object[] searchResult=null;
/*FileHandler handler = null;
Logger logger=null;
int finalIndex=0;
try
//PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
//String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
//handler = new FileHandler("eDoc.log",0,1, true);
//logger = Logger.getLogger("ErrorMsg");
//logger.addHandler(handler);
//logger.setLevel(Level.ALL);
}catch(Exception excp)
//NGP/JDK Logging warning
//logger.log(Level.WARNING, "{0} : Unable to find Resource Bundle File : {1}",new Object[] {"MSG001","ErrorMsg"});
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","PurchaseOrderCMPBeanJNDI not found");
Object objDocumentFile[]=null;
ISFXWebClientSLHome iSFXWebClientSLHomeRef=null;
ISFXWebClientSL iSFXWebClientSLRef=null;
try{
//Locating SFX WEB CLIENT SESSION BEAN
InitialContext initialContext=new InitialContext();
Object sfxWebClient=null;
try{
sfxWebClient=initialContext.lookup("SFXWebClientJNDI");
catch(Exception e)
//NGP/JDK Logging if JNDI not found
//logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","SFXWebClientJNDI"});
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","SFXWebClientJNDI not found");
iSFXWebClientSLHomeRef=(ISFXWebClientSLHome)PortableRemoteObject.narrow(sfxWebClient,ISFXWebClientSLHome.class);
//creation of SFX we client
iSFXWebClientSLRef=iSFXWebClientSLHomeRef.create();
int arrSFXFileId[]=new int[argSfxFileId.length];
logger.finer("SFXWebClient created----");
//holds the sequence of SFX file id in the array
//EFile file=new EFile();
//getting context of the server
InitialContext documentCMPInitialContext=getInitialContext();
Object objDocumentCMPRef=null;
int docId=0;
try{
objDocumentCMPRef=documentCMPInitialContext.lookup("DocumentCMPBeanJNDI");
catch(Exception e)
//NGP/JDK Logging if JNDI not found
//logger.log(Level.SEVERE, "{0} : JNDI not found : {1}",new Object[] {"MSG002","DocumentCMPBeanJNDI"});
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.JNDINotFound","DocumentCMPBeanJNDI not found");
//Home interface reference of DocumentCMP EJB
//IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)PortableRemoteObject.narrow(objDocumentCMPRef,IDocumentCMPHome.class);
IDocumentCMPHome iDocumentCMPHomeRef=(IDocumentCMPHome)objDocumentCMPRef;
//find the document id in the Document table from the SFx File Id
for(int index=0;index<argSfxFileId.length;index++)
arrSFXFileId[index]=argSfxFileId[index].intValue();
logger.finer("mpsDocumentView arrSFXFileId[index]--"+arrSFXFileId[index]);
logger.finer("For Document auditing----");
//Remote interface reference of DocumentCMP EJB
IDocumentCMP iDocumentCMPRef=iDocumentCMPHomeRef.findDocIdBySfxId(new Integer(arrSFXFileId[index]));
docId=iDocumentCMPRef.getDocumentId().intValue();
//for document audit
try{
boolean flagAudit=mlogOriginDocumentAudit("Document is Viewed",docId,5,argUserId);
catch(Exception e)
//logger.finer("Document cannot be audited----");
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in audit processing");
//call the retrieveDocument method for the above array of elements
//Object[] tempObjDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
//EFile file=new EFile();
//for(int index=0;index<tempObjDocumentFile.length;index++){
// file= (EFile) tempObjDocumentFile[index];
// objDocumentFile[finalIndex++]=file.getDocFileName();
// objDocumentFile[finalIndex++]=file.getDocFileContent();
objDocumentFile=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
//EFile[] efileArray = (EFile[]) = objDocumentFile;
searchResult = new Object[efileArray.length*2];
for (int i=0;i<efileArray.length;i=i+2)
EFile currentFile = efileArray[i];
searchResult[i] = currentFile.getDocFileName();
searchResult[i+1] = currentFile.getDocFileContent();
searchResult=iSFXWebClientSLRef.retrieveDocument(argUserId,arrSFXFileId);
}//end of try
catch(Exception expt)
//logger.finer(expt);
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in retrieve from SFX");
//if exception occurs returns null as per initilisation above
//logger.finer("mpsDocumentView size--"+objDocumentFile.length);
return searchResult;
//**************************** FILE RETRIEVE IMPLEMENTATION FOR MLOG PEOPLE*******************************
* <b>
* Used for Retrieval of a document.
* </b>
* This function is called from struts.
* <p>
* @param argDocumentId Documnet Id which gives the ID of the document in the eDoc database..
* @param argUserId User Id of the user who wants to retrieve the document
* @return Returns a one dimentional Object array containing a series of file name and file content of the retrieved documents.
public Object[] mlogOriginDocumentView(int argDocumentId,String argUserId) throws RemoteException
//NGP/JDK Logging
logger.finer("mlogOriginDocumentView called--");
try{
argUserId=argUserId.toUpperCase();
catch(Exception e)
//e.printStackTrace();
logger.log("net.mlog.edoc.ejb.session.EdocRetrieveServiceSLBean.ProcessException","Exception in uppercase");
//logger.finer("mlogOriginDocumentView-- argDocumentId---"+argDocumentId);
/*FileHandler handler = null;
Logger logger=null;
try
//PropertiesFileReader propertiesFileReaderRef=new PropertiesFileReader();
//String logFile=propertiesFileReaderRef.getProperties("/edoc.properties","EDOC_LOG");
//handler = new FileHandler("eDoc.log",0,1, tr -
Bouncing Apache service through schedule batch script
Hi
We are using Oracle11i(11.5.10.2) with Database version 10.2.0.3 on windows 2000 server.
We are getting login page error frequently for temporary solution we are bouncing apache service frequently.
Now i want to restart Apache service through schedule batch script ,is it possible?
Thanks
With Regards
UmairHi Husseinr,
Use Windows Task Scheduler to accomplish this.
there is no diect option to schedule the service to restart and Actually i don't have batch script to schedule through Task Scheduler.
Why don't you try to fix the issue instead of bouncing Apache? Did you log a SR?
We raised SR and We are Following SR also it is has been running for long time,so until SR Solution i want to bounce the Apache servie through Scheduled Batch Script.
Thanks
Umair -
Controlling Browser through Java
Hi All,
I have a question , is there any way we can controll browser(IE) through java(swing) application.
In our application we need to launch two different IE browsers by clicking two buttons
My question is if Button A is clicked browser with yahoo.com need to launch if button B is clicked msn.com should launch
subsiquently if button A is clicked application should check weather yahoo.com is running if running then it should bring the browser with yahoo.com to front and if button B is clicked again the app. should bring msn.com to front
if you can give me some example code that would be greatOk, I've got an answer for you, but its kind of lengthy. This code comes from Carnegie Mellon University, all thanks where due.
import java.io.IOException
public class BrowserControl
public static void displayURL(String url)
boolean windows = isWindowsPlatform();
String cmd = null;
try
if (windows)
cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
Process p = Runtime.getRuntime().exec(cmd);
else
cmd = UNIX_PATH + " " UNIX_FLAG + " (" + url + ")";
Process p = Runtime.getRuntime().exec(cmd);
try
int exitCode = p.waitFor();
if (exitCode != 0)
cmd = UNIX_PATH + " " + url;
p = Runtime.getRuntime().exec(cmd);
catch (InterruptedException x)
System.err.println("Error bringing up browser");
System.err.println("Caught: " + x);
catch(IOException x)
System.err.println("Could not invoke browser");
System.err.println("Caught: " + x);
public static boolean isWindowsPlatform()
String os = System.getProperty("os.name");
if (os != null && startsWith(WIN_ID));
return true;
else
return false;
private static final String WIN_ID = "Windows";
private static final String WIN_PATH = "rundll32";
private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
private static final String UNIX_PATH = "netscape";
private static final String UNIX_FLAG = "-remote openURL";
}This is a real general class, it can be used in alot more specific instances (aka windows or UNIX specific) which might cut down on alot of the system checking codes. The important parts are the static Strings at the very end and putting some URL into the url variable via some textfield or other input method.
As far as the technicalities of opening two different browser windows....I'm not sure on that. But I hope the above code helps.
PS This code is from a hard copy printout, so there might be some minor syntax errors in my typing.
Maybe you are looking for
-
Login servlet checks db for ID/PWD
Upon compilation receive the following: Login.java [31:1] unreported exception java.sql.SQLException; must be caught or declared to be thrown String uName = validateUser(userId, password); ^ 1 error This occurs with the following code (which does thr
-
In BPM steps one Undefined step is there what is the purpose of that one, and step after one icon in the top, search for steps.
-
Hi, I have tried installing CRS in weblogic and displayed with below error in middle of installation. Could anyone provide me the solution to proceed further. -------DEPLOY PRODUCTION WITH A SERVER LOCK MANAGER TO WEBLOGIC ONLINE--------- Executing r
-
[SOLVED] systemd and ntpd.service
I've just converted to pure systemd according to the wiki. Everything went remarkably well, with just a little blemish. While I'm not notified of any error at startup, when I check systemctl I find that ntpd.service's LOAD/ACTIVE/SUB is loaded/failed
-
Hola buenas. Quería retomar un poco el tema de este hilo. http://forums.ni.com/t5/Discusiones-sobre-Productos-NI/dise%C3%B1o-robot-delta/td-p/2360752 La cuestión es que dados los puntos estoy intentando calcular los angulos con un programa en C para