JProfiler7: Set Up Local Proxy - java

Good time!
I need to integrate JProfile7 and Weblogic 11g. I have done all the steps are described for this and nearly everithing is ok except the following thing.
My application connects to the remote data base and there is a proxy server that I need to use to communicate to the world outside the company.
As far as JProfiler rewrites the Weblogic's start script to use its agent, there should be a way to tell it to use the proxy, but I can't find how do this.
Could somebody, please, suggest, how to do this?
EDIT:
I've tried to use the
-Dhttp.proxySet=true -Dhttps.proxyHost=12.121.12.12 -Dhttps.proxyPort=1212 java options, but the problem remains

As long as your application and the jProfiler are running within the same network without any proxy restrictions, you should be fine. It is the application, not jProfiler, who communicates with the proxied DB node.
You should be able to start your application as is - if the app is using the current proxy, then the same app with the jProfiler settings will be also using that given proxy. There should not be any difference in the application behavior.
Also, you start the application VM, let it run for a while with the correct proxy and then attach the jProfiler to the application - thiw will not change the proxy settings.

Actually, I don't know the main cause of the problem, but to resolve the issue I've done the following:
created a new file: profiledStartScript.bat outside the weblogic server's bin directory.
added the following lines:
set DOMAIN_HOME=C:/Oracle/Middleware/user_projects/domains/myDomain
set JAVA_OPTIONS=%JAVA_OPTIONS% -agentpath:C:\PROGRA~1\jprofiler7\bin\windows-x64\jprofilerti.dll=port=8849
call "%DOMAIN_HOME%\bin\startWebLogic.cmd"
and that did the trick.

Related

How do I make modification in java class hosted on a tomcat server faster?

I have a java codebase in form a war hosted on Apache tomcat server(Production server). Now let us say i make changes in my class and i want the same to reflect on my hosted codebase. Do i have to re-start the server every time after updating the class, or is there some better way to do it
You can use auto-deploy feature of tomcat. Read the documentation here.
If it is a development testing server, you can enable debugging, and reload your changed classes without having to restart the server or redeploying your webapp.
You can enable debugging by setting the following and restarting tomcat. (you can use a desired port):
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8787
In your IDE, create a debug configuration specifying server ip and the debug port you specified.
After connecting debugger, your IDE will usually prompt you to reload changed classes whenever you compile a class.
There is also a menu item also if you want to manually reload changed classes. Once you reload classes, your changes will be immediately effective.

Profiling Java WebApps

While trying to profile our WebApp with JVisualVM I have the problem that a lot of the interesting stuff is hidden behind the methods of our ApplicationServer.
I would love to have a tool that would allow me to profile the complete webapp inside of the server, but without profiling the server itself or any other webapps that might be running on the same server. Basically I think the server itself should be in a good position to provide something like that, but I never heard of such a feature in any server. Is anyone aware of such a functionality?
I would like to add that I already do profile my web app with JVisualVM...
You can use VisualVm and connect to your application server. There you can profile your application. You can connect also to a remote application server via JMX.
Profiling a web application without profiling the server is not really feasible, since profilers always look at the entire JVM.
You could define entry points to automatically start and stop profiling, but that is not really necessary: Just set your method call recording filters to the package of your web application and you will only see method calls in the classes that you are interested in, without the surrounding stack frames of the container.
In JProfiler, this is done by opening the session settings and defining a single inclusive filter:
Disclaimer: My company develops JProfiler.
You can connect VisualVM to the server's process also to profile it. See Working with Remote Applications and Connecting to JMX Agents Explicitly for reference.

Call to remote JVM using cmd script

I need to call a jar which is kept on a shared windows machine.
The JVM also needs to be placed on this shared machine so that anyone with access to the remote location should be able to call this jar.
I need to write a windows script which shall be run using a service user.
Is this possible? If yes, request you to please provide pointers.
Java Management Extensions provides the tools for building Web-based, distributed, dynamic and modular solutions for managing and monitoring devices, applications, and service-driven networks.
see JMX Tutorial
see example with Linux script
see Windows cmd script
You might have some luck using the Tanuki Software Java Service Wrapper. Jetty uses this for their Windows Service Wrapper.
Another option is Apache Commons Procrun, which is what Apache Tomcat uses.
Both work well to set up a Java application as a Windows service. You will need to ensure your application is designed to run well as a service; you should be able to "trigger" events (start, stop, restart, etc.). You might need a lightweight adapter around the application to get it to work right as a service; but that should be a trivial exercise.
Once you have a service set up, make sure appropriate user(s) have rights to start/stop the service [1] [2]. You could even set the service up to run using a specific account. Then you can use the net start, net stop, etc. commands in a batch file.

