Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I wrote a post a few days ago about using Jersey 2.x as a shared library with WebLogic 12.1.2. In that post I suggested the following: In weblogic.xml the prefer-application-packages element needs to have entries added for ALL OF THE PACKAGES in the Jersey 2.x shared library JAR files. That means you need to go through every jar file in WEB-INF/lib for the shared library that was created with Maven and make sure the packages it defines are included in this element.

Now that is a tedious process and I thought that is something that could be automated. I spent a bit of time on the weekend putting together a script just for that. The script will go through all JAR files in a directory specified on the command line and will generate a list of unique <package-name> elements that can be used in weblogic.xml.

The script can be found on GitHub: ikromin/j2ee/weblogic_xml_cpgen/gencp.sh.

Here's a sample output of this script:
 Script Output
Processing /tmp/jersey2_25_1/WEB-INF/lib/aopalliance-repackaged-2.5.0-b32.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/asm-5.0.3.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/hk2-api-2.5.0-b32.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/hk2-locator-2.5.0-b32.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/hk2-utils-2.5.0-b32.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jackson-annotations-2.8.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jackson-core-2.8.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jackson-databind-2.8.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jackson-jaxrs-base-2.8.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jackson-jaxrs-json-provider-2.8.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jackson-module-jaxb-annotations-2.8.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/javassist-3.20.0-GA.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/javax.annotation-api-1.2.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/javax.inject-2.5.0-b32.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/javax.json-1.0.4.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-client-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-common-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-container-servlet-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-container-servlet-core-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-entity-filtering-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-guava-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-jaxb-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-json-jackson-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-json-jettison-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-json-processing-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-kryo-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-moxy-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-multipart-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-media-sse-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jersey-server-2.25.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jettison-1.3.7.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/jsonp-jaxrs-1.0.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/kryo-3.0.2.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/mimepull-1.9.6.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/minlog-1.3.0.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/objenesis-2.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/org.eclipse.persistence.asm-2.6.0.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/org.eclipse.persistence.core-2.6.0.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/org.eclipse.persistence.moxy-2.6.0.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/osgi-resource-locator-1.0.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/reflectasm-1.10.1.jar
Processing /tmp/jersey2_25_1/WEB-INF/lib/validation-api-1.1.0.Final.jar
Adding package com.esotericsoftware.kryo
Filtering out redundant sub-packages
Adding package com.esotericsoftware.minlog
Adding package com.esotericsoftware.reflectasm
Adding package com.fasterxml.jackson.annotation
Adding package com.fasterxml.jackson.core
Filtering out redundant sub-packages
Adding package com.fasterxml.jackson.databind
Filtering out redundant sub-packages
Adding package com.fasterxml.jackson.jaxrs.annotation
Adding package com.fasterxml.jackson.jaxrs.base
Adding package com.fasterxml.jackson.jaxrs.cfg
Adding package com.fasterxml.jackson.jaxrs.json
Filtering out redundant sub-packages
Adding package com.fasterxml.jackson.jaxrs.util
Adding package com.fasterxml.jackson.module.jaxb
Filtering out redundant sub-packages
Adding package com.sun.research.ws.wadl
Adding package javassist
Filtering out redundant sub-packages
Adding package javax.annotation
Filtering out redundant sub-packages
Adding package javax.inject
Adding package javax.json
Filtering out redundant sub-packages
Adding package javax.validation
Filtering out redundant sub-packages
Adding package javax.ws.rs
Filtering out redundant sub-packages
Adding package jersey.repackaged.com.google.common.base
Adding package jersey.repackaged.com.google.common.cache
Adding package jersey.repackaged.com.google.common.collect
Adding package jersey.repackaged.com.google.common.hash
Adding package jersey.repackaged.com.google.common.io
Adding package jersey.repackaged.com.google.common.math
Adding package jersey.repackaged.com.google.common.net
Adding package jersey.repackaged.com.google.common.primitives
Adding package jersey.repackaged.com.google.common.util.concurrent
Adding package jersey.repackaged.org.objectweb.asm
Adding package org.aopalliance.aop
Adding package org.aopalliance.instrument
Adding package org.aopalliance.intercept
Adding package org.aopalliance.reflect
Adding package org.codehaus.jettison
Filtering out redundant sub-packages
Adding package org.eclipse.persistence
Filtering out redundant sub-packages
Adding package org.glassfish.hk2.api
Filtering out redundant sub-packages
Adding package org.glassfish.hk2.extension
Adding package org.glassfish.hk2.internal
Adding package org.glassfish.hk2.osgiresourcelocator
Adding package org.glassfish.hk2.utilities
Filtering out redundant sub-packages
Adding package org.glassfish.jersey
Filtering out redundant sub-packages
Adding package org.glassfish.json
Filtering out redundant sub-packages
Adding package org.jvnet.hk2.annotations
Adding package org.jvnet.hk2.component
Adding package org.jvnet.hk2.external.generator
Adding package org.jvnet.hk2.external.runtime
Adding package org.jvnet.hk2.internal
Adding package org.jvnet.mimepull
Adding package org.jvnet.tiger_types
Adding package org.objectweb.asm
Filtering out redundant sub-packages
Adding package org.objenesis
Filtering out redundant sub-packages
Output saved to /var/folders/y2/__zvkpb547zg92kgv6rx5m540000gn/T/tmp.F0I2TIEX




