w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Spring Batch : How to use spring batch to read file from sftp server and save it into database?
Add a tasklet as the first step; have the tasklet invoke a Spring Integration flow, probably using an sftp outbound gateway to GET the file. There's an example of how to use the gateway in the sftp sample. The 'transfer start time' would be the time you invoke the gateway.

Categories : Spring

Is there a windows secure persistent storage API?
No, not in the sense that you're looking for. Windows, like most Operating Systems, bases its security model on users instead of applications. If a user can do X with your program, it's because the user has the right to do X. That also means he has that right in any other program, including Explorer.EXE.

Categories : C++

How to deal with persistent storage (e.g. databases) in docker
While this is still a part of docker that needs some work, you should put the volume in the Dockerfile with the VOLUME instruction so you don't need to copy the volumes from another container. That will make your containers less inter-dependent and you don't have to worry about the deletion of one container affecting another.

Categories : Docker

IOS : Remove a Persistent Storage in a Multithreading CoreData Implementation
You need to release all NSManagedObjectContext objects before you delete your NSPersistentStoreCoordinator object. This needs to happen for all NSManagedObjectContext objects in all threads. NSManagedObjectContext objects have a persistentStoreCoordinator property. After deleting the NSPersistentStoreCoordinator file you can then re-create the NSManagedObjectContext objects.

Categories : IOS

Is it a good practice to serialize Parcelable objects for persistent storage?
Neither Parcelable nor Serializable are a good idea for persisting data. Store persistent data in SharedPreferences if possible, or wind it out to a file. Serializable could hit you if you decide to change the structure of the object. Parcelable is not guaranteed to remain constant across versions; it's designed to pass data between processes, not store data. If you want to store data long-term, you should write it to a file. Depending on how you want to access it, you may want to store it in a database or a content provider.

Categories : Android

How do you synchronize in an SPA client-side row deletes in a grid with the server's persistent storage
When you set a Breeze entity to a "deleted" state myEntity.entityAspect.setDeleted() Breeze automatically detaches it from any collections from which it is a member. At this point the entity will have an EntityState of "Deleted". Later when the entity ( or entities) are saved via an EntityManager.saveChanges() call, these entities are then both deleted on the server and "detached" (removed from the EntityManager) on the client. At this point the Entity will have an EntityState of "Detached" and should be garbage collected once you release any of your own references to it. ( Breeze no longer "knows" about it. ) Is there something in addition to this that you would expect?

Categories : Javascript

Get the MappingResult firstObject value within the Persistent Storage to avoid "Illegal attempt to establish relationships" errors
You should get RestKit to connect the relationship using foreign key mapping based on the author id. That way all of the updates are made at the same time, in the same context, and saved before the mapping result is returned.

Categories : Objective C

How to Iterate a Registry Folder using Batch Script?
reg query "HKLMSoftwareMicrosoftWindowsCurrentVersionInstallerFolders"|find /i "Office14" >nul 2>&1 && set "RESULT=FOUND" echo %RESULT% appended after the question is answered: target string is: C:Program FilesMicrosoft OfficeOffice14 REG_SZ getting the path name here is a bit difficult because of trailing spaces/tabs. I suggest a solution with sed for Windows: for /f "delims=" %%a in ('reg query "HKLMSoftwareMicrosoftWindowsCurrentVersionInstallerFolders"^|sed -nr "/\Office14\/Is/s+(.*)s+REG_SZ/1/p"') do SET "OFFICEPATH=%%~a" echo %OFFICEPATH% And a more advanced solution without sed: @ECHO OFF &SETLOCAL for /f "tokens=*" %%a in ('reg query "HKLMSoftwareMicrosoftWindowsCurrentVersionInstallerFolders"^|find /i "Office14"') do SET "OFFICEPATH=%%

Categories : Windows

Registry Update via Batch File Issue
The issue came that MS has a patch in place for IE that does not allow this type of 'backdoor' method. GPO or Internet Options in IE are the only ways to officially implement these settings. That is why the settings were changing back once IE was opened after I ran my script successfully.

Categories : Internet Explorer

How to create a batch file which will prompt for the User's name and password and then writes them into registry?
This is quite easy. @echo off set /p username="Please enter your username: " set /p passwd="Please enter your password: " cls reg add HKCUSOFTWARESSIS /v USER /t REG_SZ /d %username% /f reg add HKCUSOFTWARESSIS /v PASSWORD/t REG_SZ /d %passwd% /f exit be aware, that as you type your password into the console it is visible. There is a way to hide the password, but it is very uncommon. Let me know, when you need it.

Categories : Windows

