Markus Eisele

About Markus Eisele

Markus is a Developer Advocate at Red Hat and focuses on JBoss Middleware. He is working with Java EE servers from different vendors since more than 14 years and talks about his favorite topics around Java EE on conferences all over the world. Follow him on Twitter @myfear.

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

Follow the steps in the getting started part of my first two posts. There are only a few things you have to change to get this working. Obviously you need a WebLogic 12c. Grep a copy from the OTN download-page. Read and accept the license and download either the ZIP installer or the full blown installer for your OS. Arun Gupta has a nice post about getting started with the ZIP installer. This basically is about downloading, extracting, configuring, creating your domain. Assume you have a domain1 in place. Make sure to copy the mysql-connector-java-5.1.6-bin.jar to domain1/lib and fire up the server by startWebLogic.cmd/.sh in your domain1 root directory. Next you need to configure the appropriate connection pool. You also could do this using some WLST magic or with the new WebLogic Maven Plugin but I assume you are doing this via the admin console. Go to Domain > Services > Data Sources and create a MySQL Datasource AuditLog with jndi name “jdbc/auditlog”. Make sure the server is running while you execute your tests!

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:


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

lt;container qualifier="wls" default="true">
            <property name="adminUrl">t3://localhost:7001</property>
            <property name="adminUserName">weblogic1</property>
            <property name="adminPassword">weblogic1</property>
            <property name="target">AdminServer</property>
            <property name="wlsHome">X:\path\to\wlserver\</property>

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:

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

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.
Download the project as a reference to get you started.
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:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

Leave a Reply

2 × nine =

Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below: