Glassfish allows to run multiple, independently configured application server domains. The default is domain1 and can be found at a location inside the glassfish installation like:
C:\Program Files\Java\glassfishv3\glassfish\domains\domain1
Configuration
To configure this domain for the use of inspectIT, there are two ways via editor and administration console. In both cases you need to copy the agent’s inspecit-agent.jar into the lib\ext directory of the domain:
C:\Program Files\Java\glassfishv3\glassfish\domains\domain1\lib\ext
This is necessary to assure the proper classloader creates the agent classes.
Configuration via editor:
Edit the config\domain.xml file of the domain and add three lines to the java-config element:
<jvm-options>-Dinspectit.config=PATH-TO-INSPECTIT/config</jvm-options>
<jvm-options>-Xbootclasspath/p:${com.sun.aas.instanceRoot}/lib/ext/inspectit-agent.jar</jvm-options>
<jvm-options>-javaagent:${com.sun.aas.instanceRoot}/lib/ext/inspectit-agent.jar</jvm-options>
Adjust PATH-TO-INSPECTIT that it points to your inspectIT configuration folder like /home/glassfish/inspectit/config.
Configuration via administration console:
Open the administration console (typically http://localhost:4848/ ), log-in to the server and make sure you are in the right domain.
Then select Configuration>JVM Settings and switch to the tab JVM Options. Here add the three JVM Options like above with the proper paths inserted.
Press save.
In both cases you have to restart the server for the changes to take effect. If you have configured your agent properly, you should see a message like
2010-11-04 16:32:24,921 : Trying to register Agent 'CookbookAgent'
2010-11-04 16:32:24,937 : Valid license for Agent 'CookbookAgent'
2010-11-04 16:32:24,937 : Remaining Agent slots: 3
2010-11-04 16:32:24,968 : Successfully registered Agent 'CookbookAgent' with id: 4820 and version 1.2.24
In the CMR console output. Also the inspectIT application should show your agent and the CPU usage of starting the server.
Configuring OSGi Containers
If you use GlassFish version 3.1.2+ and 4+ you should configure the OSCi Containers for our Javaagent classes. Not doing so might result in following kind of exceptions:
[2015-03-27T11:11:37.639+0100] [glassfish 4.1] [INFO] [NCLS-REST-00003] [javax.enterprise.admin.rest] [tid: _ThreadID=48 _ThreadName=admin-listener(1)] [timeMillis: 1427451097639] [levelValue: 800] [[
An error occurred while processing the request. Please see the server logs for details.
MultiException stack 1 of 2
java.lang.NoClassDefFoundError: info/novatec/inspectit/agent/Agent
at org.jvnet.hk2.internal.DelegatingClassLoader.loadClass(DelegatingClassLoader.java)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:612)
at java.lang.reflect.Proxy$ProxyClassFactory.apply(Proxy.java:592)
at java.lang.reflect.WeakCache$Factory.get(WeakCache.java:244)
at java.lang.reflect.WeakCache.get(WeakCache.java:141)
at java.lang.reflect.Proxy.getProxyClass0(Proxy.java:455)
at java.lang.reflect.Proxy.newProxyInstance(Proxy.java:738)
at org.jvnet.hk2.internal.ProxyUtilities$1.run(ProxyUtilities.java:104)
at java.security.AccessController.doPrivileged(Native Method)
at org.jvnet.hk2.internal.ProxyUtilities.secureCreate(ProxyUtilities.java:99)
at org.jvnet.hk2.internal.ProxyUtilities.generateProxy(ProxyUtilities.java:179)
at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2231)
at org.jvnet.hk2.internal.ServiceLocatorImpl.internalGetService(ServiceLocatorImpl.java:690)
at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:663)
at org.jvnet.hk2.internal.IterableProviderImpl.get(IterableProviderImpl.java:108)
at org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.getBaseUri(ActionReportResultHtmlProvider.java:211)
at org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.getContent(ActionReportResultHtmlProvider.java:78)
at org.glassfish.admin.rest.provider.ActionReportResultHtmlProvider.getContent(ActionReportResultHtmlProvider.java:68)
at org.glassfish.admin.rest.provider.BaseProvider.writeTo(BaseProvider.java:126)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.invokeWriteTo(WriterInterceptorExecutor.java:263)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:250)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
at org.glassfish.jersey.server.internal.JsonWithPaddingInterceptor.aroundWriteTo(JsonWithPaddingInterceptor.java:106)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
at org.glassfish.jersey.server.internal.MappableExceptionWrapperInterceptor.aroundWriteTo(MappableExceptionWrapperInterceptor.java:89)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:162)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1154)
at org.glassfish.jersey.server.ServerRuntime$Responder.writeResponse(ServerRuntime.java:621)
at org.glassfish.jersey.server.ServerRuntime$Responder.processResponse(ServerRuntime.java:377)
at org.glassfish.jersey.server.ServerRuntime$Responder.process(ServerRuntime.java:367)
at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:274)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:271)
at org.glassfish.jersey.internal.Errors$1.call(Errors.java:267)
at org.glassfish.jersey.internal.Errors.process(Errors.java:315)
at org.glassfish.jersey.internal.Errors.process(Errors.java:297)
at org.glassfish.jersey.internal.Errors.process(Errors.java:267)
at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028)
at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:365)
at org.glassfish.admin.rest.adapter.RestAdapter$2.service(RestAdapter.java:316)
at org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:179)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:201)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:175)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:284)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:201)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:133)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:112)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:561)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:565)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:545)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: info.novatec.inspectit.agent.Agent not found by org.glassfish.hk2.locator [238]
at org.apache.felix.framework.BundleWiringImpl.findClassOrResourceByDelegation(BundleWiringImpl.java:1532)
at org.apache.felix.framework.BundleWiringImpl.access$400(BundleWiringImpl.java:75)
at org.apache.felix.framework.BundleWiringImpl$BundleClassLoader.loadClass(BundleWiringImpl.java:1955)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 63 more
You should add the
to the [GlassFish-Home]/glassfish/config/osgi.properties file:
org.osgi.framework.bootdelegation=${eclipselink.bootdelegation}, \
com.sun.btrace, com.sun.btrace.*, \
org.netbeans.lib.profiler, org.netbeans.lib.profiler.*, info.novatec.inspectit.*
Specific containers
If you are running Eclipse Equinox or Apache Felix, you might need to add the same bootdelegation package specification to the container properties:
- for Equinox config file is: [GlassFish-Home]/glassfish/osgi/equinox/configuration/config.ini
- for Felix config file is: [GlassFish-Home]/glassfish/osgi/felix/conf/config.properties