JAXB xjc class generation - recursive element/namespace collisions - jaxb

I'm trying to generate classes for the ECMA-376 v5 schemas, but can't fix a collision of two elements via bindings customization, i.e. it will throw an [ERROR] Two declarations cause a collision in the ObjectFactory class error.
To try it yourself, just put the below ant build and the bindings file in a directory and call "ant" to setup and generate the classes.
If you uncomment the "Fixme" line in the ooxml.xjb, the generation will succeed, but looking at the src/org/openxmlformats/schemas/wordprocessingml/_2006/main/ObjectFactory.java you'll find the "Fixme" element is generated differently and probably doesn't make sense. So maybe use it just as a hint for your fix.
I guess the error is caused by the multiple "r" elements/references in ...:
wml.xsd->CT_RunTrackChange->EG_ContentRunContent->r
wml.xsd->CT_RunTrackChange->shared-math.xsd->EG_OMathMathElements->r
shared-math.xsd->EG_OMathElements->EG_OMathMathElements->r
shared-math.xsd->EG_OMathElements->wml.xsd->EG_PContentMath->EG_ContentRunContentBase->EG_RunLevelElts->EG_MathContent->shared-math.xsd->oMath->CT_OMath->EG_OMathElements... (see 3/4)
Although there are references on SO, that -XautoNameResolution would help, this seems to be futile in my case.
If nothing helps, I probably will search/replace the fixme tokens after generation, but I guess the correct binding instructions are not far away ...
In case you wonder why I use Moxy. This is a prototype for Apache POI and Moxy is suitable for android-conversion and license compatible - in any case I aim for a solution which preserves the XML infoset.
build.xml:
<project name="ECMA v5 xjc" default="doit" basedir=".">
<!-- the repository to download jars from -->
<property name="repository.m2" value="https://repo1.maven.org"/>
<property name="jaxb-dir" location="lib"/>
<property name="dist.jaxb-xjc.url" value="${repository.m2}/maven2/com/sun/xml/bind/jaxb-xjc/2.3.0/jaxb-xjc-2.3.0.jar"/>
<property name="dist.jaxb-xjc.jar" value="${jaxb-dir}/jaxb-xjc-2.3.0.jar"/>
<property name="dist.jaxb-core.url" value="${repository.m2}/maven2/com/sun/xml/bind/jaxb-core/2.3.0/jaxb-core-2.3.0.jar"/>
<property name="dist.jaxb-core.jar" value="${jaxb-dir}/jaxb-core-2.3.0.jar"/>
<property name="dist.jaxb-api.url" value="${repository.m2}/maven2/javax/xml/bind/jaxb-api/2.3.0/jaxb-api-2.3.0.jar"/>
<property name="dist.jaxb-api.jar" value="${jaxb-dir}/api/jaxb-api-2.3.0.jar"/>
<property name="dist.eclipselink.url" value="${repository.m2}/maven2/org/eclipse/persistence/eclipselink/2.7.0/eclipselink-2.7.0.jar"/>
<property name="dist.eclipselink.jar" value="${jaxb-dir}/eclipselink-2.7.0.jar"/>
<property name="dist.moxy.url" value="${repository.m2}/maven2/org/eclipse/persistence/org.eclipse.persistence.moxy/2.7.0/org.eclipse.persistence.moxy-2.7.0.jar"/>
<property name="dist.moxy.jar" value="${jaxb-dir}/org.eclipse.persistence.moxy-2.7.0.jar"/>
<property name="dist.ooxml_v5.url" value="https://www.ecma-international.org/publications/files/ECMA-ST/ECMA-376,%20Fifth%20Edition,%20Part%204%20-%20Transitional%20Migration%20Features.zip"/>
<property name="dist.ooxml_v5.jar" value="${jaxb-dir}/ooxml_v5-all.zip"/>
<property name="dist.xmlxsd.url" value="http://www.w3.org/2001/03/xml.xsd"/>
<property name="dist.xmlxsd.xsd" value="${jaxb-dir}/xml.xsd"/>
<macrodef name="downloadfile">
<attribute name="src"/>
<attribute name="dest"/>
<sequential>
<get src="#{src}" dest="#{dest}" skipexisting="true"/>
</sequential>
</macrodef>
<target name="doit">
<mkdir dir="src"/>
<mkdir dir="${jaxb-dir}/api"/>
<mkdir dir="${jaxb-dir}/ooxml_v5"/>
<mkdir dir="${jaxb-dir}/episodes_v5"/>
<downloadfile src="${dist.jaxb-xjc.url}" dest="${dist.jaxb-xjc.jar}"/>
<downloadfile src="${dist.jaxb-core.url}" dest="${dist.jaxb-core.jar}"/>
<downloadfile src="${dist.jaxb-api.url}" dest="${dist.jaxb-api.jar}"/>
<downloadfile src="${dist.eclipselink.url}" dest="${dist.eclipselink.jar}"/>
<downloadfile src="${dist.moxy.url}" dest="${dist.moxy.jar}"/>
<downloadfile src="${dist.ooxml_v5.url}" dest="${dist.ooxml_v5.jar}"/>
<downloadfile src="${dist.xmlxsd.url}" dest="${dist.xmlxsd.xsd}"/>
<unzip dest="${jaxb-dir}" src="${dist.ooxml_v5.jar}">
<patternset>
<include name="OfficeOpenXML-XMLSchema-Transitional.zip"/>
</patternset>
<mergemapper to="ooxml_v5.zip"/>
</unzip>
<unzip dest="${jaxb-dir}/ooxml_v5" src="${jaxb-dir}/ooxml_v5.zip"/>
<!-- the DOCTYPE is causing problems with generating the schema classes -->
<copy tofile="${dist.xmlxsd.xsd}.edit" file="${dist.xmlxsd.xsd}">
<filterchain>
<linecontains negate="true">
<contains value="DOCTYPE"/>
</linecontains>
</filterchain>
</copy>
<move file="${dist.xmlxsd.xsd}.edit" tofile="${dist.xmlxsd.xsd}"/>
<java fork="true" classname="org.eclipse.persistence.jaxb.xjc.MOXyXJC">
<classpath>
<fileset dir="${jaxb-dir}" includes="*.jar"/>
</classpath>
<jvmarg value="-Djava.endorsed.dirs=${jaxb-dir}/api"/>
<!-- auto resolution is ignored ... -->
<arg value="-XautoNameResolution"/>
<arg value="-no-header"/>
<arg value="-extension"/>
<!--arg value="-verbose"/-->
<arg line="-episode ${jaxb-dir}/episodes_v5/step1.episodes"/>
<arg line="-b ooxml.xjb"/>
<arg line="-d src"/>
<arg value="${dist.xmlxsd.xsd}"/>
<arg value="${jaxb-dir}/ooxml_v5/shared-math.xsd"/>
<arg value="${jaxb-dir}/ooxml_v5/dml-main.xsd"/>
</java>
</target>
</project>
ooxml.xjb:
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<bindings version="2.1"
xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
xmlns:math="http://schemas.openxmlformats.org/officeDocument/2006/math"
extensionBindingPrefixes="xjc">
<globalBindings generateIsSetMethod="true"/>
<bindings scd="x-schema::tns" xmlns:tns="http://schemas.openxmlformats.org/officeDocument/2006/math">
<bindings scd="~tns:CT_R/model::sequence">
<bindings scd="tns:rPr">
<factoryMethod name="rPrMath"/>
</bindings>
<bindings scd="model::choice/tns:t">
<factoryMethod name="tMath"/>
</bindings>
</bindings>
<!--bindings scd="group::math:EG_OMathMathElements/model::choice/math:r">
<property name="rMath1"/>
</bindings-->
</bindings>
<bindings scd="x-schema::tns" xmlns:tns="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing">
<bindings scd="~tns:CT_Anchor/model::sequence/tns:simplePos">
<property name="simplePosList"/>
</bindings>
</bindings>
<bindings scd="x-schema::tns" xmlns:tns="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
<!--bindings scd="~tns:CT_RunTrackChange/model::choice/group::math:EG_OMathMathElements/model::choice/math:r">
<class name="CTR" implClass="org.openxmlformats.schemas.officedocument._2006.math.CTR"/>
</bindings-->
<bindings scd="~tns:CT_RunTrackChange/model::choice/group::tns:EG_ContentRunContent/model::choice/tns:r">
<!--class name="FixmeR"/-->
</bindings>
</bindings>
</bindings>

