How can I see what the JVM is doing? - java

I run in a problem with the new update of java 7u51, I'm trying to set up the Deployment rule set to allow or not to run different application, base on its URL.
I have everything running, the deployment rule set file is signed and in the right place and even I'm available to match some URL to don't allow it to run.
But I don't know why some URL doesn't match.
So, I would like to debugger what JVM is doing and see if I can get why some URL are not matching.
Could somebody tell me how can I do that?

I am unsure of any debugger you could use, however you can use the Java log (or Java console if in a browser).
http://www.java.com/en/download/help/javaconsole.xml

Related

How to get active browser info along with active session ID using java\command line

I've to get all active browsers that are opened in the local machine along with corresponding session ids.
I've made little research and i do find the below link.
It's giving the active browser name which is not enough though
I know there is some plugin's available to get the sessions but i need to do it programmatically.
Thanks in advance!!
Short answer: it's impossible.
Long answer: Nothing distinguish browser from any other program. In fact many programs have browser functionality embedded in it.
If you define browser as one of known program such as "Firefox", "Chrome", "IE" etc. than you can do something to achieve some result.
First of all: forget about Java, you need to work with Win-API and Java is not best solution to do it.
You can enumerate process and find browsers by executable name.
Then you can check each browser documentation to find if there any integration API. Each browser will have its own API (or do not have).
Then using this API you can extract what is available.
So it will be hard if even possible to get what you want.

JAVA application with file write/output on linux cant be read by non root user

We have this JAVA webservice that runs on tomcat 9(installed by root).
The webservice creates a generic file log for our client. The problem is only the root user can read and access the file that is being generated.
My question is can I change the output file to be readable for all users by default? (without using chmod everytime the file is generated)
Should it be on code level or configure it on linux?
I have read about this https://docs.oracle.com/javase/tutorial/essential/io/file.html.
But one of our old redhat servers dont have a code level config on its webservice and its working fine.
Thanks
You should not be looking at this from a "java io" side of things.
This is a user permission problem. In other words: probably your tomcat servers shouldn't be running as root in the very first place.
Consider creating a special user that is used to run your tomcat instance. Here you can find guidance how you could do that for an Ubuntu system. And your favorite search engine will for sure know similar links for your favorite Linux distribution, too.
That might also be better from a security perspective: do you really want that people attacking your tomcat ... end up being root on your system if they succeed?!
Long story short: your problem is not some java code within tomcat that writes files; and then other users on your system being unable to access those files. Your problem is that your tomcat service is running as root! Fix the later; and your "initial" problem will be fixed, too.
Final word of warning though: I am not saying that it is easy to change the user setup for you. Maybe it is; but especially if your setup is using "root" for a long time, then there is a certain chance that other things you put in place rely on "being root". So, "not being root" is the right direction; but it might be a painful path to get there, from where you are now.

xpage calling Java agent fails when script library is included in agent

I have bumped into a weird problem in feature that works well on all other installations, but not for one particular client.
The "feature" involves an xpage with code in beforerenderrespons that picks up an uploaded file, gets filename etc and creates a context document. The context document is then passed as parameter to a java agent which process the file.
The java agent is set to Run as web user and has Allow restricted operations. As I said - it works in all installations at other clients, but fails all of sudden on one installation.
The only error message I get from beforerenderrespons event is "Error:Exception occurred calling method NotesAgent.runWithDocumentContext(lotus.domino.local.Document) null".
I have confirmed that the agent is found but it never gets called. I have also confirmed that the context document also exists.
The server console says nada.
I have tested calling the agent with different run methods as in agent.run() but it does not make a difference.
Now to the weird stuff - if I call a java agent that does not include a scriptlibrary it works! But as soon as I add a script library to the agent I get the error above.
Why is that? Any help or clue appreciated. It feels like I have missed a security setting somewhere.
The server doc includes the agent signer in "Sign agents to run on behalf of someone else", "Sign or run unrestricted methods and operations" and "Sign or run restricted LotusScript/Java agents"
edit:
Tested using a "pass-thru" agent that calls my original java agent that contains script libraries and that works! The pass-thru agent doesnt contain any scriptlibrary and simply calls my java agent and passes on the context document.
Even so - I still want to know why calling a java agent directy fails if it contains a script library.
/Katarina
One possiblity is the server version. That would explain why it works in some installations and not another. runWithDocumentContext() was only added in 8.5.2 http://blog.nashcom.de/nashcomblog.nsf/dx/passing-a-document-to-an-agent-without-saving-it-first.htm
Since your agent is Java anyway, you can save the trouble of spinning up a new class loader and jvm environment. Move the code into a jar and call it directly from the XPage.
I can't think of a good reason to use the agent (because it was there isn't a good reason in this case)

Returning a value from a java web start application

Wondering if anyone knows if there is a way to "return" something from a java web start application into the code on the website. For example say the user needed to select a location in the java application. This would then pass the location value back to the code on the webpage (which is php and javascript). I have figured out how to pass arguments into a program, but so far cannot figure out any way to get them out after much googling. Any help would be much appreciated, thanks.
In principle no, since the Webstart application can be running without any Website open at all.
But if your clients use the Java-plugin from 1.6.0_10 or later (and not Safari and some other browsers with special Java-handling), you can use a JNLP-enabled applet, which is able to do the same things as a Webstart application (i.e. loading files and such), and is always bound to a webpage. It then can use the Javascript-bridge, or simply a loadDocument with the right parameters to feed back information.
You can use URL or sockets to connect back to the "same-origin" host. You can also use BasicService to open a web page, possibly from a different server, in a browser (although this shouldn't be used to send information back, as it'll be a GET not a POST).

Starting an external process fails: cannot connect to X server

as part of my eclipse plugin I try to start an external program by using process.exec. This works with some tools (I tested it with gedit, for example), but with the one I need it does not work: isimgui: cannot connect to X server.
This is part of the XILINX webpack, none of the included graphic tools can be started like this.
Any ideas how I met get it to work?
You probably need to pass the -display argument to the executable you are running, or better (more widely supported) set the environment variable DISPLAY to the right value (try ':0')
use for example: process.exec(String[] cmdarray, String[] envp)
envp should contain at least one string "DISPLAY=:0"
You must inherit the DISPLAY variable from your shell (and possibly also the X11 authentication file information).

Categories

Resources