OpenLiberty JCA resource adapter and shared librabries - how? - jca

Is it possible to deploy a JCA resource adapter (rar) that references a shared library, inside the OpenLiberty server? What is the server.xml configuration snippet for this? I looked at the JCA docs for Liberty and found nothing on the topic...
My guess is something like this, but not sure:
<library id="mySharedLib">
<fileset dir="${server.config.dir}/odb" includes="*.jar" />
</library>
...
<resourceAdapter id="myrar" location="${server.config.dir}/jca/my.rar">
<properties.myrar conf="${server.output.dir}/jca/odb-server.xml"/>
<classloader commonLibraryRef="mySharedLib"/>
</resourceAdapter>

Here's link to the schema for resourceAdapter which shows you can use classloader with a commonLibraryRef as you described. Something like the following:
<library id="MyLib">
<fileset dir="/some/dir" includes="sharedlib.jar"/>
</library>
<resourceAdapter id="AdapterForMe" location="${server.config.dir}/connectors/RA.rar">
<classloader commonLibraryRef="MyLib"/>
</resourceAdapter>

Related

ATG RunAssembler does not package weblogic-application.xml

I am using ATG 11.1 with Weblogic 12c.
I have some configuration for inside /META-INF/weblogic-application.xml. For some reason runAssembler does not copy this xml over to the final ATG.ear in both in both standalone and non-standalone/development mode?
Also the runAssembler creats a jboss-app.xml inside the META-INF but not weblogic-application.xml
Thanks
Vivek
The weblogic-application.xml is not copied by the runAssembler script but rather generated. This means that if you want to modify the weblogic-application.xml you will need to do so after the runAssembler has completed. If you were using ant to do your builds you could implement something like this:
<macrodef name="enable-weblogic-appplication-setting">
<attribute name="earname" />
<sequential>
<available file="${ear.unpacked.dir}/${project.name}.ear/META-INF/weblogic-application.xml" property="weblogic-application.xml.found" />
<if>
<isset property="weblogic-application.xml.found" />
<then>
<replace file="${ear.unpacked.dir}/${project.name}.ear/META-INF/weblogic-application.xml">
<replacetoken>SomeStringThatWillAlwaysBeInTheFile</replacetoken>
<replacevalue>SomeStringThatWillAlwaysBeInTheFile plus TheNewValueYouWantToAdd</replacevalue>
</replace>
</then>
</if>
</sequential>
</macrodef>
I've been using this approach to dynamically update elements in the web.xml during the assembly process.
Alternatively, if you want to use your from source code weblogic-application.xml you can also use the ant script for <copy file='....' tofile='...' />.
As far as the weblogic-application.xml not being created by the runAssembler script, this is likely due to you not selecting the correct Application Server during the installation process of ATG.

Phing phpunit "plugin with stackIndex "1" already registered" error

