How can I log the Glassfish domain? - java

I do a bit of logging in a ServletFilter to log which web services are being called, response times, etc, and I would ideallly like to log the domain name of the running Glassfish server. But so far I have not been able to come up with any way of programmatically access this info.
Do any of you know of a way to access this info from the currently running web application?
org.glassfish.admin.amx.base.DomainRoot seems to have some methods that might give some info, but I have no idea on what classes implement these interfaces.

You can get it from a system property:
String instanceRoot = System.getProperty("com.sun.aas.instanceRoot");
For my glassfish installation this results in:
C:\glassfishv3\glassfish\domains\domain1
There is a related property called instanceName:
String instanceName = System.getProperty("com.sun.aas.instanceName");
which results in the output
server

Related

log output from qpid library running in weblogic

I am looking for a way to get more detail, like debug or verbose level logging, of a JMS message send over amqps to AzureServiceBus.
I am using qpid client 0.60.1 and I have no access to the calling code. I am working with a web application running in Weblogic. The application provides a servlet that has generic JMS functions, and I can use configuration that maps those to a specific providers' JMS connection factory libraries. To make qpid available to use, I add the qpid client jars to the CLASSPATH for when I start weblogic, and I provide a jndi.properties file that currently contains only two entries:
con
connectionfactory.ServiceBusConnectionFactory=amqps://?jms.username=&jms.password=
queue.inbound-general-q-QueueLookup=
Currently, this is the only message that I see in the weblogic log:
Connection ID:6147a0e7-1870-4a1a-8dd5-bd7102fc1aa4:106 connected to server: amqps://
I have been told that we don't have enough information to open a case with Microsoft.
I am looking for a way to get more detail, like debug or verbose level logging, of a message send. Ideally, want to see as much as possible: headers, properties, payload, etc.
The things I have access to change:
Weblogic environment, including classpath and any other java runtime flags
The jnd.properties file
I am reviewed the qpid.apache.org documentation on logging, but it has not been helpful to me as it is too vague.
The main application running in weblogic has these parameters in its runtime:
-Djava.util.logging.config.file=properties/logging.properties
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
I have tried adding some things to logging.properties, but it has never changed the output of the resulting log file to include anything from amqp.

How do I test if EJB is running on JBoss AS 7 server

Again, many excellent answers from the fine folks here on SO. I am still unable to connect. But I believe Gimby might have had a good suggestion that there may be something wrong with the server or the beans. According to the log file generated when JBoss started, my beans have been deployed. The administrator of the server is unable to run the admin console for vulnerabilities reasons so there is no way to see if the beans are running. Is there a command line tool that I could point him to for testing? Is there a simple test I could write that would check the beans? I have tried most everything I have found and others have suggested and keep getting various errors. most times being:
javax.naming.CommunicationException: Could not obtain connection to any of these urls: remote://:4647
I've encountered other errors as I have made changes to various files and code but this one is the most frequent. If the call I make to the bean is right, and that is questionable, then how do I tell if the bean is even running or not>
There seems to be some uncleared situations here.
Still I want to ask you, if your bean got a remote interface.
You could use lookup to find your bean on this server.
You also could deploy for example a RESTservice on your jboss server, which look for your bean locally, so you dont have to specify any connection properties, but you would need the jndi name.
Hope this helps a bit, greets Jerome.

Get messages.log style logging out of embedded neo4j

