Markus is a principal technology consultant working for msg systems ag in Germany. Markus is a software architect, developer and consultant. He also writes for IT magazines. Markus is speaking at different conferences about his favorite topics. He is also part of the Java EE 7 expert group.

Arquillian with NetBeans, WebLogic 12c, JPA and a MySQL Datasource

You probably followed my posts about testing more complex scenarios with embedded GlassFish (Part I / Part II).

Next on my list of things to do was to get this setup working with latest WebLogic 12c.

Getting Started

Modifying the sampleweb Project
Now open the sampleweb project’s pom.xml and remove the glassfish-embedded-all dependency together with the arquillian-glassfish-embedded-3.1 and the javaee-api. Now add the wls-remote-12.1 container and the jboss-javaee-6.0 dependencies:

<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-wls-remote-12.1</artifactId>
<version>1.0.0.Alpha2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>


Now open your arquillian.xml descriptor and change the container settings to use the wls container:

lt;container qualifier="wls" default="true">
<configuration>
<property name="wlsHome">X:\path\to\wlserver\</property>
</configuration>


Make sure to use the right target server and point to the correct wlsHome. Right-click the AuditRepositoryServiceTest in NetBeans and run “Test File”. You will see the remote container doing some work:

22.01.2012 22:40:34 org.jboss.arquillian.container.wls.WebLogicDeployerClient deploy
INFO: Starting weblogic.Deployer to deploy the test artifact.
22.01.2012 22:40:46 org.jboss.arquillian.container.wls.WebLogicDeployerClient forkWebLogicDeployer
INFO: weblogic.Deployer appears to have terminated successfully.
22.01.2012 22:40:53 org.jboss.arquillian.container.wls.WebLogicDeployerClient undeploy
INFO: Starting weblogic.Deployer to undeploy the test artifact.
22.01.2012 22:41:00 org.jboss.arquillian.container.wls.WebLogicDeployerClient forkWebLogicDeployer
INFO: weblogic.Deployer appears to have terminated successfully.

And the test going green! If you look at the domain log, you can see, that the test.war module is successfully deployed and undeployed.

Remarks and Thoughts
Looking at what we have with WebLogic 12c (especially the new maven plugin) this all seems very hand-crafted. What would a WebLogic developer have done prior to that in a maven based project? He would have pushed the weblogic.jar to his local repository and use it instead of using any jboss-javaee-6.0 or javaee-api dependencies. If you try this with the Arquillian wls container you start seeing some weird exceptions like the following:

Exception in thread “main” java.lang.ClassFormatError: Absent Code
attribute in method that is not native or abstract in class file
javax/transaction/SystemException

This is basically because only the wlfullclient.jar contains all needed classes for remote management via JMX. The magic weblogic.jar does have some additional class-path entries in it’s manifest which could not be resolved if you put it to your local m2 repository. So you simply have two options left. Use the wlfullclient.jar (see how to build it in the docs) for testing and the weblogic.jar for your development or stick to the jboss-javaee-6.0 dependency for development and testing (scope provided). Both are valid alternatives. As you can see, the WebLogic container is still undocumented in the Arquillian documentation. You can find a more detailed documentation looking at the wls-container project on github.
Thanks to Vineet and Aslak for the help!

Reference: Arquillian with NetBeans, WebLogic 12c, JPA and a MySQL Datasource from our JCG partner Markus Eisele at the Enterprise Software Development with Java  blog.

Related Whitepaper:

Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications

Java Platform, Enterprise Edition is a widely used platform for enterprise server programming in the Java programming language.

This book covers exciting recipes on securing, tuning and extending enterprise applications using a Java EE 6 implementation.The book starts with the essential changes in Java EE 6. Then they will dive into the implementation of some of the new features of the JPA 2.0 specification, and look at implementing auditing for relational data stores.They will then look into how they can enable security for their software system using Java EE built-in features as well as using the well-known Spring Security framework. They will then look at recipes on testing various Java EE technologies including JPA, EJB, JSF, and Web services.Next they will explore various ways to extend a Java EE environment with the use of additional dynamic languages as well as frameworks.At the end of the book, they will cover managing enterprise application deployment and configuration, and recipes that will help you debug problems and enhance the performance of your applications.

Share and enjoy!