For my Zend Framework (v1.12) project deployment Im using Phing. It deploys front-end and back-end applications. Everything goes fine, untill Phing starts phpunit testing:
<!-- Testing backend -->
<target name="backend-test" description="Testing backend system">
<phpunit codecoverage="false" haltonerror="true" haltonfailure="true" printsummary="true" bootstrap="${path.build}/${DSTAMP}${TSTAMP}/admin/tests/bootstrap.php">
<batchtest>
<fileset dir="${path.build}/${DSTAMP}${TSTAMP}/admin/tests">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter type="summary" usefile="false" />
</phpunit>
</target>
<!-- Testing frontend environment -->
<target name="site-test" description="Testing frontend system">
<phpunit codecoverage="false" haltonerror="true" haltonfailure="true" printsummary="true" bootstrap="${path.build}/${DSTAMP}${TSTAMP}/site/tests/bootstrap.php">
<batchtest>
<fileset dir="${path.build}/${DSTAMP}${TSTAMP}/site/tests">
<include name="**/*Test.php" />
</fileset>
</batchtest>
<formatter type="summary" usefile="false" />
</phpunit>
</target>
Back-end part phpunit tests succeed, but when it starts testing front-end - it fails it error:
[phingcall] Plugin with stackIndex "1" already registered
[phingcall] #0 /var/www/zend/Controller/Front.php(733): Zend_Controller_Plugin_Broker->registerPlugin(Object(Application_Plugin_ACL), 1)
[phingcall] #1 /var/www/_qa/build/201311181711/admin/application/Bootstrap.php(199): Zend_Controller_Front->registerPlugin(Object(Application_Plugin_ACL), 1).......
Any ideas? Your help would be appreciated.
Your bootstrap is being called twice (or at least the resource [_init function]).
You get this error because you can't define an other plugin instance for the same stack index.
You should try to find a way to mock all periferral classes loaded in your bootstrap and test each of these classes individually.
An other way would be to bootstrap your application in the phpUnit setup method and make sure it's destroyed in the teardown. This will be more ressource instensive and will most likely slow down your tests as the whole Zend stack will be instanciated, then killed, then re-instantiated for each of your test cases.

Getting an error "Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found."

I am getting an error Could not load definitions from resource net/sf/antcontrib/antcontrib.properties. It could not be found. when I am trying to ant build on eclipse. So I downloaded ant-contrib-0.6.jar and kept it in my /lib location of apache ant, but it still does not resolve my issue. I have also tried by specifying the /lib location in my CLASSPATH system variable. How can I get around this error?
You can provide full path to the ant-contrib JAR explicitly using "classpath" element:
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="${path-to-ant-contrib}/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
EDIT: Link contributed by Djacomo:
http://ant-contrib.sourceforge.net/
One important thing missing from this StackOverflow page is that setting the correct ANT_HOME env var is absolutely vital and important, without this setting ant keeps telling the same error, regardless of where you copy the ant-contrib-1.0b3.jar on your file systems. This missing thing has costed me a few hours. =)
However I receive this error without eclipse, in the pure ant.
I fixed that this way:
Add the JAR to the Ant runtime classpath entries.
Window>Preferences>Ant>Runtime>Classpath
Add the JAR to either Ant Home Entries or Global Entries.
It would appear that you haven't installed the ant contrib jar into the correct lib directory. This can be difficult to do if you have several installations of ANT.
My suggestion is to install your ANT plugins into the "$HOME/.ant/lib" directory. You could go one step further and automate the process as follows:
<project name="ant-contrib-tasks" default="all">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<target name="bootstrap">
<mkdir dir="${user.home}/.ant/lib"/>
<get dest="${user.home}/.ant/lib/ant-contrib.jar" src="http://search.maven.org/remotecontent?filepath=ant-contrib/ant-contrib/1.0b3/ant-contrib-1.0b3.jar"/>
</target>
<target name="all">
<for param="file">
<fileset dir="." includes="*.txt"/>
<sequential>
<echo message="Found file #{file}"/>
</sequential>
</for>
</target>
</project>
Use the below mentioned code in your build xml:
<path id="ant.classpath">
<pathelement location="${ant.jarPath}/ant.jar" />
<pathelement location="${ant.jarPath}/ant-contrib-0.3.jar" />
</path>
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath refid="ant.classpath" />
</taskdef>
And in your build property file:
ant.jarPath=D:/antjars
And place ant.jar and ant-contrib-0.3.jar in directory:D:/antjars
Check you have read permissions for the ant-contrib jar file.
In our case after copying the file with another user it did not, giving the same error message.

.war file won't be updated

