Saturday, December 13, 2008

NetBeans 6.5 and GlassFish v2ur2

Having finally gotten NetBeans 6.5 successfully installed my next goal was to build and deploy an application developed by a member on my team that looked up geospatially-enabled information from geonames.org and created a KML file of the output. I had already successfully done this with the code and NetBeans project files provided by the team on a previous version of NetBeans using the instance of GlassFish v2ur2 that was configured within NetBeans. It compiled and deployed with no problems. It was a service that when it was running I could access and display the returned KML file on an OpenLayers map within a portlet that was on the same instance of GlassFish.

But, for a true test, rather than doing it all within NetBeans, I wanted to take the WAR file that NetBeans created and deploy it remotely to a different instance of GlassFish. That proved to not be as easy. The instance of GlassFish I wanted to deploy to was running on a laptop with Windows Vista. I zipped up the WAR file on the Windows XP laptop, emailed it to myself, and downloaded it to the Windows Vista laptop. Windows Vista, in all its wisdom, kept insisting that the WAR file was a file type of "Directory", which really it is, but to move it into the .autodeploy folder of GlassFish I didn't want it expanded like Vista kept insisting. I finally resorted to the DOS command line to get done what I needed to do.

Once the WAR file was in the autodeploy folder the war_deployed file appeared, indicating the deployment was successful. But when I tried to display the index.jsp of the servlet in the browser, it displayed a "service is not available" page. Now it was time to look in the logs.

First I tried looking in the logs through the admin console. The log was filling up faster than I could scroll through in the window with messages that said:
WARNING *********** NetBeans HTTP Monitor ************ The request cannot be recorded most likely because the NetBeans
HTTP Server is not running. Go to the IDE and start the HTTP Server from within the Runtime window to fix this problem.

Now isn't that an aggravation. I didn't have NetBeans running and I didn't want NetBeans to be running so why should the server be complaining about a NetBeans feature not working? That's one of the problems with downloading and installing server and IDE packaged as one. They get dependent in a way that you may not necessarily want.

Doing a Google query of the error message I found this very helpful solution:

http://javahowto.blogspot.com/2008/12/disable-netbeans-httpmonitor-in.html

Rather than take the time to implement that fix, I looked at the log in NotePad. This is the NPE that was there:

[#2008-12-11T12:20:21.484-0500SEVEREsun-appserver9.1javax.enterprise.system.container.web_ThreadID=18;_ThreadName=Timer-15;_RequestID=bc574187-48c7-45d6-8456-6042df2f372f;WebModule[/GeonamesDotOrgLookupService]PWC1275: Exception sending context initialized event to listener instance of class mil.nga.to6.GeonamesDotOrg.ServiceListenerjava.lang.NullPointerException at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:433) at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:336) at mil.nga.to6.GeonamesDotOrg.ServiceListener.contextInitialized(ServiceListener.java:40) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4523) at org.apache.catalina.core.StandardContext.start(StandardContext.java:5184) at com.sun.enterprise.web.WebModule.start(WebModule.java:326) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:973) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:957) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:688) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1584) at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1222) at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:182) at com.sun.enterprise.server.WebModuleDeployEventListener.moduleDeployed(WebModuleDeployEventListener.java:278) at com.sun.enterprise.admin.event.AdminEventMulticaster.invokeModuleDeployEventListener(AdminEventMulticaster.java:974) at com.sun.enterprise.admin.event.AdminEventMulticaster.handleModuleDeployEvent(AdminEventMulticaster.java:961) at com.sun.enterprise.admin.event.AdminEventMulticaster.processEvent(AdminEventMulticaster.java:464) at com.sun.enterprise.admin.event.AdminEventMulticaster.multicastEvent(AdminEventMulticaster.java:176) at com.sun.enterprise.admin.server.core.DeploymentNotificationHelper.multicastEvent(DeploymentNotificationHelper.java:308) at com.sun.enterprise.deployment.phasing.DeploymentServiceUtils.multicastEvent(DeploymentServiceUtils.java:226) at com.sun.enterprise.deployment.phasing.ServerDeploymentTarget.sendStartEvent(ServerDeploymentTarget.java:298) at com.sun.enterprise.deployment.phasing.ApplicationStartPhase.runPhase(ApplicationStartPhase.java:132) at com.sun.enterprise.deployment.phasing.DeploymentPhase.executePhase(DeploymentPhase.java:108) at com.sun.enterprise.deployment.phasing.PEDeploymentService.executePhases(PEDeploymentService.java:919) at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:276) at com.sun.enterprise.deployment.phasing.PEDeploymentService.deploy(PEDeploymentService.java:294) at com.sun.enterprise.admin.mbeans.ApplicationsConfigMBean.deploy(ApplicationsConfigMBean.java:555) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:375) at com.sun.enterprise.admin.MBeanHelper.invokeOperationInBean(MBeanHelper.java:358) at com.sun.enterprise.admin.config.BaseConfigMBean.invoke(BaseConfigMBean.java:464) at com.sun.jmx.mbeanserver.DynamicMetaDataImpl.invoke(DynamicMetaDataImpl.java:213) at com.sun.jmx.mbeanserver.MetaDataImpl.invoke(MetaDataImpl.java:220) at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:815) at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:784) at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at com.sun.enterprise.admin.util.proxy.ProxyClass.invoke(ProxyClass.java:90) at $Proxy1.invoke(Unknown Source) at com.sun.enterprise.admin.server.core.jmx.SunoneInterceptor.invoke(SunoneInterceptor.java:304) at com.sun.enterprise.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:174) at com.sun.enterprise.deployment.autodeploy.AutoDeployer.invokeDeploymentService(AutoDeployer.java:564) at com.sun.enterprise.deployment.autodeploy.AutoDeployer.deployJavaEEArchive(AutoDeployer.java:545) at com.sun.enterprise.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:492) at com.sun.enterprise.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:267) at com.sun.enterprise.deployment.autodeploy.AutoDeployControllerImpl$AutoDeployTask.run(AutoDeployControllerImpl.java:374) at java.util.TimerThread.mainLoop(Timer.java:512) at java.util.TimerThread.run(Timer.java:462)


Here is the rest of the log file related messages that appear after the NPE, interesting that startup failed yet it was considered successfully auto-deployed.

[#2008-12-11T12:20:21.484-0500SEVEREsun-appserver9.1org.apache.catalina.core.StandardContext_ThreadID=18;_ThreadName=Timer-15;_RequestID=bc574187-48c7-45d6-8456-6042df2f372f;PWC1306: Startup of context /GeonamesDotOrgLookupService failed due to previous errors#] [#2008-12-11T12:20:21.593-0500INFOsun-appserver9.1javax.enterprise.system.tools.deployment_ThreadID=18;_ThreadName=Timer-15;[AutoDeploy] Successfully autodeployed : C:\servers\glassfish\domains\domain1\autodeploy\GeonamesDotOrgLookupService.war.#]

I had gotten the code from my team member so wasn't that familiar with what it was doing. He gave me several pointers on what to look for and we finally determined that there were 9 files in the WEB-INF/classes folder that were in the NetBeans project, but did not get copied over in to the NetBeans WAR file. That meant we had a build issue. I had just taken the project files "as-is" and assumed all was well since it built, ran and deployed from within NetBeans. Makes you wonder why NetBeans can't detect such a situation as this.

Not being that knowledgeable with how to tweak the build within NetBeans, I did the workaround of manually copying the missing files into the WAR. I redeployed the new WAR file and this time it worked. Whew, another learning experience. Thanks to all who helped.

No comments: