Home » Java » Enterprise Java » Arquillian with NetBeans, WebLogic 12c, JPA and a MySQL Datasource

About Markus Eisele

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. He has been a principle consultant and worked with different customers on all kinds of Java EE related applications and solutions. Beside that he has always been a prolific blogger, writer and tech editor for different Java EE related books. He is an active member of the German DOAG e.V. and it's representative on the iJUG e.V. As a Java Champion and former ACE Director he is well known in the community. 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:

<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="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>
        </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:

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
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.
Download the simpleweb-wls.zip 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.

Do you want to know how to develop your skillset to become a Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

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

1. JPA Mini Book

2. JVM Troubleshooting Guide

3. JUnit Tutorial for Unit Testing

4. Java Annotations Tutorial

5. Java Interview Questions

6. Spring Interview Questions

7. Android UI Design

and many more ....

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*


Want to take your Java Skills to the next level?
Grab our programming books for FREE!
  • Save time by leveraging our field-tested solutions to common problems.
  • The books cover a wide range of topics, from JPA and JUnit, to JMeter and Android.
  • Each book comes as a standalone guide (with source code provided), so that you use it as reference.
Last Step ...

Where should we send the free eBooks?

Good Work!
To download the books, please verify your email address by following the instructions found on the email we just sent you.