Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic Jax-RS registration in Weblogic 12.2.1 when adding eclipselink artifact

I have observed a very strange behavior in the latest Weblogic server, version 12.2.1.2. When an eclipselink dependency is added to your Java servlet application, Weblogic server is going to automatically trigger Jax-RS Jersey REST service under /resources/* path.

To remove any doubts, I have created a very simple helloworld war file. A sample war file can be created by following the instruction from this page (http://geekabyte.blogspot.com/2015/07/how-to-create-war-files-with-intellij.html)

If you followed the above instruction, basically the only dependency you would have is

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>javax.servlet-api</artifactId>
        <version>3.1.0</version>
        <scope>provided</scope>
    </dependency>

And Helloworld as the only class in the application. You can deploy this to any server and it will run just fine.

Now you add another dependency to your maven pom file. It is eclipselink artifact as you can see below:

    <dependency>
        <groupId>org.eclipse.persistence</groupId>
        <artifactId>eclipselink</artifactId>
        <version>2.5.2</version>
    </dependency>

When you deploy the war file, the server will log the following:

<May 23, 2017, 2:42:47,343 PM MST> <Warning> <JAXRSIntegration> <BEA-2192511> 
<The list of resource packages: org.eclipse.persistence.jpa.rs.exceptions;org.eclipse.persistence.jpa.rs.resources;org.eclipse.persistence.jpa.rs.resources.unversioned> 

And you will see the following from your Weblogic Admin console Automatic registration of JAX-RS/Jersey REST service

The impact of this is that if you follow the convention and store all your javascript and css files under /resources/ path, instead of serving these static files, the server will try to process these requests via JAX-RS service which end up returning 404 not found.

I have tried different configurations: Different server, different version of Weblogic server, Toplink instead of eclipselink, different version of eclipselink, and a bunch of other things which I will not mention here to keep it simple. Obviously we have a working application running in prior version of Weblogic which we are needing to migrate to the latest version of Weblogic. It took many days to pinpoint the problem to this one dependency. In any case, this problem only exists for Weblogic 12.2.* with eclipselink of any version as a dependency.

My obvious question to everyone is: Why is this happening? Has anyone experienced the same issue? What was your solution?

like image 270
Stephen C Avatar asked Oct 17 '22 12:10

Stephen C


1 Answers

Just to clarify my error and solution, I did not have this error (/resources/* path) in Weblogic 12.2.1.2 but I did have it in 12.2.1.3, and I noticed this new path /resoures/* after my organization got it upgraded (to 12.2.1.3).

Since I had eclipselink.jar included in my war, I tried the suggestion from "oracode", so I specified the scope "provided" in my POM, then I build the new war, but it did not affect the result. I was still having the problem.

<dependency>
  <groupId>org.eclipse.persistence</groupId>
  <artifactId>eclipselink</artifactId>
  <version>2.5.1</version>
  <scope>provided</scope>
</dependency>

However, the solution that worked for me was: to add the init-param section in my web.xml.

In my org, we have N web services, so I started comparing them, and I noticed one of these services (the one that was failing with this /resources/*) did NOT have init-param section specified explicitly, so I added it and my web service working ok now under /*.

<servlet>
  <servlet-name>jersey</servlet-name>
  <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
  <init-param>
    <param-name>com.sun.jersey.config.property.packages</param-name>
    <param-value>com.xxxxxx.xxx.xxx.xxx</param-value>
  </init-param>   
  <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
  <servlet-name>jersey</servlet-name>
  <url-pattern>/*</url-pattern>
</servlet-mapping>  
like image 192
gaps96 Avatar answered Oct 21 '22 01:10

gaps96