moving exe to windows service - stopped log files creation - java

I am using apache log4j from java 1.6.
I am creating exe file using exe4j and when I place it in the production folders -
logs are being created successfully.
Now, I have turned it into service exe
(checked a "service" checkbox in exe4j and installed it with SC command )
and log files stopped being created .
is there an explanation/solution for it ?
Thanks.

Your service most likely is running as an account (LOCAL SERVICE?) that does not have permission to write to the log folder.
To check the account under the service is running on, right-click the service in the Services panel, select Properties, and view the LogOn tab (for Windows 7... exact steps for other Windows versions will vary but the idea is the same).
I would suggest continuing to run your service with the least privileges it needs and modify access rights to the log folder to allow the account the service is running under to write to that folder (Principal of Least Privilege). Of course, don't have anything except logs in that folder.

Related

Can't figure out cause for NoClassDefFoundError: aspose/pdf/Paragraph

I can't get any pages of my webapp to load (locally on Tomcat 7.0.2.6), due to this NoClassDefFound error. I'm at my wits end trying to figure out what the cause is, here is what I know:
My coworker has this project successfully running locally (on Tomcat) and on our development server (WebLogic).
I have done a fresh pulldown from svn so my code is exactly the same as his. I've verified that I have a shared library reference to Aspose (and that the required .jars are in there), and that weblogic.xml has an entry for it.
We saw this same error when initially deploying on WebLogic because the Aspose library was named incorrectly, but it ran fine locally on his Tomcat server.
I've tried cleaning and rebuilding the project to no effect.
As best as I can figure, it has to be either a Tomcat issue, or maybe an Eclipse setting.
Has anyone encountered a similar situation? Any ideas on what to try to resolve this?
First thing you need to do is determine if you are colliding with another class with the same name and package. The easiest way to do this is with the cygwin/linux console, save this shell script to a file say, findjar
find "$1" -name "*.jar" -exec sh -c 'jar -tf {}|grep -H --label {} '$2'' \;
put it in your path and navigate to the root of the server instance and run the script like this
findjar . yourclass
Note the period, dont forget it. this will return if you have multiple classes with the same name in your project.
once your sure the project is clean and there is only one copy of the class, i would try actually adding your shared libraries folder to the websphere server instances JVM arguments. to do that:
Go into the admin, click on servers
Open server types, click on websphere application servers
You should see your server listed there, click on it
On the right hand side, you will see a section “server infrastructure” and below that is a subsection “Java and process Management”
Open that section and click on “Process Definition”
On the process definition screen is another right hand column. Click on “Java Virtual Machine”
Yes, finally we are on the correct screen, there is an end in sight here, I promise
On the virtual machine page, there is a large text field labeled “Classpath” What you need to do is enter the full path to the shared libraries folder
its odd and makes no sense to have to do it, but i have had to do that in the past to allow my code to see the properties files in a shared resource.
It is possible that your colleague has java librarys installed within his Tomcat instance itself.
Take a look in the Tomcat directory for some lib folders (I cant remember the exact location and I think it changes based on the version) but something like ${CATALINE_HOME}/common/lib
Verify that he doesnt have differen JAR files in his tomcat installation as yours.
From this question: Does Tomcat load the same library file into memory twice if they are in two web apps?
They are apparently stored here:
Tomcat 6 $CATALINA_HOME/lib
Tomcat 5 $CATALINA_HOME/common/lib

Java app deployment and updating in a Remove Desktop Services environment

I have a Java app which needs to be used in a Remote Desktop Services environment.
As the javaw.exe process holds a file handle of the JAR file, I can not replace the JAR as long as other users are working with it.
I can also not see the current users as there might be many other javaw.exe processes for other JAR files running on the same server. And in a server farm I would have to check every single server for open instances.
Is there a best practice to deploy and update Java apps in this environment?
Some ideas:
use a launcher app which has a configuration file which specifies the location of the JAR file
modify the entry in the start menu to point to the new JAR file location
copy the jar to a user-specific work folder on logon
use JWS
Option 3 and 4 however would mean that Log4J output needs to be directed to a location in a folder which can be accessed by operations / developers

How to run a JNLP file with SQLite DB?

I'm new to JavaFX. I have a JavaFX Application which is generating a jar and a JNLP file. As a DB I'm using SQLite db. The system runs fine when running it on Netbeans IDE but does not get going with built files (jnlp, jar). Problem is the JNLP is unable to find the db location when running with JNLP.
How can I fix it?
How is the DB installed?
Presuming the installer can accept an 'installation path', I would tend to:
Use an installer-desc element to start Java code.
That pops a JFileChooser to allow the user to create/select an installation directory
That it then passes (that path) to the DB installer, and..
Persists the path using the PersistenceService
When the main GUI starts, it can:
Read the DB path from the PersistenceService
Invoke/start the DB.
For demos. of some of the parts of that, see:
The PersistenceService.
The installer-desc that invokes the ExtensionInstallerService.
Sign your application to give it the permissions it needs to run correctly in jnlp mode.
If you have permissions on the machine you're running on and the user accepted them you should be able to write a new database file to the local system.
Make sure that you check that the database exists and if not create it. Failing that, what is the exception?

How to obtain administrator rights in java web start application, need to writting in system directories

I'm going to develop a java web start application, which need to access protected system directory and install a program there.
I know, how to exit sandbox, my application is signed and have access to filesystem. The problem is, that it sill can't access directories like C:/windows/system32.
I found solutions for standalone java applications:
Java: run as administrator
How to do this in java web start?
Thanks in advance for answer!
In your case you can probably try to use the following trick:
Precompile a jar file with the Manifest pointing to the main
class, that carries out all of the required filesystem routines
Put this jar somewhere into the resources folder of your Web-Start
application and then copy it into the user's Temp folder upon
Web-Start execution
Provision required files from the elevation
PowerToys
in the similar manner
Call " %PATH_TO_USER_TEMP%/elevate"
command together with "java -jar %PATH_TO_USER_TEMP%/yourJar.jar"
(please refer to the article above or additional documentation on
the Elevation PowerToys to find out the details)
If everything
works out, user shall be presented with a request to grant the
executed java process required Admin privileges.

Can't run dynamically generated batch file from Java

In java I have dynamically created a batch file under program files in tomcat's bin directory and execute it dynamically, but it does not execute. If I double click the generated batch file it does execute. (Problem occurs on windows server machine.)
On my machine and many XP machine this process works fine.
So is it OS dependent, or the file is at program files so can't have permissions to execute or there is any other problem?
A proper answer requires you to supply more information; maybe by answering these questions, you will determine your answer.
1) Be specific about the Windows Server version (2003, 2008, etc.)
2) I assume Tomcat is running as a Service; what user account does it run as, and does this user account have appropriate permissions?
3) Post the code you have that creates the file. Post the code you have that is executing the file. Are you trying to execute the file after it is created, but before the output stream is closed?
4) Have you tried creating this file in a different directory than the bin folder of Tomcat?

Categories