Currently I m running a component (IBM WTX tool) from Java using the jars provided by IBM. In the WTX component I am connecting to a oracle database using tns connect identifier. While the running the component independently the tool picks up the tnsnames.ora of the oracle driver installed in my system and it works fine. But when running the same component from Java it could not resolve the tnsname and fails. Do we need to do any additional setup in Java Side?
I tried System.setProperty("oracle.net.tns_admin",""). But It didn't work.
Can anyone help on the issue?
Regards,
TNS_ADMIN must be set in the environment before the Java process is started. I don't think it can be set from within Java - or at least I haven't seen it done successfully before. Typically I have see this set from a shell script that also launches the Java program.
Related
I just want to know how I can start derby in network server mode and still be able to get an embedded connection?
Thank you.
You need to launch Derby in "embedded server mode". If you are already using Derby in embedded mode, this can be enabled by providing the necessary files in your classpath, then specifying a handful of command line arguments when launching the application.
First make sure the following jars are in your application's runtime classpath.
derby.jar derbynet.jar
Then add the following command line options to the Java command used to launch your application. If the class files are missing, these options will have no effect.
-Dderby.drda.startNetworkServer=true
-Dderby.drda.portNumber=8011
I'm running Derby from within a servlet hosted by Tomcat, so I added these options to the catalina.bat file.
Start up your application and check the list of open network sockets.
netstat -an | find "8011"
You should now see Derby listening for connections on 8011. Its now possible to connect to the database using Derby's client driver (derbyclient.jar). The instructions at http://docs.oracle.com/javadb/10.3.3.0/adminguide/radminembeddedserverex.html cover this part pretty well.
It was hinted that running Derby in this mode may be discouraged. I don't believe that to be the case. Your application will continue to access the database using the embedded driver, while other software is now permitted access using the client driver.
The Embedded Server mode sounds like what you are asking for. It allows you to start a network server when you start the embedded database.
It sounds contradictory that you want to start derby in network server mode and get the embedded driver. Even if this might be possible, it is definitely discouraged. You should decide on whether you want to use Apache Derby in the network mode using the DRDA or as an embedded driver and stick to that decision.
Here you'll find a tutorial on how to use the network driver:
http://db.apache.org/derby/papers/DerbyTut/ns_intro.html
Some one correct me if i am wrong, Both will run on separte ports. So you can connect to the required one using the proper connectionName, right?
#pawelocue: Sorry, but this is wrong. Using the embedded server mode is perfectly alright and sometimes very useful. It is definitely not discouraged.
I’m using glassfish 3.1.2 on Red Hat Enterprise Linux Server release 5.7 (Tikanga). Glassfish has been installed as part of a piece of bigger software (that I’m developing). It used to work correctly in the past.
I can issue a ‘start-domain’ command. This one will work correctly and glassfish will start. I can see the process and the glassfish admin web console is working fine. However, the command ‘list-domain’ reports my domain as not running. The command ‘stop-domain’ will fail reporting the domain1 as already stopped. This prevents my software to run properly.
As far as I know, nothing has changed on that system. There is no exception/error in the log. I already search the internet for description of similar behaviour. I ensured the embedded firewall (the one coming with the OS) did not prevent the communication. I removed the expired certificate (just in case). I have no idea on what I could do next.
What could I check? Any help appreciated. Add a comment if you need specific details and I will update the question.
Answer to unwichtich's questions:
absolute path to jvm using an absolute path to the admin-cli.jar: /.../java -Duser.home=... -Duser.language=en -Dhttps.protocols=TLSv1.2 -jar /.../glassfish/modules/admin-cli.jar --terse --port 23992 --user admin --passwordfile /.../passwordfile list-domains
There are two lines in the /etc/hosts. The first with the ip mapping to the hostname. The second with 127.0.0.1 mapping to loopback and localhost
My software includes some command line utilities that need to perform operation on Glassfish (like start-domain, stop-domain, list-domains,...).
Respected Experts,
I have a stand alone java application and want to monitor the threads created by it. I am planning to use a tool like JConsole or JVisualVM. However, I am not able to connect these tools locally to my Java Application.
I am using Windows machine. JConsole and Java program are running locally. I have tried to run Java application with following JMV arguments with no success:
java -Dcom.sun.management.jmxremote.port=9999 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false LinkedListTest
When I try to connect using JConsole, my process id is greyed and following message appears:
Note: The management agent is not enabled on this process
I think I should be able to connect JConsole to a stand alone java application. Any thoughts what I am missing here
Thanks and Regards
Thanks for the inputs. I was able to solve the problem and the details are as follows:
As #Holger mentioned, both JConsole and JVisualVM can connect to the local Java Application running without any JMX arguments. The problem that I was facing was machine specific. I restarted the machine and deleted the following directory:
%TMP%\hsperfdata_User.Name
(I was not able to delete this directory without doing a restart)
Restarted JConsole/JVisualVM and was able to connect to local java processes using the process id.
In fact, the use of JVisualVM pointed me towards this fix. On start of JVisualVM, I got an error message stating something like local processes/applications can't be monitored. The message had a link to Troubleshooting guide. I am reproducing the relevant snippet:
Local Applications Cannot Be Monitored (Error Dialog On Startup)
Description: An error dialog saying that local applications cannot be monitored is shown >immediately after VisualVM startup. Locally running Java applications are displayed as Application> (pid ###).
Resolution: This can happen on Windows systems if the username contains capitalized letters. In >this case, username is UserName but the jvmstat directory created by JDK is >%TMP%\hsperfdata_username. To workaround the problem, exit all Java applications, delete the >%TMP%\hsperfdata_username directory and create new %TMP%\hsperfdata_UserName directory.
However, on my machine directory had the following format:
%TMP%\hsperfdata_User.Name
So, my recommendations are:
-check the name of the above mentioned directory for presence of camel case user name
-If not, follow the steps from the Trouble Shooting guide
-If the problem persists, delete the directory (may require machine reboot, as in my case)
-Restart JConsole/JVisualVM
Hopefully, the problem would be resolved.
Thanks and Regards
How do I set the Java proxy settings in Ubuntu (10.04 or 12.04), from the command line?
What I am aiming at is to get direct connection, but by default it takes it from browser settings which are meant to go via a proxy - just I don't want Java to go via the proxy.
I am running an application server in Ubuntu which serves remote desktop sessions. I can put the Java control panel into the user's desktop, and then they (each individual user) can set the proxy settings under Network Settings. However - this means I have to tell each user to make this setting, which is not workable.
I want it set via some command line or environment variable on the server itself, so it defaults to "direct connection". I am not familiar with Java programming and it won't help much to give me Java code for this, I think it must be possible to set the defaults upon Java startup? Any pointers are welcome.
How can I do this?
Instead of command line you can edit $javaDirectory/jre/lib/net.properties.
Remove # in-front of:
http.proxyHost="proxy host"
http.proxyPort="proxy port"
https.proxyHost="proxy host"
https.proxyPort="proxy port"
and set your proxy there.
You can export the http_proxy environment variable via command line.
Ex:
$ export http_proxy=http://proxy-server:port
There is a environment variable ftp_proxy also, just in case you need it.
I'm using Java Service Wrapper (here) v. 3.2.3 on Linux RHEL 5.4.
I need to add hostname to system properties (see here):
wrapper.java.additional.13=-DHOSTNAME="%WRAPPER_HOSTNAME%"
The problem is that WRAPPER_HOST_NAME Since ver.3.3.2, WRAPPER_HOSTNAME Since ver.3.3.6.
Is there're a way to use external command to get hostname?
Is there any other unique system property I can use across several identical machine?
If running on Windows, try
wrapper.java.additional.13=-DHOSTNAME="%COMPUTERNAME%"