How can I maximize the log information an embedded neo4j database will give me, so that I can see what's going on?
Recent technical discussion on the google group called for an excerpt of messages.log, but I don't have that log file since I'm running embedded. I have consulted the server configuration docs (http://docs.neo4j.org/chunked/stable/server-configuration.html#_server_logging_configuration) but they don't tell me the actual names of the loggers to use.
I have tried this:
java.util.logging.Logger.getLogger("org.neo4j").setLevel(Level.ALL)
But by default, and also with this line of code, I see no log messages from neo4j at all.
I'm trying to get some of the server message logs to debug why certain read-only transactions are failing and rollback is failing; first I have to figure out how to get neo4j to tell me what's going on in this embedded database.
Actually you have messages.log it is in your graph.db directory.
And there are loads of diagnostic, config, tuning, memory and other information in that file. So very valuable.

Cannot debug Java Web application from Netbeans

I have a Java EE 5 application which consists of three web projects. I'm using JBoss 5.1 web server and NetBeans 7.2 IDE.
I have the following problems:
I cannot start application in Debug mode. That I know of, there are two (best) approaches in NetBeans and Java: Remote debugging and debugging via shared memory. I read this post How to debug JBOSS application in netbeans? and I set debug parameters in Jboss configuration(I also know there are different parameter sets for shared memory and remote debugging), but when I go to attach debugger I got following errors:
If I use remote debugging I got error "Connection refused";
If I use shared memory I got error similar to this text "dt_shmem:file path could not be found".
These errors occur when I start JBoss by running run.bat file. If I start JBoss from Netbeans IDE, I can attach to remote process (still have problem with shared memory approach), but then I have other problems, regarding variable primitives and model binding in page life cycle (I will not write about that now).
How can I solve these problems so I can debug application? At least, how can I find a better error message when it fails. I could not find too much on the Net by looking for "Connection refused" error only.
Why I cannot just press run main project(or web project) and that netbeans start application, open it in new browser tab(as localhost) and start debug mode? I'm coming from .net background and VS is offering this as out of the box tool (called ASP .NET development server). Why I have to use external web server and with every change deploy new application and then attach to it? Why Netbeans cannot by default use JVM for running application, and later when I deploy application I will choose which web server to use!?
I hope someone will make this clear to me :)
Thanks
added Note at 03.01.2013.
Well, when I changed VM options in project.properties file of web project (added run.args.extra=-J-Xms256m -J-Xmx756m), I succeeded to debug application and heat breakpoint when executing the code. However, I still have strange problem with Managed Bean properties. I have select list on page, and it is connected to Boolean property. When nothing is selected it should be set to null value by default (and it is when I start JBoss server by running run.bat file), but its value is by default set to false! I checked parameters post values in firebug and there is no problem in posting parameters to bean. It looks to me that problem is when JSF framework is trying to map post values to Managed Beans properties, but I cannot find out why this is happening. I also checked faces-config.xml, but did not find any specific rule for mapping to this specific property. Any tips?

JMX Remote Deployment Architecture

I'm reading up on JMX for the first time, and trying to see if its a feasible solution to a problem we're having on production.
We have an architecture that is constantly hitting a remote web service (managed by a different team on their own servers) and requesting data from it (we also cache from this service, but its a sticky problem where caching isn't extremely effective).
We'd like the ability to dynamically turn logging on/off at one specific point in the code, right before we hit the web service, where we can see the exact URLs/queries we're sending to the service. If we just blindly set a logging level and logged all web service requests, we'd have astronomically-large log files.
JMX seems to be the solution, where we control the logging in this section with a managed bean, and then can set that bean's state (setLoggingEnabled(boolean), etc.) remotely via some manager (probably just basic HTML adaptor).
My questions are all deployment-related:
If I write the MBean interface and impl, as well as the agent (which register MBeans and the HTML adaptor with the platform MBean server), do I compile, package & deploy those inside my main web application (WAR), or do they have to compile to their own, say, JAR and sit on the JVM beside my application?
We have a Dev, QA, Demo and Prod envrionment; is it possible to have 1 single HTML adaptor pointing to an MBean server which has different MBeans registered to it, 1 for each environment? It would be nice to have one URL to go to where you can manage beans in different environments
If the answer to my first question above is that the MBean interface, impl and agent all deploy inside your application, then is it possible to have your JMX-enabled application deployed on one server (say, Demo), but to monitor it from another server?
Thanks in advance!
How you package the MBeans is in great part a matter of portability. Will these specific services have any realistic usefulness outside the scope of this webapp ? If not, I would simply declare your webapp "JMX Manageable" and build it in. Otherwise, componentize the MBeans, put them in a jar, put the jar in the WEB-INF/lib and initialize them using a startup servlet configured in your web.xml.
For the single HTML adaptor, yes it is possible. Think of it as having Dev, QA, Demo and Prod MBeanServers, and then one Master MBeanServer. Your HTML Adaptor should render the master. Then you can use the OpenDMK cascading service to register cascades of Dev, QA, Demo and Prod in the Master. Now you will see all 5 MBeanServer's beans in the HTML adaptor display.
Does that answer your third question ?
JMX is a technology used for remote management of your application and for a situation for example when you want to change a configuration without a restart is the most proper use.
But in your case, I don't see why you would need JMX. For example if you use Log4j for your logging you could configure a file watchdog and just change logging to the lowest possible level. I.e. to debug. This does not require a restart and IMHO that should have been your initial design in the first place i.e. work arround loggers and levels. Right now, it is not clear what you mean and what happens with setLoggingEnable.
In any case, the managed bean is supposed to be deployed with your application and if you are using Spring you are in luck since it offers a really nice integration with JMX and you could deploy your spring beans as managed beans.
Finally when you connect to your process you will see the managed beans running for that JVM. So I am not sure what exactly you mean with point 2.
Anyway I hope this helps a little

Categories

Resources