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:
<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/SystemExceptionThis 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!
Nice!
ReplyDeleteAbout the docs, the Arquillian documentation is in Confluence - https://docs.jboss.org/author/display/ARQ/Reference+Guide.
The files at http://docs.jboss.org/arquillian/reference/latest/en-US/html/ are quite old, and neither are they the latest.
Thanks Vineet!
ReplyDeleteEspecially for the help along the way!!!
- M
Is there any way that i do not need to run an instance of weblogic?
ReplyDeleteThis comment has been removed by a blog administrator.
ReplyDeleteThis comment has been removed by the author.
Delete