Related

Spring Integration Kafka Configuration - Errors in Eclipse

I am using Eclipse as the IDE. I have a very basic config XML file that does not validate and hence prevents Eclipse from running anything. What am I missing?
Here's the validation errors (I see the in problems view):
Here's my config xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-kafka="http://www.springframework.org/schema/integration/kafka"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/integration/kafka http://www.springframework.org/schema/integration/kafka/spring-integration-kafka.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd">
<int:channel id="inputToKafka" />
<int-kafka:outbound-channel-adapter
id="kafkaOutboundChannelAdapter" kafka-template="template"
auto-startup="false" channel="inputToKafka" topic="replicated-topic-1"
message-key-expression="'bar'" partition-id-expression="2">
</int-kafka:outbound-channel-adapter>
<bean id="template" class="org.springframework.kafka.core.KafkaTemplate">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="192.168.33.21:9092,192.168.33.22:9092,192.168.33.23:9092" />
</map>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<int-kafka:message-driven-channel-adapter
id="kafkaListener"
listener-container="listenerContainer"
auto-startup="false"
phase="100"
send-timeout="5000"
channel="nullChannel"
error-channel="errorChannel" />
<bean id="listenerContainer" class="org.springframework.kafka.listener.KafkaMessageListenerContainer">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="192.168.33.21:9092,192.168.33.22:9092,192.168.33.23:9092" />
</map>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg name="topics" value="replicated-topic-1" />
</bean>
</beans>
If these are just bogus errors and the app runs ok, it simply means you are resolving to the online version of the spring-integration-core schema here. See the IMPORTANT note at the top of that schema as to why it is not the current version.
You can resolve that by using a spring-aware eclipse (e.g. STS or the Spring IDE plugin) and set spring nature on the project so the schema is resolved properly, from the class path, instead of the internet.
Or you can go to the XML Catalog in eclipse preferences and configure the schema mapping to properly point to the 4.3 version of the schema.
If it's truly a runtime problem (app won't run), then it means you have an incorrect version of spring-integration-core on the classpath - you should use maven or gradle to pull in the correct version transitively. If you are manually building the project class path, you need spring-integration-core version 4.3.2 or later (current version is 4.3.4).

Cannot persist data in Cassandra using Kundera

I tried to connect to cassadra and perform CRUD operation from this link. But after executing the code got the below exception.Can't figure out the problem.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Jun 29, 2015 2:47:00 PM com.impetus.client.cassandra.config.CassandraPropertyReader onProperties
WARNING: No property file found in class path, kundera will use default property
Jun 29, 2015 2:47:01 PM com.impetus.kundera.persistence.EntityManagerFactoryImpl <init>
INFO: EntityManagerFactory created for persistence unit : kundera
Exception in thread "main" com.impetus.kundera.KunderaException: org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException: Failed to get a connection within the configured max wait time.
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:208)
at kundera.KunderaClient.main(KunderaClient.java:22)
Caused by: org.scale7.cassandra.pelops.exceptions.NoConnectionsAvailableException: Failed to get a connection within the configured max wait time.
at org.scale7.cassandra.pelops.pool.CommonsBackedPool.getConnectionExcept(CommonsBackedPool.java:345)
at org.scale7.cassandra.pelops.Operand.tryOperation(Operand.java:77)
at org.scale7.cassandra.pelops.Mutator.execute(Mutator.java:93)
at org.scale7.cassandra.pelops.Mutator.execute(Mutator.java:63)
at com.impetus.client.cassandra.pelops.PelopsClient.onPersist(PelopsClient.java:527)
at com.impetus.kundera.client.ClientBase.persist(ClientBase.java:83)
at com.impetus.kundera.lifecycle.states.ManagedState.handleFlush(ManagedState.java:193)
at com.impetus.kundera.graph.Node.flush(Node.java:525)
at com.impetus.kundera.persistence.PersistenceDelegator.flush(PersistenceDelegator.java:411)
at com.impetus.kundera.persistence.PersistenceDelegator.persist(PersistenceDelegator.java:169)
at com.impetus.kundera.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:202)
... 1 more
However, I can perform crud operation from cqlsh.
Below is my persistence.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="kundera">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>kundera.Catalog</class>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9042" />
<property name="kundera.username" value="cassandra" />
<property name="kundera.passsword" value="cassandra" />
<property name="kundera.keyspace" value="Kundera" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
<property name="kundera.cache.provider.class"
value="com.impetus.kundera.cache.ehcache.EhCacheProvider" />
<property name="kundera.cache.config.resource" value="/ehcache-test.xml" />
</properties>
</persistence-unit>
</persistence>
I tried changing kundera.port to 9160. But got the same exception.
Is your Cassandra server enabled for authentication ? Which version of kundera-cassandra are you using ?
Also, can you please update your persistence.xml and try with :
<persistence-unit name="kundera">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>kundera.Catalog</class>
<properties>
<property name="kundera.nodes" value="localhost" />
<property name="kundera.port" value="9160" />
<property name="kundera.username" value="cassandra" />
<property name="kundera.passsword" value="cassandra" />
<property name="kundera.keyspace" value="Kundera" />
<property name="kundera.dialect" value="cassandra" />
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
</properties>
</persistence-unit>
9042 port is for cql3 binary protocol enabled clients but not the thrift clients. Change,
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.pelops.PelopsClientFactory" />
TO
<property name="kundera.client.lookup.class"
value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
it should work for you.
HTH,
-Vivek