The actual usable output of this script is saved to a temporary file. The name of the file is displayed as the last message from the script before it exits.

Below is what a sample output file will look like:
 weblogic.xml
<package-name>com.esotericsoftware.kryo.*</package-name>
<package-name>com.esotericsoftware.minlog.*</package-name>
<package-name>com.esotericsoftware.reflectasm.*</package-name>
<package-name>com.fasterxml.jackson.annotation.*</package-name>
<package-name>com.fasterxml.jackson.core.*</package-name>
<package-name>com.fasterxml.jackson.databind.*</package-name>
<package-name>com.fasterxml.jackson.jaxrs.annotation.*</package-name>
<package-name>com.fasterxml.jackson.jaxrs.base.*</package-name>
<package-name>com.fasterxml.jackson.jaxrs.cfg.*</package-name>
<package-name>com.fasterxml.jackson.jaxrs.json.*</package-name>
<package-name>com.fasterxml.jackson.jaxrs.util.*</package-name>
<package-name>com.fasterxml.jackson.module.jaxb.*</package-name>
<package-name>com.sun.research.ws.wadl.*</package-name>
<package-name>javassist.*</package-name>
<package-name>javax.annotation.*</package-name>
<package-name>javax.inject.*</package-name>
<package-name>javax.json.*</package-name>
<package-name>javax.validation.*</package-name>
<package-name>javax.ws.rs.*</package-name>
<package-name>jersey.repackaged.com.google.common.base.*</package-name>
<package-name>jersey.repackaged.com.google.common.cache.*</package-name>
<package-name>jersey.repackaged.com.google.common.collect.*</package-name>
<package-name>jersey.repackaged.com.google.common.hash.*</package-name>
<package-name>jersey.repackaged.com.google.common.io.*</package-name>
<package-name>jersey.repackaged.com.google.common.math.*</package-name>
<package-name>jersey.repackaged.com.google.common.net.*</package-name>
<package-name>jersey.repackaged.com.google.common.primitives.*</package-name>
<package-name>jersey.repackaged.com.google.common.util.concurrent.*</package-name>
<package-name>jersey.repackaged.org.objectweb.asm.*</package-name>
<package-name>org.aopalliance.aop.*</package-name>
<package-name>org.aopalliance.instrument.*</package-name>
<package-name>org.aopalliance.intercept.*</package-name>
<package-name>org.aopalliance.reflect.*</package-name>
<package-name>org.codehaus.jettison.*</package-name>
<package-name>org.eclipse.persistence.*</package-name>
<package-name>org.glassfish.hk2.api.*</package-name>
<package-name>org.glassfish.hk2.extension.*</package-name>
<package-name>org.glassfish.hk2.internal.*</package-name>
<package-name>org.glassfish.hk2.osgiresourcelocator.*</package-name>
<package-name>org.glassfish.hk2.utilities.*</package-name>
<package-name>org.glassfish.jersey.*</package-name>
<package-name>org.glassfish.json.*</package-name>
<package-name>org.jvnet.hk2.annotations.*</package-name>
<package-name>org.jvnet.hk2.component.*</package-name>
<package-name>org.jvnet.hk2.external.generator.*</package-name>
<package-name>org.jvnet.hk2.external.runtime.*</package-name>
<package-name>org.jvnet.hk2.internal.*</package-name>
<package-name>org.jvnet.mimepull.*</package-name>
<package-name>org.jvnet.tiger_types.*</package-name>
<package-name>org.objectweb.asm.*</package-name>
<package-name>org.objenesis.*</package-name>


-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.