9

I've recently setup a new Weblogic 12c environment. On deploying an application that I know works in Weblogic 11g I get the error "The url-pattern /resources/* in web application is mapped to multiple Servlets."

The mapping it's referring to is in the web.xml inside the application.ear that's being deployed, but it's only mapped once:

  <servlet-mapping>
    <servlet-name>velocity</servlet-name>
    <url-pattern>/resources/*</url-pattern>
  </servlet-mapping> 

The project doesn't contain any other references to the url pattern /resources/*, can someone explain where the duplicated mapping is coming from and how I can work around it?

The closest issue I could find is this: https://bugster.forgerock.org/jira/si/jira.issueviews:issue-html/OPENAM-7947/OPENAM-7947.html, which has been marked as unreproducible.

Full stack trace from deployment:

<Error> <Deployer> <BEA-149205> <Failed to initialize the application "<application_name>" due to error weblogic.application.ModuleException: weblogic.management.DeploymentException: [HTTP:101401]The url-pa
ttern /resources/* in web application <application_name> is mapped to multiple Servlets.
weblogic.application.ModuleException: weblogic.management.DeploymentException: [HTTP:101401]The url-pattern /resources/* in web application <application_name> is mapped to multiple Servlets.
        at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
        at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
        at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:192)
        at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:187)
        at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:83)
        at weblogic.application.utils.StateMachineDriver.nextStateInParallel(StateMachineDriver.java:144)
        at weblogic.application.internal.flow.ModuleStateDriver.parallelPrepare(ModuleStateDriver.java:46)
        at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:75)
        at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:55)
        at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:731)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:45)
        at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:243)
        at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:66)
        at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:65)
        at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:158)
        at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:41)
        at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:193)
        at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:31)
        at weblogic.management.deploy.internal.ConfiguredDeployments$2.doItem(ConfiguredDeployments.java:684)
        at weblogic.management.deploy.internal.parallel.BucketInvoker.invoke(BucketInvoker.java:138)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionAppsParallel(ConfiguredDeployments.java:692)
        at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:322)
        at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:202)
        at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:207)
        at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:129)
        at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:76)
        at sun.reflect.GeneratedMethodAccessor2.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1262)
        at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:332)
        at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:374)
        at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:471)
        at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:232)
        at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:85)
        at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2020)
        at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:114)
        at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:88)
        at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1213)
        at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1144)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:666)
        at weblogic.invocation.ComponentInvocationContextManager._runAs(ComponentInvocationContextManager.java:348)
        at weblogic.invocation.ComponentInvocationContextManager.runAs(ComponentInvocationContextManager.java:333)
        at weblogic.work.LivePartitionUtility.doRunWorkUnderContext(LivePartitionUtility.java:54)
        at weblogic.work.PartitionUtility.runWorkUnderContext(PartitionUtility.java:41)
        at weblogic.work.SelfTuningWorkManagerImpl.runWorkUnderContext(SelfTuningWorkManagerImpl.java:640)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:406)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:346)
WhyWeblogic
  • 91
  • 1
  • 1
  • 2

4 Answers4

4

If you use web annotations in java code, you don't have to declare the servlet in the web.xml file any more.

You can try by removing the corresponding "servlet" and "servlet-mapping" tags in web.xml

It seems that WebLogic 12.1.3 can deal with double declaration (inline annotation & xml) but not anymore in WebLogic 12.2.

I had this error with @webservice annotation when I specified the "serviceName" parameter and when I declared the servlet in web.xml file with the same value.

Zou
  • 243
  • 2
  • 11
0

The issue doesn't exist in version 12.1.3 (which happened to be the version we were meant to be upgrading to).

WhyWeblogic
  • 91
  • 1
  • 1
  • 2
0

Weblogic as of version 12.2.1.3 automatically registers a JAX-RS servlet to the path /resources/* in certain scenarios (e.g. some dependency like jackson-jaxrs-json-provider "requests" it via annotation/spi/moduleinfo). But if this path is already registered by another service the mentioned error is thrown.

There are 3 possible solutions one can try:

  1. In our case the issue was coming from classpath scanning for web services components, and finding annotated services in the webservices-rt jar. That scanning needed to be switched off. Setting the metadata-complete attribute to true in the web.xml descriptor if your Web application does not have any annotations and if you have the version set to 2.5 or higher to avoid unnecessary scanning of the Web applications classes for annotations. E.g.

    <?xml version="1.0" encoding="UTF-8"?>
     <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
      http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
      version="4.0"
      metadata-complete="true">
      <servlet>
       <servlet-name>sample</servlet-name>
       <servlet-class>Sample</servlet-class>
      </servlet>
      <servlet-mapping>
       <servlet-name>sample</servlet-name>
       <url-pattern>/sample</url-pattern>
      </servlet-mapping>  
    </web-app>
    
  2. Alternatively, you can turn off annotation processing and DI for all the Web applications by setting -Dweblogic.servlet.DIDisabled=true flag when starting WebLogic Server.

  3. Registering another path for jersey in the web.xml to e.g. /jersey/*

    <servlet>
     <servlet-name>Jersey Web Application</servlet-name>
     <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
    </servlet>
    <servlet-mapping>
     <servlet-name>Jersey Web Application</servlet-name>
     <url-pattern>/jersey/*</url-pattern>
    </servlet-mapping> 
    
Lonzak
  • 9,334
  • 5
  • 57
  • 88
0

Try removing the FATP jars which were added after 12.2 upgrade. This worked for me.