Friday, November 11, 2011

"Same url pattern" error on GlassFish OSE 3.1.1 deployment

When I was experimenting with JSF 2.0 deploying into GlassFish Open Source Edition 3.1.1 using MyEclipse 10, I encountered an error I can't explain, since the source code set was previously tested on eclipse indigo + tomcat 7 combination and seems to work fine.

So I went and get jsf-blank.zip from coreservlets.com JSF 2.0 Tutorial - build and deployed it to GlasshFish from eclipse. Simple project, simple test and it's now proven to work. I copied the source code into MyEclipse and deploy the project into GlassFish, and sure enough it blows again.

The short version of the error is:

Exception while deploying the app : java.lang.IllegalStateException: Servlet [xxxxx] and Servlet [yyyyy] have the same url pattern: [/zzz]at org.glassfish.apf.AnnotationInfo@f3b0e2

Here's the error log associated with the exception:

[#|2011-11-11T10:09:09.367-0800|SEVERE|glassfish3.1.1|javax.enterprise.system.tools.deployment.org.glassfish.deployment.common|_ThreadID=16;_ThreadName=Thread-2;|Servlet [RegistrationRequesterPortImpl] and Servlet [RegistrationPortImpl] have the same url pattern: [/RegistrationService_V11]|#]

[#|2011-11-11T10:09:09.368-0800|SEVERE|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=16;_ThreadName=Thread-2;|Exception while deploying the app [jsf-blank]|#]

[#|2011-11-11T10:09:09.368-0800|SEVERE|glassfish3.1.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=16;_ThreadName=Thread-2;|Servlet [RegistrationRequesterPortImpl] and Servlet [RegistrationPortImpl] have the same url pattern: [/RegistrationService_V11]at org.glassfish.apf.AnnotationInfo@f3b0e2
java.lang.IllegalStateException: Servlet [RegistrationRequesterPortImpl] and Servlet [RegistrationPortImpl] have the same url pattern: [/RegistrationService_V11]at org.glassfish.apf.AnnotationInfo@f3b0e2
 at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:490)
 at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:432)
 at com.sun.enterprise.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:358)
 at com.sun.enterprise.deployment.archivist.WebArchivist.postAnnotationProcess(WebArchivist.java:89)
 at com.sun.enterprise.deployment.archivist.Archivist.readRestDeploymentDescriptors(Archivist.java:409)
 at com.sun.enterprise.deployment.archivist.Archivist.openWith(Archivist.java:267)
 at com.sun.enterprise.deployment.archivist.ApplicationFactory.openWith(ApplicationFactory.java:240)
 at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:171)
 at org.glassfish.javaee.core.deployment.DolProvider.load(DolProvider.java:93)
 at com.sun.enterprise.v3.server.ApplicationLifecycle.loadDeployer(ApplicationLifecycle.java:828)
 at com.sun.enterprise.v3.server.ApplicationLifecycle.setupContainerInfos(ApplicationLifecycle.java:770)
 at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:368)
 at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
 at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
 at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:360)
 at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
 at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
 at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
 at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
 at org.glassfish.deployment.autodeploy.AutoOperation.run(AutoOperation.java:145)
 at org.glassfish.deployment.autodeploy.AutoDeployer.deploy(AutoDeployer.java:575)
 at org.glassfish.deployment.autodeploy.AutoDeployer.deployAll(AutoDeployer.java:461)
 at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:389)
 at org.glassfish.deployment.autodeploy.AutoDeployer.run(AutoDeployer.java:380)
 at org.glassfish.deployment.autodeploy.AutoDeployService$1.run(AutoDeployService.java:209)
 at java.util.TimerThread.mainLoop(Timer.java:512)
 at java.util.TimerThread.run(Timer.java:462)
Caused by: Servlet [RegistrationRequesterPortImpl] and Servlet [RegistrationPortImpl] have the same url pattern: [/RegistrationService_V11]at org.glassfish.apf.AnnotationInfo@f3b0e2
 at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:367)
 at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:375)
 at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
 at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:195)
 at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)
 at com.sun.enterprise.deployment.archivist.Archivist.processAnnotations(Archivist.java:606)
 at com.sun.enterprise.deployment.archivist.Archivist.readAnnotations(Archivist.java:445)
 ... 26 more
Caused by: java.lang.IllegalArgumentException: Servlet [RegistrationRequesterPortImpl] and Servlet [RegistrationPortImpl] have the same url pattern: [/RegistrationService_V11]
 at com.sun.enterprise.deployment.WebBundleDescriptor.addWebComponentDescriptor(WebBundleDescriptor.java:362)
 at org.glassfish.webservices.annotation.handlers.WebServiceHandler.processAnnotation(WebServiceHandler.java:433)
 at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:344)
 ... 32 more