I have an old project, built using Google Web Toolkit in Eclipse. When I created it, I did the following steps, in order to get the .war file
GWT Compile Project
Run the following Ant script
<project name="The" basedir="." default="default">
<target name="default" depends="buildwar,deploy"></target>
<target name="buildwar">
<war basedir="war" destfile="The.war" webxml="war/WEB-INF/web.xml">
<exclude name="WEB-INF/**" />
<webinf dir="war/WEB-INF/">
<include name="**/*.jar" />
</webinf>
</war>
</target>
<target name="deploy">
<copy file="The.war" todir="." />
</target>
</project>
Get the .war file
Now, I had to change a port in my project, so I changed it in my code and did the same steps in order to get the .war
However, when I deploy my updated project in Tomcat, it still makes requests to the old port number (I found this reading catalina.out)
So, What can I do in order to get a new, fresh .war ???
You don't mention it, but did you change the ports in tomcat? I assume you did, but I just want to cover all possibilities.

How to configure a Google Web Toolkit application with Datanucleus + PostgreSQL

I created an application using GWT and support for the Google Datastore but now i'm trying to move my application to my own server and i'm also trying to detach my app from Google App Engine and from Datastore.
To be more precise: I want to stop using Google Datastore and start using JDO and Datanucleus but with PostgreSQL (or other relational database). I tried searching in Datanucleus.org but there was no simple tutorial for me to use.
Please, can someone help me?
Thank you very much!
=)
I've discovered how to do it though I think it should be more easy eheheh.
Here it goes:
1) First we must setup PostgreSQL server;
2) Create our web application with webAppCreator (from GWT SDK);
3) Since we must enhance our domain classes for them to be used by datanucleus and JDO, we have multiple options to do it. I used an Apache Ant task ( from Google App Engine SDK). If we do this we can use the good parts from app engine (simple class enhancement) but our application won't be tied to the restrictions of App Engine.
The additions to the build.xml created with webAppCreator:
<!-- this refers to the location of my Google AppEngine SDK -->
<property name="sdk.dir" location="C:/Projects/appengine-java-sdk" />
<import file="${sdk.dir}/config/user/ant-macros.xml" />
<target name="copyjars"
description="Copies the App Engine JARs to the WAR.">
<copy
todir="war/WEB-INF/lib"
flatten="true">
<fileset dir="${sdk.dir}/lib/user">
<include name="**/*.jar" />
</fileset>
</copy>
</target>
<target name="compile" depends="copyjars"
description="Compiles Java source and copies other source files to the WAR.">
<mkdir dir="war/WEB-INF/classes" />
<copy todir="war/WEB-INF/classes">
<fileset dir="src">
<exclude name="**/*.java" />
</fileset>
</copy>
<javac
srcdir="src"
destdir="war/WEB-INF/classes"
classpathref="project.class.path"
debug="on" />
</target>
<target name="datanucleusenhance" depends="compile"
description="Performs JDO enhancement on compiled data classes.">
<enhance_war war="war" />
</target>
4) Download the PostgreSQL JDBC Driver from the official site;
5) Download the datanucleus-rdbms.jar file from the official sourceforge page;
6) Add these jars to the Project Classpath;
7) Create a file with the following content:
javax.jdo.PersistenceManagerFactoryClass=org.datanucleus.jdo.JDOPersistenceManagerFactory
javax.jdo.option.ConnectionDriverName=org.postgres.jdbc.Driver
javax.jdo.option.ConnectionURL=jdbc:postgres://localhost:5432/myschool
javax.jdo.option.ConnectionUserName=root
javax.jdo.option.ConnectionPassword=rootroot
datanucleus.autoCreateTables=true
8) Create a PersistenceManagerFactory like this:
File propsFile = new File("Insert the location of the properties file here");
PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory(propsFile);
9) Create the domain classes and run the new Ant Target datanucleusenhance;
10) This will create enhanced classes and the connection with the relational database and also store the information in the PostgreSQL's tables.
11) If I'm not mistaken and if I didn't forget anything than that's all :)
Thank you for reading the question.
Please, if you notice anything wrong, can you tell me? It's my first time here :P
==== Some References ====
http://code.google.com/intl/en/appengine/docs/java/tools/ant.html#Enhancing_JDO_Classes