ImageMagick identify.exe returns nothing in parallel Apache Ant project

I use Apache Ant project to gather some information about textures. Here you can see a test project that does only reading without any further actions. This is a minimal set that reproduces one nasty bug. I have found that sometimes ImageMagick's identify.exe does not return anything – I've added a code that forces build to fail if so. If I run this project multiple times I will get unstable behavior. Sometimes project build successfully, sometimes it fails with several fail-messages. Developers of ImageMagick say that their tools are thread safe. But if identify.exe is not the case then what can be? I really need help of someone with advance knowledge about Apache Ant and ImageMagick.
<project default="default">
<taskdef resource="net/sf/antcontrib/antlib.xml"/>
<property name="image_magick_path" location="c:\Program Files\ImageMagick-6.8.9-Q8\"/>
<property name="images_path" location="path\to\folder\with\png\images"/>
<target name="default">
<for param="item" parallel="true">
<path>
<fileset dir="${images_path}">
<patternset id="pattern_images">
<include name="**\*.png"/>
<include name="**\*.jpg"/>
<include name="**\*.gif"/>
<include name="**\*.bmp"/>
</patternset>
</fileset>
</path>
<sequential>
<local name="image_width"/>
<tex_width file="#{item}" property="image_width"/>
<local name="image_height"/>
<tex_width file="#{item}" property="image_height"/>
<if>
<or>
<equals arg1="${image_width}" arg2=""/>
<equals arg1="${image_height}" arg2=""/>
</or>
<then>
<fail message="Got nothing. But why? Image: #{item}"/>
</then>
</if>
</sequential>
</for>
</target>
<macrodef name="tex_width">
<attribute name="file"/>
<attribute name="property"/>
<sequential>
<exec executable="${image_magick_path}\identify.exe" outputproperty="#{property}">
<arg value="-format"/>
<arg value="%w"/>
<arg value="#{file}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="tex_height">
<attribute name="file"/>
<attribute name="property"/>
<sequential>
<exec executable="${image_magick_path}\identify.exe" outputproperty="#{property}">
<arg value="-format"/>
<arg value="%h"/>
<arg value="#{file}"/>
</exec>
</sequential>
</macrodef>
</project>
Ok, I will write here how I managed to solve my problem. I hope it will help someone someday.
First thing I found is that PHP method 'getimagesize' is much faster so I decided to switch to it thus killing the main problem. I wrote following macrodef to get both image width and height:
<macrodef name="getimagesize">
<attribute name="file"/>
<attribute name="propertywidth"/>
<attribute name="propertyheight"/>
<sequential>
<local name="output"/>
<exec executable="php" outputproperty="output">
<arg value="-r"/>
<arg value=
""$size=getimagesize('#{file}');
echo($size[0].' '.$size[1]);""
/>
</exec>
<propertyregex
property="#{propertywidth}"
input="${output}"
regexp="(\d*) (\d*)"
replace="\1"
/>
<propertyregex
property="#{propertyheight}"
input="${output}"
regexp="(\d*) (\d*)"
replace="\2"
/>
</sequential>
</macrodef>
Unfortunately this macrodef has abosutely same bug. Sometimes during parallel run some exec-tasks returned nothing in output. I was very upset so I decided to write another macrodef which I use now and finally it works fine. What I did was avoid reading anything from exec-task's 'stdout' and use tempfile-task instead. Here's final macrodef:
<macrodef name="getimagesize">
<attribute name="file"/>
<attribute name="propertywidth"/>
<attribute name="propertyheight"/>
<sequential>
<local name="file_dirname"/>
<dirname property="file_dirname" file="#{file}"/>
<local name="file_temp"/>
<tempfile property="file_temp" destdir="${file_dirname}" createfile="true"/>
<exec executable="php">
<arg value="-r"/>
<arg value=""$size=getimagesize('#{file}');
file_put_contents('${file_temp}', $size[0].' '.$size[1]);""/>
</exec>
<local name="file_temp_content"/>
<loadfile property="file_temp_content" srcfile="${file_temp}"/>
<delete file="${file_temp}"/>
<propertyregex
property="#{propertywidth}"
input="${file_temp_content}"
regexp="(\d*) (\d*)"
replace="\1"
/>
<propertyregex
property="#{propertyheight}"
input="${file_temp_content}"
regexp="(\d*) (\d*)"
replace="\2"
/>
</sequential>
</macrodef>