Script Bash & Batch - Resolution in Wine & Windows Registry For Some Games
Under Cygwin (or possible some lighter environments as well) this would give you your resolution: #!/bin/bash ScreenWidth=$(wmic desktopmonitor get screenwidth | grep -o '[[:digit:]]+') ScreenHeight=$(wmic desktopmonitor get screenheight | grep -o '[[:digit:]]+') Resolution="${ScreenWidth}x${ScreenHeight}" ... Credits to Endoro for suggesting the command wmic.

Categories : Bash

set batch size in spring JDBC batch update
There is no option for jdbc that looks like Hibernate; I think you have to get a look to specif RDBMS vendor driver options when preparing connection string. About your code you have to use BatchPreparedStatementSetter.getBatchSize() or JdbcTemplate.batchUpdate(String sql, final Collection<T> batchArgs, final int batchSize, final ParameterizedPreparedStatementSetter<T> pss)

Categories : Spring

Spring Security Reauthentication with Persistent Logins
You should find the existing database entry for the user. This can be done by username. Then you can set a new database entry as a persistent token with rememberMeServices.loginSuccess. Finally, you have to reauthenticate your user.

Categories : Spring

I'm trying to use Java Prefences from XML WITHOUT using Windows registry, but I see a Registry-related message
I eventually discovered a workaround (not a solution) to this problem. As I stated before, I had inadvertently/foolishly deleted the Prefs node in SoftwareJavaSoft in the Registry, and when I recreated it the message went away. I now assume that the Windows registry is used whether you like it or not.

Categories : Java

Regarding Spring Batch
Why dont you run it by using org.springframework.batch.core.launch.support.CommandLineJobRunner you can define it as your main class in Run Configuration of eclise. In Arguments give <your batch-job-xml-file><space><your Job (in your case its simpleJob)> You dont need maven here too. Just set classpath of required libraries.

Categories : Spring

Getting error with Spring batch
I think you are mixing different versions of springbatch. Try downloading the latest version of all the jars and execute it. Similar problem was posted by someone in the SpringSource Forum, in this link

Categories : Spring

Spring batch 2.2 JavaConfig
Assuming that no other artifacts require a DataSource, you can use java config to create a context without a DataSource. To do that, your configuration will need to extend DefaultBatchConfigurer as you point out. In there, you'll override two methods, createJobRepository() and setDataSource(). Below is an example context (it doesn't define a job or steps, but it bootstraps all the related beans correctly). @Configuration @EnableBatchProcessing public static class BatchConfiguration extends DefaultBatchConfigurer { @Override protected JobRepository createJobRepository() throws Exception { MapJobRepositoryFactoryBean factory = new MapJobRepositoryFactoryBean(); factory.afterPropertiesSet(); return (JobRepository) factory.getObject(); }

Categories : Java

Spring batch job with unique jobParamIncrementer
It looks like you don't pass the job name to the CommandLineJobRunner. Try changing the call to CommandLineJobRunner.main in JobRunner.main() method to: CommandLineJobRunner.main(new String[] { "applicationContext.xml", "uniqueJob", id});

Categories : Spring

Spring-batch and file upload
The link below might solve your problem. The information you have given is not helping me dig deep into the problem. Link for Solution If you are still not able to solve this, give me the below details: 1) When you debug are you able to get into the importUsers in the debug mode? 2) Is the file (which the code is trying to read) in the classpath.

Categories : Spring

Spring Batch 'RunIdIncrementer' not generating next value
This might be a long shot but it took me a long time to figure it out because the only symptom was sporadically getting the JobInstanceAlreadyCompleteException as you describe so I figured I'd suggest it. The database I was using was Oracle and the BATCH_JOB_SEQ and BATCH_JOB_EXECUTION_SEQ I had created both had a CACHE_SIZE of 10. This had the effect of sometimes causing the JOB_INSTANCE_ID and JOB_EXECUTION_ID to not be ordered correctly. Spring batch makes the assumption that the most recent JOB_INSTANCE is the one with max(JOB_INSTANCE_ID) (see org.springframework.batch.core.repository.dao.JdbcJobInstanceDao.FIND_LAST_JOBS_BY_NAME). Since my sequence was sometimes thrown off, this assumption did not always hold true. I fixed it by setting the sequences to NO_CACHE. An easy way to t

Categories : Spring

spring batch : Tasklet without ItemWriter
Well, in a chunk, A reader and a Writer are MANDATORY! however, The ItemProcessor is optional. This is from the official doc : 5.1.1. Configuring a Step Despite the relatively short list of required dependencies for a Step, it is an extremely complex class that can potentially contain many collaborators. In order to ease configuration, the Spring Batch namespace can be used: <job id="sampleJob" job-repository="jobRepository"> <step id="step1"> <tasklet transaction-manager="transactionManager"> <chunk reader="itemReader" writer="itemWriter" commit-interval="10"/> </tasklet> </step> The configuration above represents the only required dependencies to create a item-oriented step: reader - The ItemReader that provide

Categories : Java

Start a spring batch job when already within a transaction
Use AbstractJobRepositoryFactoryBean.ValidateTransactionState, but use carefully (Warning: Dragons ahead). To use another transaction you can inject a custom SimpleJobLauncher.executor with method Executor.run marked as @Transactional() (or create a custom JobLauncher and do the same trick on method run). I haven't tried because I haven't faced the problem, but hope can help.

Categories : Java

How to write more then one class in spring batch
You can use a CompositeItemWriter. But perhaps your summary processing should be in another step which reads the rows you previously inserted

Categories : Spring

How to resolve Spring Batch Error?
Which versione of spring-batch are you using? With 2.2.1.RELEASE (and 3.2.3.RELEASE of Spring framework) this example works fine! Libraries (from maven) are: org.springframework spring-core spring-beans spring-context spring-batch-core spring-batch-infrastructure

Categories : Java

why do I need the prefix 'batch:' in my spring beans
batch is the alias in your XML file for the http://www.springframework.org/schema/batch namespace. You'll have something like this at the beggining of your XML: xmlns:batch="http://www.springframework.org/schema/batch" This means that whenever you're prefixing an element with batch:, you're specifying that the element is the one Spring defines. This is necessary to clear out possible ambiguities (there might be other frameworks around defining the <job> element). It is possible to define a default namespace for all elements in the XML document, so that if no namespace is prefixed, it'll be the one that the declaration is referring to. This default namespace is defined with the xmlns="..." attribute, and is usually assigned to the http://www.springframework.org/schema/beans name

Categories : Xml

is nested chunks in spring batch possible
You can't have nested chunk so you can code your own CompositeItemReader like(pseudo-code): class CompositeItemReader implements ItemReader<Transaction> { ItemReader<Promotion> promotions; ItemReader<Transaction> transactions; public void setPromotions(ItemReader<Promotion> promotions) {...} public Transaction read() { Transaction item = transactions.read(); if(null == item) { Promotion p = promotions.read(); if(null != p) { // Close transactions reader, create dynamic query and open transaction reader // Re-read item! item = this.read(); } } return item; } } but remember to register promotions and transactions as stream and remember to manage restartability. Or, if you are sure each Promotion

Categories : Spring

Transaction management with Spring Batch
You need to explicitly reference your Transaction Manager in your step definition: <job id="sampleJob" job-repository="jobRepository"> <step id="step1"> <tasklet transaction-manager="transactionManager"> <chunk reader="itemReader" writer="itemWriter" commit-interval="10"/> </tasklet> </step> </job> See: 5.1.1. Configuring a Step Ah, seeing that you use JavaConfig, you need to assign the transaction manager to the TaskletStepBuilder using builder.transactionManager(transactionManager) (inherited from StepBuilderHelper)

Categories : Java

spring batch remains in EXECUTING
the current release of Spring Batch (2.2.0) doesn't appear to have an out of the box solution for this situation. as discussed in this question, 'manual' intervention in the database may be required. alternatively, if this is a particular job that is hanging (that is, you know the job name), you can do the following as well; use the JobExplorer.findRunningJobExecutions(jobName) go through the list of executions and 'fail' them (JobExecution.upgradeStatus(BatchStatus.FAILED)) save the change using JobRepository.update(jobExecution)

Categories : Java

Could not Autowired JobLauncherTestUtils in Spring-Batch
After some googling found out that a bean definition needs to be specified in the context.xml used for JUnit testing. <bean id="jobLauncherTestUtils" class="org.springframework.batch.test.JobLauncherTestUtils" > <property name="job" ref="custom.entities"/> <property name="jobRepository" ref="jobRepository"/> <property name="jobLauncher" ref="jobLauncher"/> </bean> With above definition I am able to autowire JobLauncherTestUtils.

Categories : Spring

Getting NullPointerException in Spring Batch when tomcat is shut down
I have not tried with spring quartz. However, normally while using Quartz, we shutdown the quartz gracefully. By gracefully, I mean here that I will shutdown the scheduler only after executing all my pending jobs(jobs which are executed currently but have not yet marked their completion). For graceful shutdowns, we pass attribute true while using method shutdown. Refer API here I am eager to know how spring quartz implementation does this.

Categories : Spring

How to write to a compressed file in spring-batch
I agree with Matthias' answer but I think 1-step solution is not restartable. Do you have some requirements of restartability? Look at append-to-a-compressed-stream

Categories : Java

Spring batch one reader multiple writers
What do you mean by "multiple writers"? What you are trying to achieve seems NOT multiple writers, but a single writer with multiple-threads. To be clear, when we are talking about "multiple writer", we mean a reader read a chunk, and need to do different kind of "writing" for the chunk. e.g. you may have a PlayerRecordReader which read Player from somewhere, and you have PlayerDbWriter and PlayerFileWriter which writes to DB and File. Multiple writer are not for distributing the load. For case that you want the writing to be done in parallel, what you need is a single writer (of course you need to make it thread-safe) and using executor in your step definition. This page in Spring Batch give you clear instruction on how to do it. http://static.springsource.org/spring-batch/referenc

Categories : Spring

Spring Batch reading csv columns in different order
Spring-batch reads and tokenize fields from CSV in sequence, as expected. The problem is in BeanWrapperFieldSetMapper: to inject FieldSet values into bean's properties mapper pass from an String[] (ordered with your field names) to a Properties (look FieldSet.getProperties()) to match property-value. I think you can achieve your goal using a StepExecutionListener and intercept item after reading (you will get your mappedPosition fully popolated)

Categories : Csv

spring batch StaxEventItemReader release out an exception
Before all check this thread and check if your xml file is composed by a single object element like: <Object> <child1>...</child1> <child2>...</child2> <child3>...</child3> </Object> because StAX reader implementation works for files like <root> <Object>...</Object> <Object>...</Object> <root> If this solve the problem, stop reading! Else apparently there aren't errors in your configuration. Assuming latest version (2.2.1.RELEASE) Error is in this line at StaxEventItemReader.moveCursorToNextFragment() while (reader.peek() != null && !reader.peek().isStartElement()) { so, most probably, reader is null; or you have unmarshal problems and reader go into trouble. Is error thrown at

Categories : Xml

Spring Batch ItemReader list processed only once
The problem is that you marked your reader as scope="prototype". It should be scope="step". In Spring-batch there are only two scopes: singleton (the default) and step. From the javadoc: StepScope: Scope for step context. Objects in this scope use the Spring container as an object factory, so there is only one instance of such a bean per executing step. All objects in this scope are (no need to decorate the bean definitions). and Using a scope of Step is required in order to use late binding since the bean cannot actually be instantiated until the Step starts, which allows the attributes to be found. During the Spring context startup look at your log and you will see this line: INFO: Done executing SQL script from class path resource [org/springframework/batc

Categories : Java

How to implement batch operations with MyBatis/Spring?
I'm not sure I understand the question fully correct but I will try to give you my thoughts. For making the single service I would recommend to generify the service interface: public void bulkUpload (@RequestBody List<T> myRecords) Then you can check the type of the object and call the propper mapper repository. Then you can generify it more by creating a common interface: public interface Creator<T> { void create(T object); } and extend it by your mapper interface: public interface MyService extends Creator<MyRecord>{} Now the most complicated step: you get the object of a particular type, see what exact mapper implements the Creator interface for this class (using java reflection API) and invoke the particular method. Now I give you the code I use in on

Categories : Java

JPA Hibernate bulk/batch update in Spring MVC
what you've got is pretty much the standard way of updating multiple rows via JPA. event spring-data-jpa that exposes save(Iterable<T> items) just loops over the Iterator under the covers. here's another question that is answered very nicely on the options, but in short, you're on the right path with the alternative being to formulate and execute the update statement yourself. update: executing in a single transaction may increase performance as you only have the transaction overhead once. you also get the scenario where if one of the updates fail, any previous ones are rolled back too. (so, potentially you lose all the 'work' from previous updates - you may or may not want that) also, be aware of the transaction manager type you're using (e.g. JTA or JPA) and the JPA implementa

Categories : Hibernate

Spring batch : call beforeProcess on ItemProcessListener only once
Your best choice to be sure method is called once is to use a StepExecutionListener and bind this listener to step where you use your ItemProcessor. Else, if you need to call just before ItemProcessor.process() add a ItemProcessListener and manage a flag in StepExecutionContext: if this flag is not setted (false) or absent call the method and set flag to true else do nothing. But if you can be more precise about your use-case a better solution can be found. Hope can help!

Categories : Spring

How to stop file transferring in spring-batch
From ConsumerTemplate's javadoc receiveBody waits until there is a response; you need to work with timeout (check TimeoutPolicy in spring-batch) or a different way to mark reader as 'exhausted' (return null from reader) to stop reader from reading

Categories : Spring

problems in spring batch mongo itemreader?
Robin? Is that you? I posted the same question to Spring Forums some time ago and forgot about it. This is why it's happening: I discovered that the processor was changing the field cdrStatus to COMPLETED. That way, when the reader requested the new page and it's using limit and skip, the changed records of the first page where not included in the new page request so the 'new' first page was skipped and records not retrieved. What I don't know if it's the expected behavior. You can find the thread here: http://forum.spring.io/forum/spring-projects/batch/129604-problems-with-mongoitemreader

Categories : Spring



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.