|#]


Long story short, I googled for previous solutions and after a while found an answer in java.net GlassFish forum as it turns out, to resolve the issue a metadata-complete="true" attribute need to be added into web.xml web-app tag.

Here's an example:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  version="2.5"
  metadata-complete="true">
    ...


That additional attribute seems to fix the issue, though I'm still not clear why it works OK through eclipse but not myEclipse.

Thursday, November 03, 2011

Brushing off some good Apples

Apple products is probably not meant for me. At least that's how it seemed.

I remember years back in late 80s, a roommate bought a Macintosh. It was fascinating, crisp graph and all, but I remember thinking, it doesn't have as much software as the PC, shrugged and moved on. Fast forward a few years, Steve Jobs was dismissed from the company he co-founded and moved to build NeXT computers. A lab at the CalState Long Beach had a few NeXTs system. I think its the cubes, tho I can't remember exactly. I happened to have a login access to those machines and got a chance to use them, and I thought it was slick and beautiful, much more pleasant to use than the Unix terminals or the icky Dec's VAX/VMS terminals. Then I check on the price, and its way too far fetched for a starving student. So I don't let my self get too much hooked into it.

Fast forward again, I found my self with a photographer roommate and he showed me how he processed his photos on his Mac with Photoshop in the days when digital photography meant photos were scanned and processed, not transferred from a CF or SD cards. I asked how much all those cost and after hearing the answer, shake my head and went back to my PC and thought that maybe the PC can do the same thing and I just don't know about it.

Time after time, I had other brushes with Apple and its technologies, and though I marveled at the beauty of the design, I'm getting used to just brushed it off, make do with what I have and embrace the alternative. When Apple came out with the iPod, it was years until I got my iPods. The first was an iPod shuffle, a gift from the company and another bought for my daughter for her little free math and alphabets games. For my self I got an alternate technology that I thought fit my logical perception and expectations. Shortly before the iPhone was released, I bought a Windows Mobile phone that supports Java and was happy about it, expecting that a new version of Windows Mobile will soon replaced the older version I have on it. But as it turned out, the Windows Mobile release never come and I'm getting seriously disappointed and sworn off never to touch another dumb WinMo phone ever again.

In late 2009, after thinking I can get an early phone upgrade from AT&T and get an iPhone 3GS at upgrade price, I finally stepped into an Apple Store, asked for a 16GB iPhone 3GS. They have it in stock! So I got through the checks and balances, ready to switch when I found out that AT&T still locked my contract for a few more month (I thought I can upgrade my phone 6 months before contract ends, as it turns out its 3 months or so). Needless to say, I left the store disappointed. I didn't see any benefit of paying full price (+/- $700 if I remember correctly) for the 3GS when in a few more months I can get it at lower price subsidized by AT&T.

In the meantime, I started to look at Android and explored the Android Market to see what's available. By this time I have an iPod 3rd generation, mostly not for my use, but obviously I get to play with it too. So I looked to see if any of the app were also in the Android platform. To my surprise there are plenty of those app which were cross-platformed. So I started looking for the hardware and eventually saw the specs for the HTC EVO 4G. Which seems to have superior hardware compared to the 3GS. Eventually when it came time in Summer 2010, I switched both carriers and hardware. I switched to Sprint and got the HTC EVO 4G. I haven't regret that decision since. Goodbye Windows Mobile - hello, Android.

Over the years, I had actually acquired a few iPads and a MacBook for relatives overseas (I got reimbursed back) and play with them a little before passing them to their rightful owners. The "try it before you buy it" marketing ploy couldn't have worked with me, since until now even after all those brushes with the technology and actually liking it, I lacked the actual "must have" desire for Apple product.

I've seen the MacBook Air and saw how slick and simple the design is. I have people telling me how smooth the MacBook Pro worked with VMWare with Windows guest OS used for development. I actually tried the system. And yet, the "Must have" feeling disappeared as soon as I went back to my chair and back tinkering around with some code design.

Since Steve Jobs passed away, I tried to see how direct his product and technology affected me. I can see his indirect influence on how the technologies he "Re-imagined" affected what I worked on. I can see the beauty in his design decisions and as I slowly read over his biography and past articles from the Mac team, I learned more about his unique role. As Walter Isaacson summarized in a NY Times article - The Genius of Jobs: "Those who know how to stand at the intersection of the humanities and the sciences. That is the formula for true innovation."