Giving Persistence Database setting on first deploy of JSF application

I have developed a JSF application with JPA using Netbeans and GlassFish. It is working fine within the Netbeans environment. Now I want to deploy it a remote GlassFish server with different database settings. Is there any method I can give the database settings when it is deployed in the server for the first time and save the settings afterwords?
I have a persistence.xml file, but the database settings are there in glassfish-resources.xml file.
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="HOPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>dsHiLap2</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.ddl-generation" value="create-tables"/>
</properties>
</persistence-unit>
glassfish-resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE resources PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Resource Definitions//EN" "http://glassfish.org/dtds/glassfish-resources_1_5.dtd">
<resources>
<jdbc-resource enabled="true" jndi-name="jdbc/ho" object-type="user" pool-name="connectionPoolHo">
<description/>
</jdbc-resource>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="connectionPoolHo" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="URL" value="jdbc:derby://localhost:1527/healthofice"/>
<property name="serverName" value="localhost"/>
<property name="PortNumber" value="1527"/>
<property name="DatabaseName" value="healthofice"/>
<property name="User" value="healthoffice"/>
<property name="Password" value="health"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="dsDec2012" object-type="user" pool-name="connectionPoolHo"/>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="derby_net_ho_hoPool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="1527"/>
<property name="databaseName" value="ho"/>
<property name="User" value="ho"/>
<property name="Password" value="ho"/>
<property name="URL" value="jdbc:derby://localhost:1527/ho"/>
<property name="driverClass" value="org.apache.derby.jdbc.ClientDriver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="dsHo" object-type="user" pool-name="derby_net_ho_hoPool"/>
<jdbc-resource enabled="true" jndi-name="ds2013Feb" object-type="user" pool-name="connectionPoolHo"/>
<jdbc-resource enabled="true" jndi-name="drHoBuddhikaDesktop1" object-type="user" pool-name="derby_net_ho_hoPool"/>
<jdbc-resource enabled="true" jndi-name="drHoBuddhikaLaptop1" object-type="user" pool-name="connectionPoolHo"/>
<jdbc-resource enabled="true" jndi-name="dsHiLap" object-type="user" pool-name="derby_net_ho_hoPool"/>
<jdbc-connection-pool allow-non-component-callers="false" associate-with-thread="false" connection-creation-retry-attempts="0" connection-creation-retry-interval-in-seconds="10" connection-leak-reclaim="false" connection-leak-timeout-in-seconds="0" connection-validation-method="auto-commit" datasource-classname="org.apache.derby.jdbc.ClientDataSource" fail-all-connections="false" idle-timeout-in-seconds="300" is-connection-validation-required="false" is-isolation-level-guaranteed="true" lazy-connection-association="false" lazy-connection-enlistment="false" match-connections="false" max-connection-usage-count="0" max-pool-size="32" max-wait-time-in-millis="60000" name="derby_net_ho1_ho1Pool" non-transactional-connections="false" pool-resize-quantity="2" res-type="javax.sql.DataSource" statement-timeout-in-seconds="-1" steady-pool-size="8" validate-atmost-once-period-in-seconds="0" wrap-jdbc-objects="false">
<property name="serverName" value="localhost"/>
<property name="portNumber" value="1527"/>
<property name="databaseName" value="ho1"/>
<property name="User" value="ho1"/>
<property name="Password" value="ho1"/>
<property name="URL" value="jdbc:derby://localhost:1527/ho1"/>
<property name="driverClass" value="org.apache.derby.jdbc.ClientDriver"/>
</jdbc-connection-pool>
<jdbc-resource enabled="true" jndi-name="dsHiLap2" object-type="user" pool-name="derby_net_ho1_ho1Pool"/>
</resources>
You need to use GlassFish deployment plan to configure different connection pool settings for your remote GlassFish server, since glassfish-resources.xml defined application-scoped resources. The application-scoped connection pool is only created during the application deployment. Please see To Deploy an Application or Module by Using a Deployment Plan. Basically your supply a remote server version of glassfish-resources.xml (following module-name.gf-dd-name naming convention) in the deploymentplan.jar.
Another option is not to use the application-scoped resource. You can define the connection pool/data source through the GlassFish Admin console.

Not able to see the FxCop Report embeded in the Email using CruiseControl.Net

I have installed Cruise Control 1.5 on my machine and trying to configure the automated build. Everything is working fine. Application is building, i receive an email but I don't see the FXCop result embedded in the Build Email. What am i missing?
ccnet.config file
<cruisecontrol xmlns:cb="urn:ccnet.config.builder">
<project name="SampleProject">
<webURL>http://localhost/ccnet</webURL>
<workingDirectory>E:\\NewProject\\DevBuilds</workingDirectory>
<artifactDirectory>E:\\NewProject\\DevBuilds\Artifacts</artifactDirectory>
<modificationDelaySeconds>600</modificationDelaySeconds>
<category>Dev Build</category>
<sourcecontrol type="svn">
<trunkUrl>https://mycompany.com/svn/trunk/MyApplication</trunkUrl>
<workingDirectory>E:\\NewProject\\DevBuilds\SourceCode</workingDirectory>
<autoGetSource>false</autoGetSource>
<executable>C:\Program Files\Subversion\bin\svn.exe</executable>
<username>username</username>
<password>password</password>
</sourcecontrol>
<initialState>Started</initialState>
<startupMode>UseInitialState</startupMode>
<triggers>
<intervalTrigger seconds="3600" buildCondition="IfModificationExists" />
</triggers>
<state type="state" directory="E:\\NewProject\\DevBuilds" />
<labeller type="iterationlabeller">
<prefix>1.0</prefix>
<duration>1</duration>
<releaseStartDate>2012/04/11</releaseStartDate>
<separator>.</separator>
</labeller>
<tasks>
<nant>
<executable>E:\NewProject\Installables\nant\bin\nant.exe</executable>
<baseDirectory>E:\\NewProject\\Build Files</baseDirectory>
<buildFile>Build.xml</buildFile>
<targetList>
<target>Run</target>
</targetList>
<buildTimeoutSeconds>5000</buildTimeoutSeconds>
</nant>
</tasks>
<publishers>
<merge>
<files>
<file>E:\NewProject\DevBuilds\FxCopOutput\FxCop-results.xml</file>
</files>
</merge>
<xmllogger logDir="E:\\NewProject\\DevBuilds\Artifacts\\buildlogs" />
<email from="Checkins#symphonysv.com" mailhost="smtp.gmail.com" includeDetails="true" useSSL="false">
<users>
<user name="dev1" group="buildmaster" address="myname#gmail.com"/>
</users>
<groups>
<group name="buildmaster">
<notifications>
<notificationType>Always</notificationType>
</notifications>
</group>
</groups>
</email>
</publishers>
</project>
</cruisecontrol>
Build.xml
<?xml version="1.0"?>
<project name="Test" default="Run" basedir=".">
<property name="BuildNumber" value="1.0.0.0"/>
<property name="SourceControlURL" value="https://mycompany.com/svn/trunk/MyApplication/"/>
<property name="BuildFile" value=".\Build.xml"/>
<property name="TagBuild" value="false"/>
<property name="BuildType" value="Release"/>
<property name="BuildTargetDir" value="E:\NewProject\DevBuilds\Executables"/>
<property name="BuildWorkDir" value="E:\NewProject\DevBuilds\SourceCode"/>
<property name="MSBUILD" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319"/>
<property name="FxCopOutPutDirectory" value="E:\NewProject\DevBuilds\FxCopOutput" />
<property name="FxCopInputDirectory" value="E:\NewProject\DevBuilds" />
<target name="Run" description="Starting ThinkPets Build">
<call target="GetLatestCode"/>
<call target="BuildCode"/>
<call target="BuildASPWebSite"/>
<call target="runFxCop"/>
</target>
<target name="GetLatestCode">
<echo message="Updating Code From SVN to ${BuildWorkDir}"/>
<exec program="svn.exe">
<arg line="checkout ${SourceControlURL} ${BuildWorkDir} -q"/>
</exec>
</target>
<target name="BuildCode">
<echo message="Building VS10 Projects Web" />
<exec program="${MSBUILD}\msbuild.exe" failonerror="true">
<arg line=" "${BuildWorkDir}\Application.sln" /t:Rebuild /p:Configuration=Release /V:q"/>
</exec>
</target>
<target name="BuildASPWebSite">
<echo message="Building ASP Web Site" />
<exec program="${MSBUILD}\aspnet_compiler.exe" failonerror="true">
<arg line=" -v / -p "${BuildWorkDir}\MyDir" -f -c "${BuildTargetDir}" "/>
</exec>
</target>
<target name="runFxCop" depends="BuildCode">
<exec program="C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe" failonerror="false">
<arg line="/p:${FxCopInputDirectory}\SampleProject.FxCop /o:${FxCopOutPutDirectory}\FxCop-results.xml"/>
</exec>
</target>
</project>
There are a few points you missed:
You need to add <includeDetails>true</includeDetails> to your e-mail publisher block. This will give you HTML e-mails.
In order to transform your XML build results into HTML you need to add an <xslFiles> section to your e-mail publisher block. The elements of this block point to XSL transformation files in [CCNET_INSTALL_DIR]\server\xsl.
So for including the FxCop summary just as appears in CCNET webdasboard this is your e-mail publisher block:
<email from="Checkins#symphonysv.com" mailhost="smtp.gmail.com" includeDetails="true" useSSL="false">
<users>
<user name="dev1" group="buildmaster" address="myname#gmail.com"/>
</users>
<groups>
<group name="buildmaster">
<notifications>
<notificationType>Always</notificationType>
</notifications>
</group>
</groups>
<includeDetails>true</includeDetails>
<xslFiles>
<file>xsl\fxcop-summary_1_36.xsl</file>
</xslFiles>
</email>
Thanks Chairman for your valuable time. I think my mistake was that I did not host the "ccnet" application on my machine which resulted in not able to find the xsls for the publishers. When I used the same settings and config file on the Server machine with "ccnet" application hosted, I was able to see the FxCop summary in the email. Please correct my understanding if wrong.

Resources