I worked with a team yesterday, and wanted to capture a simple datasource example with DB2 usage with WebSphere Liberty and using with DB2:
I spent some hours to figure out how to deploy my webapp to the Liberty from my Maven project.
I looked into the feature restConnector-1.0 . restConnector provides a REST based JMX MBeans interface to WebSphere Liberty. You add <feature>restConnector-1.0</feature> to your server, and make sure you have a user set in the admin role.
<administrator-role> <user>admin</user> </administrator-role>
You need to add write access for the administrator-role user. You’ll need to specify a relative path (use the Liberty Directory Locations) or use the absolute path (it’s a bit more complicated).
You can login and see the various APIs [ https://localhost:9443/IBMJMXConnectorREST/api ] or check the documentation [API1][API2][MBean] . You’ll want to check any upload with https://localhost:9443/IBMJMXConnectorREST/file/status
I used it with maven-antrun-plugin to execute against curl.
n</artifactId> <version>1.8</version> <executions> <execution> <id>upload-pre-integration</id > <phase>pre-integration-test</p hase> <goals> <goal>run</goal> </goals> <configuration> <target name="post-war-to-server" unless="maven.test.skip"> <!-- Remove War File from the Server --> <exec executable="curl"> <arg line="-u 'admin:dmin' -H 'Content-Type: application/war' -X DELETE 'https://localhost:9443/ IBMJMXConnectorREST/file/%24% 7Bserver.output.dir%7D% 2Fdropins%2Ftransformation. war?recursiveDelete=true' --insecure -v" /> </exec> <!-- Should check that this is a 204 --> <!-- Post the War file to the Server --> <!-- Expand the War file on the Server --> <exec executable="curl"> <arg line="-u 'admin:admin' -H 'Content-Type: application/war' -X POST 'https://localhost:9443/IBMJMXConnectorREST/file/%24%7Bserver.output.dir%7D%2Fdropins%2Ftransformation.war?expandOnCompletion=true' --data-binary '@target/example.war' --insecure -v" /> </exec> </target> </configuration> </execution> </executions> </plugin>
Execute maven with mvn clean integration-test package in order to trigger the deployment during the integration-test.
As many of you know, I have been working with JAX-RS and WebSphere Liberty for a few years now. Somehow, after this time has passed, I still seem to uncover new JAX-RS capabilities.
For those familiar with JAX-RS, you know it generates some funky errors. I wanted to control the data in the response. I started looking at Servlet Filters, however, by the time you get the response it’s fully committed. I started looking at JAX-RS filters and exception handlers. I found ExceptionMapper and ClientErrorException. The WebSphere Liberty documentation includes a good overview.
I implemented the ExceptionMapper
I hope you all find this useful. Thanks!
I have been working on a project with IIB (IBM Integration Bus). If you are like me, you want to automate all those pesky build tasks. In IIB, I needed to package and build my project (BAR).
I investigated scripting the build using the mqsipackagebar command . I noticed at the bottom a description of using it with ANT.
I’ve used ANT in a few projects (in combination with Maven). I took the script as a starting point, added the jar files and property files (based on configuring environments without IIB). I configured the maven-antrun-plugin in order to integrate within my parent project’s maven build.
Here is some sample code for you, I hope it helps you all get started:
Recently, I’ve been working with Swagger to document my team’s APIs, and had a mysterious entry popup (default/entity). It looks something like this:
I threw some tracing into action:
[6/7/16 7:51:24:912 EDT] 00000039 id= io.swagger.jaxrs.utils.
ReaderUtils < collectParameters Exit  [6/7/16 7:51:24:912 EDT] 00000039 id= io.swagger.jaxrs.utils. ReaderUtils < collectFieldParameters Exit  [6/7/16 7:51:24:912 EDT] 00000039 id= io.swagger.jaxrs.utils. ReflectionUtils > isOverriddenMethod Entry public javax.ws.rs.core.Response org.eclipse.persistence.jpa. rs.resources.MetadataResource. getMetadataCatalog(java.lang. String,java.lang.String,javax. ws.rs.core.HttpHeaders,javax. ws.rs.core.UriInfo) class org.eclipse.persistence.jpa. rs.resources.MetadataResource [6/7/16 7:51:24:912 EDT] 00000039 id= io.swagger.jaxrs.utils. ReflectionUtils > isOverriddenMethod Entry public javax.ws.rs.core.Response org.eclipse.persistence.jpa. rs.resources.MetadataResource. getMetadataCatalog(java.lang. String,java.lang.String,javax. ws.rs.core.HttpHeaders,javax. ws.rs.core.UriInfo) class org.eclipse.persistence.jpa. rs.resources.common. AbstractResource [6/7/16 7:51:24:912 EDT] 00000039 id= io.swagger.jaxrs.utils. ReflectionUtils > isOverriddenMethod Entry public javax.ws.rs.core.Response org.eclipse.persistence.jpa. rs.resources.MetadataResource. getMetadataCatalog(java.lang. String,java.lang.String,javax. ws.rs.core.HttpHeaders,javax. ws.rs.core.UriInfo)
I had too broad a dependency in my Maven pom.xml. I switched from eclipselink to org.eclipse.persistence.jpa.
The swagger entries disappeared from my swagger.yaml and it’s subsequent view. I hope this helps.
I’ve been building a Maven Project that uses some jar files which are not in Maven Central (or any repository). I ran across this article – Local Maven Dependencies. I found it very helpful.
Simply, do the following:
create a directory (d:/folder/repo)
Run a maven deploy to url (it’ll create the repository details based on the flags)
mvn deploy:deploy-file -Durl=file://d:/folder/repo/ -Dfile=Common.jar -DgroupId=xyz -DartifactId=Common -Dpackaging=jar -Dversion=1.0
and add to your Maven Project’s POM
Then reference your jar file with a new dependency.
The code should almost write itself from there 🙂
To setup ODBC bridge from IBM Integration Broker to DB2, download and install the ODBC bridge from the IBM Data Server Runtime Clients. It’s a 1.3 G download, and you only need about a 40M file for your system.
The installation is straight foward. Be prepared to click Next, and Finish.
Setup the ODBC bridge and IIB
Start > Run
- Type ODBC
- Click on Data Sources
- Click on Configure ODBC
Username db2admin Password fakepass! IP 188.8.131.52 Port 50000 Database name SAMPLE
call the alias as SAMPLE
- Launch a Command prompt
- Start > Run
- change directory to server\bin
- Launch iib
- C:\Program Files\IBM\IIB\10.0.0.4\server\
bin>mqsisetdbparms.exe TESTNODE_cheetah -n SAMPLE -u db2admin -p fakepass!
- BIP8071I: Successful command completion.
- TESTNODE_cheetah should be your local node in Eclipse.
- you’ll want to restart the Node (you can look in the lower right of your toolkit)
- Right Click the Node
- Then Start
To Read Data, the ESQL is easy:
- You can then send a message using the IIB tests , and confirm using your database db2 select * from DB2ADMIN.EMPLOYEE.
To Write Data:
- Repeat the project with the following:
- Create a New Input Message with
"EMPNO" : "2229",
"FIRSTNME" : "Paul",
"LASTNAME" : "B",
"JOB" : "PRES",
"EDLEVEL" : 18