24 February 2015

The Sonatype team have announced the release of Nexus 2.1.1 which is a minor update that now works with the Oracle Maven Repository.

I was going to write a bit up about it but Manfred Moser from Sonatype has already put together a blog and video on it:

With the new Nexus 2.11.2 release we are supporting the authentication mechanism used for the Oracle Maven repository in both Nexus OSS and Nexus Pro.
This allows you to proxy the repository in Nexus and makes the
components discoverable via browsing the index as well as searching for
components.

You will only need to set this up once in Nexus and all your
projects. Developers and CI servers get access to the components and
the need for any manual work disappears. On the Nexus side, the configuration changes can be done easily as part of your upgrade to the new release.

Viewing the output of the mvn process and the running Artifactory server you can see that maven is downloading dependencies from http://localhost:8081/artifactory and correspondingly Artifactory is downloading the requested artifact from https://maven.oracle.com.

Once the maven process has completed and all the requested artifacts downloaded, Artifactory will have cached them locally for future use.

Using the Search functionality of the Artifactory Web UI you can search for weblogic artifacts.

Using the Repository Browser functionality of the Artifactory Web UI you can view and navigate around the contents of the remote Oracle Maven Repository.

Nice JFrog > Artifactory team - thanks for the quick support of our repository.

One further thing I'd look at doing is enabling the Configure Passwords Encryption option in the Security settings to encrypt your OTN password, so that it's not stored in cleartext in the etc/artifactory.config.latest.xml file.

09 February 2015

With the Oracle Maven Repository now accessible one way to have explore its contents is to use the Maven Repositories viewer feature available in most development tools. I've seen the repository contents displayed easily in NetBeans so I decided to take a look at what it looks like in Eclipse as well.

I had to make a few minor setting changes to get it to work so decided to document them here. If you've gotten it to work with less setting changes, let me know!

As initial setup, I configured my local maven environment to support access to the Oracle Maven Repository. This is documented here https://maven.oracle.com/doc.html. I also installed maven-3.2.5 that includes the updated Wagon module that supports authentication.

Next I downloaded and used the new network installer that the
Oracle Eclipse team has published on OTN to install the latest version of Oracle Enterprise Pack for Eclipse.

This network installer lets developers select
the version of Eclipse to install and the set of Oracle extensions -- Weblogic, GlassFish and other stuff -- to add in to it.

Once Eclipse is installed, you can add the Maven Repository viewer by selecting Window > Show View > Other > Maven Repositories from the Eclipse toolbar.

I also added a Console > Maven viewer to see what was happening under the covers and arranged them so they were visible at the same time:

With the Maven views ready to go, expand the Global Repositories node. This will show Maven Central (any other repositories you may have configured) and the Oracle Maven Repository if you have configured it correctly in the settings.xml file.

The initial state of the Oracle Maven Repository doesn't show any contents indicating that its index hasn't been downloaded to display.

Right mouse clicking on it and selecting the Rebuild Index option causes an error to be shown in the console output indicating that the index could not be accessed.

To get it to work, I made the following changes to my environment.

Configure Eclipse to Use Maven 3.2.5

Using the Eclipse > Preferences > Maven > Installation dialog, configure Eclipse to use Maven 3.2.5. This is preferred version of Maven to use to access the Oracle Maven Repository since it automatically includes the necessary version of the Wagon HTTP module that supports the required authentication configuration and request flow.

Configure Proxy Settings in Maven Settings File

** If you don't need a proxy to access the Internet then step won't be needed **
If you sit behind a firewall and need to use a proxy server to access public repositories then you need to configure a proxy setting inside the maven settings file.

Interestingly for command line maven use and NetBeans a single proxy configuration in settings.xml was enough to allow the Oracle Maven Repository to be successfully accesses and its index and artifacts used.

However with Eclipse, this setting alone didn't allow the Oracle Maven Repository to be accessed. Looking at the repository URL for the Oracle Maven Repository you can see ity's HTTPS based -- https://maven.oracle.com and it appears for Eclipse that a specific HTTPS based proxy setting is required for Eclipse to access HTTPS based repositories.

Rebuild Index Success

With the settings in place, the Rebuild Index operation succeeds and the contents of the Oracle Maven Repository are displayed in the repository viewer.

04 February 2015

The Arquillian project is proving to be very popular for testing code and applications. It's particularly useful for Java EE projects since it allows for in-container testing to be performed, enabling unit tests to use dependency injection and all the common services provided by the Java EE platform.

Arquillian uses the concept of container adapters to allow it to execute test code with a specific test environment. For the Java EE area, most of the Java EE implementations have an adapter than can be used to perform the deployment of the archive under test and to execute and report on the results of the unit tests.

These adapters utilize the WebLogic Server JMX API to perform their tasks and are the adapters used internally by the development teams when working with Arquillian. They have been tested to work with WebLogic Server [12.1.1, 12.1.2, 12.1.3]. We also have been using them internally with the 12.2.1 version under development to run the CDI TCK and other tests.

This example has the most basic configuration you can use to employ
Arquillian with a Maven project to deploy and execute tests using
WebLogic Server 12.1.3.

The README.md file in the project contains more details and a longer description. In summary though:

1. The first step is to add the Arquillian related dependencies in the Maven pom.xml:

2. The next step is to create an arquillian.xml file that the container adapter uses to connect to the remote server that is being used as the server to run the tests:

3. The last step is to create a unit test which is run with Arquillian. The unit test is responsible for implementing the @Deployment method which constructs an archive to deploy that contains the code to be tested. The unit test then provides @Test methods in which the deployment is tested to verify its behaviour:

Executing the unit tests, with the associated archive creation and deployment to the server is performed using the maven test goal:

The tests can be executed directly from IDEs such as NetBeans and Eclipse using the Run Test features:

03 February 2015

The inimitable Bruno Borges picked up tweet earlier today commenting on a problem using @Produces with non-CDI libraries with WebLogic Server 12.1.3.

The tweeter put his example up on a github repository to share - quite a nice example of using JAX-RS, CDI integration and of using Arquillian to verify it works correctly. Ticked a couple of boxes for what I've been looking at lately

Turns out that the issue was quite a simple and common one - a missing
reference to the jax-rs:2.0 shared-library that is needed to use JAX-RS
2.0 on WebLogic Server 12.1.3. Needs a weblogic.xml to reference that library.

02 February 2015

The WebLogic Server 12.1.3 EJB Developers Guide was recently updated to note that the embedded EJB container can be used by adding a reference to weblogic.jar to the CLASSPATH when the EJB client is being executed.

This is very convenient since it enables the WebLogic Server embedded EJB container to used by simply adding weblogic.jar to the classpath when running the client:

Or for example if you are developing unit tests using JUnit and running them from a maven project, you can configure the maven-surefire-plugin to use WebLogic Server to run the EJB test code in its embedded EJB container:

A fully working example of using this is available in this GitHub repository: