I use "antcall" scriptlla concurrent invocations, but appear "javax.mail. Management InstanceNotFoundException".
I set up 10 concurrent, sometimes can be 10, sometimes only a few can rise.
<target name="PAIR_CONN">
<etl debug="true">
<fileset file="Pair_Conn.xml" />
</etl>
</target>
<target name="pair_conn_mult">
<parallel threadCount='5'>
<antcall target="PAIR_CONN">
<param name="g_flag" value="1" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="2" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="3" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="4" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="0" />
</antcall>
</parallel>
</target>
Unable to unregister mbean scriptella:type=etl,url="file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml"
javax.management.InstanceNotFoundException: scriptella:type=etl,url="file:/informatica/infa861/oss_etl_523/src/ElectricCable/Pair_Conn.xml"
I view scriptella source code, the code is already synchronized,
public synchronized void register() {
if (name != null) {
throw new IllegalStateException("MBean already registered");
}
server = getMBeanServer();
String url = ctx.getScriptFileURL().toString();
System.out.println("LM:"+url);
boolean registered = false;
for (int i = 0; i < 1000; i++) {
if (name == null || server.isRegistered(name)) {
registered = true;
name = toObjectName(url, i);
System.out.println("LM:"+name);
} else {
registered = false;
break;
}
}
etlThread = Thread.currentThread();
if (!registered) {
try {
server.registerMBean(this, name);
started = new Date();
LOG.info("Registered JMX mbean: " + name);
} catch (Exception e) {
throw new SystemException("Unable to register mbean " + name, e);
}
} else {
throw new SystemException("Unable to register mbean for url " + url + ": too many equal tasks already registered");
}
}
What suggestions to you have for this situation ? What should I try, or what should I read in order to find a solution ?
Thanks for pointing out a serious bug. I've opened JavaForge ticket to track this issue.
As a workaround you can switch to <java fork="true"> task to run Scriptella in a forked VM, so the Ant script will become something like this:
<path id="scriptella.class.path">
<pathelement location="../../build/scriptella.jar"/>
</path>
<taskdef resource="antscriptella.properties" classpathref="scriptella.class.path"/>
<target name="PAIR_CONN">
<java fork="yes" classname="scriptella.tools.launcher.EtlLauncher" classpathref="scriptella.class.path">
<arg value="Pair_Conn.xml"/>
<arg value="-d"/>
<sysproperty key="g_flag" value="${g_flag}"/>
</java>
</target>
<target name="pair_conn_mult">
<parallel threadCount='5'>
<antcall target="PAIR_CONN">
<param name="g_flag" value="1" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="2" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="3" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="4" />
</antcall>
<antcall target="PAIR_CONN">
<param name="g_flag" value="0" />
</antcall>
</parallel>
</target>
Related
What I'd like to do is to extract images from ROS .bag file and then to make a mp4 video from it.
Following this link: https://www.pianshen.com/article/9945320163/ and the ros wiki, I think I roughly understand the procedure to extract images from a give .bag file. Yet, I encountered a problem while trying to figure out the remap tag. My .bag file has many topics and I do not know how to get the interested topics. During the trials and errors process, I always get the following message:
[ERROR] [1638797416.552069577]: Client [/extract] wants topic /pred/pred_tra_rviz to have datatype/md5sum [sensor_msgs/Image/060021388200f6f0f447d0fcd9c64743], but our version has [visualization_msgs/MarkerArray/d155b9ce5188fbaf89745847fd5882d7]. Dropping connection.
Any comments are greatly appreciated.
EDIT: the launch file looks like this:
<launch>
<node pkg="rosbag" type="play" name="rosbag" required="true" args="/opt/ros/melodic/share/image_view/myBag.bag"/>
<node name="extract" pkg="image_view" type="extract_images" respawn="false" required="true" output="screen" cwd="ROS_HOME">
<remap from="image" to="/prediction/predicted_trajectories_rviz"/>
</node>
</launch>
I do not know how to handle the type mismatch message. What I'd like to do is to extract images from ros bags, and then compress them to get a clip of mp4 videos, the same as how I play the ros bag when entering "rosbag play /path_to_my_ros_bag/" on the terminal. I inspected the launch file I used for the rosbag play command. It's like the following.
<launch>
<arg name="tracked_objects_topic" default="/detected_object/objects" />
<arg name="ego_car_state_topic" default="/current_pva" />
<arg name="traffic_signal_topic" default="/perception/signal_response" />
<arg name="roadmap_rviz_topic" default="/prediction/roadmap_rviz" />
<arg name="ego_rviz_topic" default="/prediction/ego_rviz" />
<arg name="object_rviz_topic" default="/prediction/object_rviz" />
<arg name="rosbag" default="" />
<arg name="interval" default="0.1" />
<arg name="skip" default="0.0" />
<arg name="show_box" default="true" />
<arg name="show_ego" default="true" />
<arg name="show_roadmap" default="true" />
<arg name="roadmap_range" default="300" />
<arg name="show_rviz" default="true" />
<node pkg="prediction" type="map_client_test" name="map_client_test_node" output="screen" required="true">
<param name="tracked_objects_topic" value="$(arg tracked_objects_topic)" />
<param name="ego_car_state_topic" value="$(arg ego_car_state_topic)" />
<param name="traffic_signal_topic" value="$(arg traffic_signal_topic)" />
<param name="roadmap_rviz_topic" value="$(arg roadmap_rviz_topic)" />
<param name="ego_rviz_topic" value="$(arg ego_rviz_topic)" />
<param name="object_rviz_topic" value="$(arg object_rviz_topic)" />
<param name="rosbag" value="$(arg rosbag)" />
<param name="interval" value="$(arg interval)" />
<param name="skip" value="$(arg skip)" />
<param name="show_box" value="$(arg show_box)" />
<param name="show_ego" value="$(arg show_ego)" />
<param name="show_roadmap" value="$(arg show_roadmap)" />
<param name="roadmap_range" value="$(arg roadmap_range)" />
</node>
<group if="$(arg show_rviz)">
<node pkg="rviz" type="rviz" name="rviz" args="-d $(find prediction)/launch/rviz/map_client_test.rviz" />
</group>
</launch>
I need to delete all the line items <LineItem> from the file which does not suffice with this requirements:
elements in Line Item : <LineItemNumber V="00000000000000000010" /> and <PurchaseOrderNumber V="0100230946|00010" /> have to be matched, another words in integer Line Item Number would be 10 and Purchase order number after pipe line | would be 10. we need to have only one those line Items which are matching this requirement. Sorry, i'm really bad at describing.
<Transmission>
<InterchangeUsageIndicator V="T" />
<Groups>
<Group>
<GroupSenderID V="CCC" />
<TotalNumberOfShipmentsInGroup V="000005" />
<Documents>
<Document>
<DocumentHeader>
<InvoiceChargeType V="T" />
<DocumentType V="ORDER" />
<DocumentProcessingCode C="00" />
<BOLNumber V="BOL2309460180582136" />
<AlternateQuantities>
<AlternateQuantity Quantity="12.0" UOM="PK" UOMType="SQ" Characteristic="" />
</AlternateQuantities>
<Buyer Name="" Q="ZP" ID="COUSPO001">
<AlternateIDs />
</Buyer>
<Seller Name="" Q="2" ID="CNTR">
<AlternateIDs />
</Seller>
<Parties>
<Party PartyType="SF">
<Name V="SHA" />
<LocationID Q="" ID="" />
<AlternateLocationIDs>
<LocationID Q="" ID="SHA" />
</AlternateLocationIDs>
<City V="Shanghai" />
<Country V="CN" />
<LocationPurpose V="" />
</Party>
<Party PartyType="ST">
<Name V="LEB" />
<LocationID Q="" ID="" />
<AlternateLocationIDs>
<LocationID Q="" ID="LEB" />
</AlternateLocationIDs>
<City V="Lebanon" />
<Country V="TN" />
<LocationPurpose V="" />
</Party>
<Party PartyType="VN">
<Name V="YANGZHOU BAOYI SHOES" />
<LocationID Q="" ID="4100000423" />
<AlternateLocationIDs />
<City V="JIANGSU" />
<Country V="CN" />
<LocationPurpose V="" />
</Party>
</Parties>
<DateReferences>
<DR Type="D" Q="ETA" Date="2019-12-19" />
<DR Type="D" Q="EST" Date="2019-11-28" />
</DateReferences>
<ReservedReferences>
<RR Type="R" Q="K6" V="86|SEAL230946" />
<RR Type="R" Q="V3" V="VYG230946|BKG230946" />
</ReservedReferences>
</DocumentHeader>
<Vessel VesselName="VSL230946" VesselNumber="" VesselCountryOfRegistration="" VesselRegistrationNumber="" />
<Equipments>
<Equipment Initial="CNTR" Number="230946" Length="0" Type="" TotalContainerVolume="52.06" />
</Equipments>
<LineItems>
<LineItem>
<LineItemNumber V="00000000000000000010" />
<LineItemType C="LI" />
<TransportationServiceCode Code="" />
<PurchaseOrderNumber V="0100230946|00010" />
<AdditionalReferenceNumber V="" />
<DescriptionMarksAndNumbers>
<CommodityCode Q="" C="M9160" />
<BuyerProductID V="" />
</DescriptionMarksAndNumbers>
<BilledRatedAsQuantity V="0.0" UOM="PA" />
<LadingQuantity V="0.0" UOM="PA" />
<LineItemTotalAmount V="0.0" />
<LineItemWeight V="0.00" />
<LineItemVolume V="0.00" />
</LineItem>
<LineItem>
<LineItemNumber V="00000000000000900001" /> //this one would not work,because it is 900001
<LineItemType C="LI" />
<LineItemSubType C="SCH" />
<TransportationServiceCode Code="" />
<PurchaseOrderNumber V="0100230946|00010" />
<AdditionalReferenceNumber V="" />
<DescriptionMarksAndNumbers>
<CommodityCode Q="" C="M9160" />
<BuyerProductID V="" />
</DescriptionMarksAndNumbers>
<BilledRatedAsQuantity V="24.0" UOM="PA" />
<LadingQuantity V="24.0" UOM="PA" />
<LineItemTotalAmount V="0.0" />
<UserDefinedReferences>
<UDR Type="U" Q="CR" V="22859470896|001|0001" Description="" />
<UDR Type="U" Q="S6" V="|3|20" Description="" />
<UDR Type="U" Q="19" V="M9160|USDS|0001" Description="" />
</UserDefinedReferences>
<LineItemWeight V="2959.54" />
<LineItemVolume V="104.12" />
</LineItem>
<LineItem>
<LineItemNumber V="00000000000000900002" />
<LineItemType C="LI" />
<LineItemSubType C="SCH" />
<TransportationServiceCode Code="" />
<PurchaseOrderNumber V="0100230946|00010" />
<AdditionalReferenceNumber V="" />
<DescriptionMarksAndNumbers>
<CommodityCode Q="" C="M9160" />
<BuyerProductID V="" />
</DescriptionMarksAndNumbers>
<BilledRatedAsQuantity V="24.0" UOM="PA" />
<LadingQuantity V="24.0" UOM="PA" />
<LineItemTotalAmount V="0.0" />
<UserDefinedReferences>
<UDR Type="U" Q="CR" V="22859470902|001|0002" Description="" />
<UDR Type="U" Q="S6" V="|3.5|20" Description="" />
<UDR Type="U" Q="19" V="M9160|USDS|0001" Description="" />
</UserDefinedReferences>
<LineItemWeight V="2959.54" />
<LineItemVolume V="104.12" />
</LineItem>
I tried to start on LINQ: this is where I got so far:
try {
var xDoc = XDocument.Parse(msg.Body);
var xDocument = xDoc.Root.XPathSelectElement("Groups/Group/Documents/Document");
var xLineItems = xDocument.XPathSelectElements("LineItems/LineItem");
var poNumbers = xLineItems.Select(e => (string)e.Element("PurchaseOrderNumber").Attribute("V")).Distinct();
foreach (var poNumber in poNumbers) {
}
msg.Body = xDoc.ToString();
I believe you would like to Delete all LineItem where LineItemNumber!=10 and PurchaseOrderNumber after the Pipe NOT equals 10. You could use Linq to filter the elements that match the purpose and use the Remove method to deletes the selected nodes.
var xDoc = XDocument.Parse(xml);
xDoc.Descendants("LineItem")
.Where(x=> Convert.ToInt32(x.Element("LineItemNumber").Attribute("V").Value)!=10
&& Convert.ToInt32(x.Element("PurchaseOrderNumber").Attribute("V").Value.Split('|')[1])!=10
).Remove();
var result = xDoc.ToString();
I am trying to integrate BeanIO with spring batch. Using BeanIO I am reading a fixed length stream file. I have tested and verified the code to read the flat file using a standalone class and it works seamlessly but when I tried to integrate it with Spring Batch the doRead() method of BeanIOFlatFileItemReader is not getting invoked and some how directly the RedemptionEventCustomProcessor written by me is getting invoked.
I get below stacktrace on console.:
:::::::::::::In Processor::::::::::::::::
Exit Status : FAILED job Id 0 [java.lang.NullPointerException]
Done
Please find the dependencies used below:
spring-batch-core version 2.1.9.RELEASE
spring-batch-infrastructure 2.1.9.RELEASE
beanio-2.1.0.M2
Please find below the resources files as mentioned below:
earn-api-batch - spring batch xml file
earn-api-batch-context - spring batch context xml file
earn-api-mapping.xml - BeanIO mapping xml file
earn-api-batch.xml:
<import resource="classpath:earn-api-batch-context.xml" />
<batch:job id="processEventJob">
<batch:step id="step">
<batch:tasklet>
<batch:chunk reader="RedemptionFileReader" writer="RedemptionEventCustomWriter" processor="RedemptionEventCustomProcessor" commit-interval="1"></batch:chunk>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="RedemptionFileReader" class="org.beanio.spring.BeanIOFlatFileItemReader">
<property name="streamMapping" value="classpath:/earn-api-mapping.xml" />
<property name="streamName" value="redemptionFile" />
<property name="resource" value="classpath:/RedemptionTest" />
</bean>
<bean id="RedemptionEventCustomWriter" class="org.beanio.spring.BeanIOFlatFileItemWriter">
<property name="streamMapping" value="classpath:/earn-api-mapping.xml" />
<property name="streamName" value="redemptionFile" />
<property name="resource" value="file:Redemption.txt" />
</bean>
earn-api-batch-context:
<context:component-scan base-package="com.aexp.earn.api.batch" />
<bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
<property name="jobRepository" ref="jobRepository" />
</bean>
<bean id="jobRepository" class="org.springframework.batch.core.repository.support.SimpleJobRepository">
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobInstanceDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapStepExecutionDao"/>
</constructor-arg>
<constructor-arg>
<bean class="org.springframework.batch.core.repository.dao.MapExecutionContextDao"/>
</constructor-arg>
</bean>
<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" />
earn-api-mapping.xml:
<beanio xmlns="http://www.beanio.org/2012/03"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.beanio.org/2012/03 http://www.beanio.org /2012/03/mapping.xsd">
<stream name="redemptionFile" format="fixedlength">
<!-- 'class' binds the header record to a java.util.HashMap -->
<record name="header" class="map">
<!-- 'rid' indicates this field is used to identify the record -->
<field name="recordType" length="1" rid="true" literal="1" />
<field name="fileSeqNo" length="10" padding=" " justify="right" />
<!-- 'format' can be used to provide Date and Number formats -->
<field name="fileDate" length="8" type="date" format="yyyyMMdd" />
</record>
<record name="nar" class="com.aexp.earn.api.batch.vo.NonAirline">
<field name="recordType" length="1" ignore="true" />
<field name="redeemType" rid="true" literal="1" length="1" />
<field name="mmNo" length="10" />
<field name="cmNo" length="19" padding=" " justify="right" />
<field name="rewardProgCode" length="2" padding="0" justify="right" />
<field name="certNo" length="10"/>
<field name="certFaceValue" length="13" padding=" " justify="right" />
<field name="redeemTimeStamp" length="26" />
<field name="statusCode" length="2" />
<field name="statusTimeStamp" length="26" />
<field name="rewardCode" length="4" />
<field name="rewardSubCode" length="4" />
<field name="transId" length="15" />
<field name="transSrcId" length="3" />
<field name="narRequestId" length="14" />
<field name="narRequestLnId" length="5" padding=" " justify="right" />
</record>
<record name="ar" class="com.aexp.earn.api.batch.vo.Airline">
<field name="recordType" length="1" ignore="true" />
<field name="redeemType" rid="true" literal="2" length="1" />
<field name="partnerTransferType" length="1" />
<field name="mmNo" length="10" />
<field name="cmNo" length="19" padding=" " justify="right" />
<field name="rewardProgCode" length="2" />
<field name="frequentFlyerNo" length="15" />
<field name="partnerCode" length="2"/>
<field name="redeemTimeStamp" length="26" />
<field name="transferedMiles" length="12" padding=" " justify="right" />
<field name="transferedStatus" length="1" />
<field name="statusTimeStamp" length="26" />
<field name="originSourceCode" length="3" />
<field name="transId" length="15" />
<field name="transSrcId" length="3" />
<field name="arRequestId" length="14" />
<field name="arRequestLnId" length="5" padding=" " justify="right" />
</record>
<record name="pwp" class="com.aexp.earn.api.batch.vo.PWP">
<field name="recordType" length="1" ignore="true" />
<field name="redeemType" rid="true" literal="3" length="1" />
<field name="mmNo" length="10" />
<field name="cmNo" length="19" padding=" " justify="right" />
<field name="rewardProgCode" length="2" />
<field name="redeemTimeStamp" length="26" />
<field name="adjustMiles" length="12" />
<field name="adjustCD" length="4" />
<field name="transId" length="15" />
<field name="transSrcId" length="3" />
<field name="pwpRequestId" length="14" padding=" " justify="right" />
<field name="pwpRequestLnId" length="5" />
</record>
<record name="pap" class="com.aexp.earn.api.batch.vo.PAP">
<field name="recordType" length="1" ignore="true" />
<field name="redeemType" rid="true" literal="4" length="1" />
<field name="mmNo" length="10" />
<field name="cmNo" length="19" padding=" " justify="right" />
<field name="rewardProgCode" length="2" />
<field name="redeemTimeStamp" length="26" />
<field name="chnlPtnrId" length="5" />
<field name="orderId" length="32" />
<field name="partnerReserId" length="32" />
<field name="confirmId" length="16" padding=" " justify="right" />
<field name="actPtCnt" length="12" />
<field name="rewdActTypeCd" length="3" />
<field name="seqNo" length="5" />
</record>
<!-- 'target' binds the trailer record to the Integer record count field -->
<record name="trailer" target="recordCount">
<!-- 'literal' is used to define constant values -->
<field name="recordType" rid="true" literal="9" length="2" />
<!-- 'type' can be declared where bean introspection is not possible -->
<field name="recordCount" length="7" type="int" />
</record>
</stream>
</beanio>
Find below the classes:
Main class:
public class EventStart {
#SuppressWarnings("resource")
public static void main(String[] args) {
String[] springConfig =
{
"earn-api-batch.xml"
};
ClassPathXmlApplicationContext appContext = null;
appContext = new ClassPathXmlApplicationContext(springConfig);
JobLauncher jobLauncher = (JobLauncher) appContext.getBean("jobLauncher");
Job job = (Job) appContext.getBean("processEventJob");
try {
JobExecution execution = jobLauncher.run(job, new JobParameters());
System.out.println("Exit Status : " + execution.getStatus() + " job Id " + execution.getJobId() + " " + execution.getAllFailureExceptions());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("Done");
}
}
Reader Class:
#Component(value = "RedemptionFileReader")
#Scope("step")
public class RedemptionFileReader extends BeanIOFlatFileItemReader<Map<String,Object>>{
/* #Value("#{batchProps['redemption.server.file.path']}")
private Resource resource;*/
Map<String,Object> map = new HashMap<String,Object>();
/*#Override
public String read() throws Exception, UnexpectedInputException,
ParseException, NonTransientResourceException {
System.out.println("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh");
// TODO Auto-generated method stub
return null;
}*/
#Override
public Map<String,Object> doRead() throws Exception, UnexpectedInputException,
ParseException, NonTransientResourceException {
System.out.println("HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH");
/*if (null != recordsCount) {
return null;
}*/
map = identifyRecord();
return map;
}
private Map<String,Object> identifyRecord() throws FileNotFoundException {
Map<String,Object> map=new HashMap<String,Object>();
ArrayList<NonAirline> narList = new ArrayList<NonAirline>();
ArrayList<Airline> arList = new ArrayList<Airline>();
ArrayList<PWP> pwpList = new ArrayList<PWP>();
ArrayList<PAP> papList = new ArrayList<PAP>();
// create a StreamFactory
StreamFactory factory = StreamFactory.newInstance();
// load the mapping file
factory.load("src/main/resources/earn-api-mapping.xml");
// use a StreamFactory to create a BeanReader
BeanReader in = factory.createReader("redemptionFile", new File("src/main/resources/RedemptionTest"));
Object record = null;
String recordCount = "";
while ((record = in.read()) != null) {
if ("header".equals(in.getRecordName())) {
//Map<String,Object> header = (Map<String,Object>) record;
//System.out.println(header.get("fileDate"));
System.out.println("Header");
}
else if ("nar".equals(in.getRecordName())) {
NonAirline nar = (NonAirline) record;
System.out.println("NAR Redeem Type: " + nar.getRedeemType());
System.out.println("NAR MM No.: " + nar.getMmNo());
System.out.println("NAR CM No.: " + nar.getCmNo());
narList.add(nar);
}
else if ("ar".equals(in.getRecordName())) {
Airline ar = (Airline) record;
System.out.println("AR Redeem Type: " + ar.getRedeemType());
System.out.println("AR MM No.: " + ar.getMmNo());
System.out.println("AR CM No.: " + ar.getCmNo());
arList.add(ar);
}
else if ("pwp".equals(in.getRecordName())) {
PWP pwp = (PWP) record;
System.out.println("PWP Redeem Type: " + pwp.getRedeemType());
System.out.println("PWP MM No.: " + pwp.getMmNo());
System.out.println("PWP CM No.: " + pwp.getCmNo());
pwpList.add(pwp);
}
else if ("pap".equals(in.getRecordName())) {
PAP pap = (PAP) record;
System.out.println("PAP Redeem Type: " + pap.getRedeemType());
System.out.println("PAP MM No.: " + pap.getMmNo());
System.out.println("PAP CM No.: " + pap.getCmNo());
papList.add(pap);
}
else if ("trailer".equals(in.getRecordName())) {
recordCount = (String) record;
System.out.println("Trailer");
System.out.println(recordCount + " contacts processed");
}
}
map.put("NAR", narList);
map.put("AR", arList);
map.put("PWP", pwpList);
map.put("PAP", papList);
in.close();
return map;
}
}
Processor Class:
#Component(value = "RedemptionEventCustomProcessor")
public class RedemptionEventCustomProcessor implements ItemProcessor<Map<String,Object>, Map<String,Object>> {
ArrayList<NonAirline> narList = new ArrayList<NonAirline>();
ArrayList<Airline> arList = new ArrayList<Airline>();
ArrayList<PWP> pwpList = new ArrayList<PWP>();
ArrayList<PAP> papList = new ArrayList<PAP>();
#SuppressWarnings("unchecked")
#Override
public Map<String,Object> process(Map<String,Object> map) throws Exception {
System.out.println(":::::::::::::In Processor::::::::::::::::");
narList = (ArrayList<NonAirline>) map.get("NAR");
for(int i=0; i <= narList.size(); i++)
{
NonAirline nar = narList.get(i);
System.out.println("CM No. " + nar.getCmNo());
}
return map;
}
}
Please let me know if any other information is required. Any help will be really appreciated, please consider I am new to both BeanIO and spring as well.
If anyone could share a working example of BeanIO using Spring Batch that should also help.
Thank You in advance.
I too am using beanio with spring batch. The error you are getting is perhaps for the version issue. Here is my xsd config from job 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:context="http://www.springframework.org/schema/context"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:batch="http://www.springframework.org/schema/batch" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
I've a WebAPI OData v3 (5.6.3) service (without EF) which I call from breeze using server side metadata. Unfortunately I cannot get navigation properties to load correctly in breeze.
The model is defined as following:
public class ParentItem
{
private readonly List<ChildItem> childItems = new List<ChildItem>();
[Key]
public int Id { get; set; }
public virtual ICollection<ChildItem> ChildItems
{
get
{
return this.childItems;
}
}
#endregion
}
public class ChildItem
{
[Key]
public int Id { get; set; }
[ForeignKey("ParentItem")]
public int? ParentItemId { get; set; }
public virtual ParentItem ParentItem { get; set; }
}
These are the metadata generated by the server:
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:DataServices m:DataServiceVersion="3.0" m:MaxDataServiceVersion="3.0" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<Schema Namespace="Solutions2Share.Solutions.MeetingManagerWeb.Models" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="ParentItem">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<NavigationProperty Name="ChildItems" Relationship="MyNamespace_ChildItem_ChildItemsPartner" ToRole="ChildItems" FromRole="ChildItemsPartner" />
</EntityType>
<EntityType Name="ChildItem">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="ParentId" Type="Edm.Int32" />
<NavigationProperty Name="ParentItem" Relationship="MyNamespace_ParentItem_ParentItemPartner" ToRole="ParentItem" FromRole="ParentItemPartner" />
</EntityType>
<Association Name="MyNamespace_ChildItem_ChildItemsPartner">
<End Type="MyNamespace.ChildItem" Role="ChildItems" Multiplicity="*" />
<End Type="MyNamespace.ParentItem" Role="ChildItemsPartner" Multiplicity="0..1" />
</Association>
<Association Name="MyNamespace_ParentItem_ParentItemPartner">
<End Type="MyNamespace.ParentItem" Role="ParentItem" Multiplicity="0..1" />
<End Type="MyNamespace.ChildItem" Role="ParentItemPartner" Multiplicity="0..1" />
</Association>
<EntityContainer Name="Container" m:IsDefaultEntityContainer="true">
<EntitySet Name="ParentItems" EntityType="MyNamespace.ParentItem" />
<EntitySet Name="ChildItems" EntityType="MyNamespace.ChildItem" />
<AssociationSet Name="MyNamespace_ChildItem_ChildItemsPartnerSet" Association="MyNamespace_ChildItem_ChildItemsPartner">
<End Role="ChildItemsPartner" EntitySet="ParentItems" />
<End Role="ChildItems" EntitySet="ChildItems" />
</AssociationSet>
<AssociationSet Name="MyNamespace_ParentItem_ParentItemPartnerSet" Association="MyNamespace_ParentItem_ParentItemPartner">
<End Role="ParentItemPartner" EntitySet="ChildItems" />
<End Role="ParentItem" EntitySet="ChildItems" />
</AssociationSet>
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
I'm using webApiOData on the client:
breeze.config.initializeAdapterInstance('dataService', 'webApiOData', true);
The query which I'm execute looks like this:
breeze.EntityQuery().from('ParentItems').expand('ChildItems');
The server call returns the correct items:
{
"odata.metadata":"http://example.com/api/$metadata#ParentItems","value":[
{
"odata.type":"MyNamespace.ParentItem","odata.id":"http://example.com/api/ParentItems(1)","ChildItems#odata.navigationLinkUrl":"http://example.com/api/ParentItems(1)/ChildItems","ChildItems":[
{
"odata.type":"MyNamespace.ChildItem","odata.id":"http://example.com/api/ChildItems(1)","ParentItem#odata.navigationLinkUrl":"http://example.com/api/ChildItems(1)/ParentItem","Id":1,"ParentItemId":1
},{
"odata.type":"MyNamespace.ChildItem","odata.id":"http://example.com/api/ChildItems(2)","ParentItem#odata.navigationLinkUrl":"http://example.com/api/ChildItems(2)/ParentItem","Id":2,"ParentItemId":1
}
],"Id":1
}
]
}
But the ChildItems property of the ParentItem entity is empty.
Edit: If I call manager.getEntities()after executing the query all parent and child items are returned.
I'm trying to set up a small app to experiment with NHibernate in visual studio but I'm not getting far.
The error I get is: "Could not find the dialect in the configuration".
I've tried specifying settings in both app.config and hibernate.cfg.xml but neither seems to work. These files are in the same directory as my app source (tried other directories too). I've tried setting the build action on hibernate.cfg.xml as "embedded resource" but that didn't help either. I get the same error message even if I completely remove these config files.
I've looked at various examples on the net but can't get it sorted ... Does anyone know what the problem could be?
Here is my application source,app.config and hibernate.cfg.xml
Application Source
using NHibernate;
using NHibernate.Cfg;
namespace Timer
{
public partial class Form1 : Form
{
Configuration cfg;
ISessionFactory factory;
ISession session;
ITransaction transaction;
public Form1()
{
cfg = new Configuration();
//cfg.AddAssembly("Timer");
//cfg.AddFile("WorkoutSet.hbm.xml");
factory = cfg.BuildSessionFactory();
session = factory.OpenSession();
transaction = session.BeginTransaction();
InitializeComponent();
}
}
}
App.Config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
<section
name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.FirebirdDialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.FirebirdClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="User=sysdba;Password=masterkey;Database=C:\X\Test\Timer\Timer.FDB;Dialect=3;ServerType=1;"
/>
</nhibernate>
<log4net debug="false">
<!-- Define some output appenders -->
<appender name="trace"
type="log4net.Appender.TraceAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern"
value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="console"
type="log4net.Appender.ConsoleAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern"
value="%d{ABSOLUTE} %-5p %c{1}:%L - %m%n" />
</layout>
</appender>
<appender name="rollingFile"
type="log4net.Appender.RollingFileAppender,log4net" >
<param name="File" value="h:\log.txt" />
<param name="AppendToFile" value="false" />
<param name="RollingStyle" value="Date" />
<param name="DatePattern" value="yyyy.MM.dd" />
<param name="StaticLogFileName" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern"
value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default priority -->
<root>
<priority value="DEBUG" />
<appender-ref ref="console" />
</root>
<logger name="NHibernate">
<level value="DEBUG" />
</logger>
</log4net>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="FirebirdSql.Data.FirebirdClient"
fullName="FirebirdSql.Data.FirebirdClient, Version=2.0.1.0, Culture=neutral, PublicKeyToken=3750abcc3150b00c" />
</assemblyBinding>
</runtime>
</configuration>
hibernate.cfg.xml
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section
name="nhibernate"
type="System.Configuration.NameValueSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
/>
</configSections>
<nhibernate>
<add
key="hibernate.connection.provider"
value="NHibernate.Connection.DriverConnectionProvider"
/>
<add
key="hibernate.dialect"
value="NHibernate.Dialect.FirebirdDialect"
/>
<add
key="hibernate.connection.driver_class"
value="NHibernate.Driver.FirebirdClientDriver"
/>
<add
key="hibernate.connection.connection_string"
value="User=sysdba;Password=masterkey;Database=C:\X\Test\Timer\Timer.FDB;Dialect=3;ServerType=1;"
/>
</nhibernate>
</configuration>
ok thanks everyone, I've got it sorted now. It seems I needed to call cfg.Configure() to process hibernate.cfg.xml ... once I did this there were a few other errors but they were all quite logical to fix up with error messages that made good sense.
Here's the initialization code that worked.
public Form1()
{
cfg = new Configuration();
cfg.Configure();
factory = cfg.BuildSessionFactory();
session = factory.OpenSession();
transaction = session.BeginTransaction();
InitializeComponent();
}
If you're using NHibernate 2.0, but following instructions referring to 1.2, the configuration xml has changed and this will be causing your issue.
Try (in app.config, omit the configSections for a standalone file):
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="dialect">NHibernate.Dialect.FirebirdDialect</property>
<property name="connection.driver_class">NHibernate.Driver.FirebirdClientDriver</property>
<property name="connection.connection_string">User=sysdba;Password=masterkey;Database=C:\X\Test\Timer\Timer.FDB;Dialect=3;ServerType=1;</property>
</session-factory>
</hibernate-configuration>
cfg.Configure();
really helped...Thanks a lot.
Earlier i was using
cfg.AddAssembly(Assembly.GetCallingAssembly());
without success