WebLogic client jar
Asked Answered
P

2

6

I want to use Java with JMX to monitor WebLogic. I need to use wlclient.jar which is provided into WebLogic lib directory.

Is there any maven repository which I can use to download the wlclient.jar? The only way that I found is to manually import the jar file into my repository but this is not a option for me.

Photoengraving answered 15/12, 2015 at 12:23 Comment(1)
I never used it, but you could give the oracle maven repo a try: blogs.oracle.com/WebLogicServer/entry/…Auklet
A
5

Another alternative is to create an in-project repository. This makes your project truly portable. This method is similar to the 'Use Dependency with system scope' mentioned by A. Di Matteo, except that it has the added benefit of being able to use any scope (and not just 'system').

I had the same issue as you, using a jar which was not available in Maven Central and after exploring all of the possible options, I settled on the in-project repository which I believe is better that system-scoping a dependency since it frees you to choose the scope.

Steps to do this:

  1. Create a sub-directory called 'lib' in your project

  2. Add this lib as a repository in your pom

<repositories>
    <repository>
        <id>lib</id>
        <name>In Project Repo</name>
        <url>file://${basedir}/lib</url>
    </repository>
</repositories>
  1. Install the artefact to your lib directory:

mvn install:install-file -Dfile=myArtifact.jar -DgroupId=x.y.z -DartifactId=${artifactId} -Dversion=${version} -Dpackaging=jar -DgeneratePom=true

  1. And, finally use the dependency like you would use any other dependency
<dependencies>
    ....
    <dependency>
        <groupId>x.y.z</groupId>
        <artifactId>${artifactId}</artifactId>
        <version>${version}</version>
    </dependency>
</dependencies>
Autum answered 15/12, 2015 at 15:7 Comment(1)
Nice approach. I would improve it moving the install:install-file step in the POM, in a profile which would be activated only if the file is missing from the repository and if the case it will run in the validate phase the install-file goal. As such, everything will be automated and even more portable.Cropeared
C
3

If you can't find the jar in any Maven repository, you could apply any of the following actions, depending on your needs:

Internal Maven Repository
If you don't have an internal repository (like Artifactory or Nexus), normally used in companies as internal maven cache/proxy/point-of-control, but could also be an option to install it and run it locally.
You could then upload the library there, providing Maven GAV (GroupId, ArtifactId, Version) and make Maven pointing to it as a repository (for your, for your CI server if any, for your colleagues if any). You can then add the library as standard maven dependency. This solution has longer set-up, but better maintainability.

Install the library in local cache
You could use the Maven Install Plugin and install the library to your local cache, as shown by this official example.
Basically, you could run the following command:

mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=path-to\wlclient.jar -DgroupId=weblogic -DartifactId=wlclient -Dversion=1.0.0 -Dpackaging=jar

It will copy the library to your local Maven cache with standard Maven GAV. However, as above, you should make sure to replicate the same set up on any CI server and any team mate machine as well. You can then add the library as standard maven dependency. This solution has quicker set-up, but lower maintainability though.

Both solutions however affect the portability of your build (build would fail if someone tries to build it outside of your company network or team).

Use dependency with system scope
You can have the jar as part of your project and point at it via the system scope for that dependency.

<dependency>
  <groupId>weblogic</groupId>
  <artifactId>wlclient</artifactId>
  <version>1.0.0</version>
  <systemPath>${basedir}/path/to/library/wlclient-1.0.0.jar</systemPath>
  <scope>system</scope>
</dependency>

You should rename the jar though in order to be compliant with Maven conventions.
This solution is more portable, requires much less set-up, but again it needs to be maintained and requires a check-in of the concerned library as part of your versioned project (some may strongly disagree on this practice).

Cropeared answered 15/12, 2015 at 12:45 Comment(2)
Do you know is there any maven public repository with already published wlclient.jar?Photoengraving
couldn't find any, except the one Slettal suggested, but apparently (according to comments to that post) is not as easy as it should be to use.Cropeared

© 2022 - 2024 — McMap. All rights reserved.