How to create the build using Eclipse 3.6

I am developing an web app using java/j2ee as middle ware and Mysql 5.1 as database. I have to deploy it on AWS-EC2 server.
My questions are:
How do I create the build
How do I deploy on ec2 server?
I am using Apache Tomcat-6. Should I use any other server like Apache2 as web-server?
Use WTP to create a Dynamic Web Module project.
Use AWS Toolkit for Eclipse
That's pretty terse, but you'll need so many more details that it's pointless to list them here. Read the docs, then come back with specific questions :)
Whether you need Apache2 in front of Tomcat depends on your requirements. If you need it you'll know it :) Things that you might want to punt off on Apache2:
SSL
Static content
URL rewriting
If you are just planning to do every thing manually. You should read this manual http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/
Basically,
You need to create an AMI instance of platform of your choice. (Win/Unix-based).
Configure it with the software that you need. In your case, Tomcat-6 and MySQL-5.1. Configure them. Set Schema etc.
Upload your WAR file to the instance and deploy to Tomcat-6.
Make sure Tomcat port (8080 or whatever you've configured) is open. You can configure this from AWS console's Security Group setting.
Use the instance's Public DNS to access your app. Public DNS can be found from AWS console.
There are many freely available, pre-configured AMI available. Since your setting is one of the most common one. I am sure you will get one and skip Step#2.

Should I implement source control for j2ee application server configuration files?

For a typical J2EE web application, the datasource connection settings are stored as part of the application server configuration.
Is there a way to version control these configuration details? I want more control on the datasource and other application server config changes.
What is the standard practice for doing this?
Tracking configuration changes to your application server through version control is a good thing to ask for. However, It does imply that all changes are done via scripting, instead of the administrative web interface. I recommend
http://www.ibm.com/developerworks/java/library/j-ap01139/index.html?ca=drs-
as a good background information article on this topic.
Update: Just recently, part 2 has been published here: http://www.ibm.com/developerworks/java/library/j-ap02109/index.html?ca=drs-
When working with WebSphere we found the best approach was to script the deployment and place the script under version control plus the response files for each of the target environments.
Websphere canbe tricky as the directory structure is a mess of files - often there appears to be duplicates and it's hard to figure which is the magic file you need to backup / restore . The question of how to go about this should not detract from the need to do it. - which is a definite yes.
Our (Spring) apps have a hardcoded jndi name in the spring config file. That way, the same ear can be deployed to dev, qa and prod environments, and you don't have to worry about database connection details.
The app server admins ensure that a datasource is registered against that jndi name, with the connection details as appropriate on each environment.
But how does this let me manage changes to datasource configurations in the application servers. Here's a scenario:
DBAs change the connection password of the database server.
Webspehere/Weblogic administrator makes corresponding changes to server configuration through administrator console.
The above change is not version controlled so there is no clean way of knowing the history of such changes.
The problem is not about how the application should be configured but about how the configuration changes should be version controlled. Perhaps it sounds like an overkill for simple projects but for some projects, controlling changes like these really becomes a problem.
Any time you ask yourself "should X be in version control" the default answer is "yes".
For a more refined answer, ask yourself this: is the file created by a person (like a source file or a document) or is it generated by another program (like an object file or a distribution PDF)?
File that are created, and/or maintained, by a human should be under configuration control.
We are always using version control for our app server settings. It's a tool called WLST (weblogic scripting tool) which is part of the weblogic server distribution. The domain configuration is stored within a Jython script, which can easily be executed via command line and therefore integrates superb with our build tool maven.
Creating a preconfigured running weblogic domain only needs to execute a maven goal. All those annoying problems of misconfigured jdbc connections or wrong jms destination parameters are gone. You will always have a appserver configuration which matches the source code at a given time. You will never need to remember which app server setting must be applied for this specific version of the project you are working on.
I really recommend this.
I also would like to know, if there are similar solutions for other application server available. As far as i know there is a way for glassfish via ant. How this can be achieved for JBoss?

Categories