I'm working with some Java that I generate with JAXB but I don't think the JAXB is the problem since the structure of the code generated matches the getter and setter methods for Spring properties that now work but earlier on gave me this same type of exception.
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'previousCurrentEstateNo' of bean class [ca.qc.ic.osb.efilingClasses.EIS]: Bean property 'previousCurrentEstateNo' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
The difference here is the use of a String array. I've tried the various suggestions that are supposed to work without success. I'm using Spring 3.0.6.
<bean id="eisJointSummary" class="ca.qc.ic.osb.efilingClasses.EIS"
scope="prototype" lazy-init="true">
<property name="previousCurrentEstateNo" >
<list>
<value>1234</value>
</list>
</property>
</bean>
within EIS class:
public static class Estate
{
protected String[] previousCurrentEstateNo;
public String[] getPreviousCurrentEstateNo() {
if (this.previousCurrentEstateNo == null) {
return new String[ 0 ] ;
}
String[] retVal = new String[this.previousCurrentEstateNo.length] ;
System.arraycopy(this.previousCurrentEstateNo, 0, retVal, 0, this.previousCurrentEstateNo.length);
return (retVal);
}
public String getPreviousCurrentEstateNo(int idx) {
if (this.previousCurrentEstateNo == null) {
throw new IndexOutOfBoundsException();
}
return this.previousCurrentEstateNo[idx];
}
public int getPreviousCurrentEstateNoLength() {
if (this.previousCurrentEstateNo == null) {
return 0;
}
return this.previousCurrentEstateNo.length;
}
public void setPreviousCurrentEstateNo(String[] values) {
int len = values.length;
this.previousCurrentEstateNo = ((String[]) new String[len] );
for (int i = 0; (i<len); i ++) {
this.previousCurrentEstateNo[i] = values[i];
}
}
public String setPreviousCurrentEstateNo(int idx, String value) {
return this.previousCurrentEstateNo[idx] = value;
}
Thanks
You are creating a bean of the type ca.qc.ic.osb.efilingClasses.EIS and that class doesn't have a previousCurrentEstateNo property.
From what I can tell from the information you provided the previousCurrentEstateNo is a property of Estate.
I am assuming that EIS has a property of type Estate?
Try something to this effect:
<bean id="eisJointSummary" class="ca.qc.ic.osb.efilingClasses.EIS"
scope="prototype" lazy-init="true">
<property name="nameOfTheEstatePropertyInEIS">
<bean class="ca.qc.ic.osb.efilingClasses.EIS.Estate">
<property name="previousCurrentEstateNo">
<list>
<value>1234</value>
</list>
</property>
</bean>
</property>
</bean>
Related
i am getting "Marshalling Error: class tavant.twms.integration.layer.component.hsmComponent.HSMAddressResponse nor any of its super class is known to this context". i have added the annotations as well, but still not resolved. below are my files,
cxf-servlet.xml
<bean id="integrationServiceImpl" class="tavant.twms.integration.layer.IntegrationServiceImpl"/>
<jaxws:endpoint id="integrationService" implementor="#integrationServiceImpl" address="/IntegrationService">
<jaxws:dataBinding>
<bean class="org.apache.cxf.jaxb.JAXBDataBinding"/>
</jaxws:dataBinding>
</jaxws:endpoint>
#webmethod
public Object fetchHSMAddressDetails(String addressxml){
securityHelper.populateIntegrationUser();
HSMAddressRequestDocumentDTO requestDTO = null;
HSMAddressRequest request = null;
try {
requestDTO = HSMAddressRequestDocumentDTO.Factory.parse((String) addressxml);
} catch (XmlException e) {
throw new RuntimeException(e);
}
if(requestDTO == null)
return null;
request = requestDTO.getHSMAddressRequest();
return hsmAddressFetch.fetchMelissaData(request);/* return type is HSMAddressResponse*/
}
ow can I filter using multiple attributes? (simulating an "AND"
operation)
I have tried:
ofy().load().type(Produit.class).filter("idListe in",collectionProduits.getIdListes()).filter("supprime !=",true).list();
This is my entity:
#Entity
public class Produit implements Serializable{
private static final long serialVersionUID = xxxxxxxxxxxxxx;
#Id
private Long id;
#Index
private Long idliste;
#Index
private Boolean supprime;
public Produit() {
// TODO Auto-generated constructor stub
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getIdliste() {
return idliste;
}
public void setIdliste(Long idliste) {
this.idliste = idliste;
}
public Boolean getSupprime() {
return supprime;
}
public void setSupprime(Boolean supprime) {
this.supprime = supprime;
}
I have this critical error:
Uncaught exception from servlet java.io.IOException:
com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException:
no matching index found. The suggested index for this query is:
<datastore-index kind="Produit" ancestor="false" source="manual">
<property name="idliste" direction="asc"/>
<property name="supprime" direction="asc"/>
</datastore-index>
(through reference chain:
com.listecourses.model.CollectionProduits["produits"]) at
com.google.api.server.spi.response.ServletResponseResultWriter.writeValueAsString(ServletResponseResultWriter.java:187)
at
com.google.api.server.spi.response.ServletResponseResultWriter.write(ServletResponseResultWriter.java:74)
at
....
After seeing this error, I changed my datastore-indexes.xml to this:
<?xml version="1.0" encoding="utf-8"?>
<datastore-indexes autoGenerate="false">
<datastore-index kind="Produit" ancestor="false" source="manual">
<property name="idliste" direction="asc"/>
<property name="supprime" direction="asc"/>
</datastore-index>
</datastore-indexes>
I re-deployed after creating this file. I waited a little bit of time for the index to generate. And I have the same error on log of appengine.
more, I have this error log on eclipse:
No projects found for [C:\workspace\example-AppEngine\war\datastore-indexes.xml]
The file process strategy checks databases for specific preprocess conditions/steps were executed before processing a file XYZ.
The files XYZ comes from different sub directories of a root directory that camel scans.
If one of the file is not eligible camel should move to the next one. Not sure what flag should I use if any so it won't bother checking the current file again and again instead of moving to the next one.
My File process Strategy:
public class MigrFileProcessStrategy<T> extends GenericFileProcessStrategySupport<T> {
private static final Logger log = LoggerFactory.getLogger(MigrFileProcessStrategy.class);
#Autowired
DefaultMigrationProcessor defaultMigrationProcessor;
#Override
public boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, Exchange exchange, GenericFile<T> file) throws Exception {
//check if HIST table has entry for this filename, if yes all preprocessing done, file is ready.
boolean readyForProcessing = false;
String fileAbsPath = file.getAbsoluteFilePath();
File inMigrFile = new File(fileAbsPath);
readyForProcessing = defaultMigrationProcessor.isFileReadyForProcessing(inMigrFile);
if (!readyForProcessing) {
String msg = String.format("\n####Process?:%b File:%s", readyForProcessing, fileAbsPath);
log.info(msg);
}
return readyForProcessing;
}
}
My Config:
<bean id="migrFilesToCopy" class="org.apache.camel.component.file.MigrFileFilter">
<!-- Filter for migr files that need to be copied-->
<property name="caseSensitive" value="true" />
<property name="excludes" value="**/**/*.migratedLnk, **/_inProgress/**, **/_done/**, **/_failed/**" />
</bean>
<endpoint id="endpoint_migrFilesToCopy"
uri="file://#{migrationProcessor.migrRootDir.toFile()}?processStrategy=#migrFileProcessStrategy&directoryMustExist=true&idempotent=true&recursive=true&delete=true&initialDelay=1000&delay=5000&readLock=changed&readLockTimeout=100000&readLockCheckInterval=1000&moveFailed=_failed&maxMessagesPerPoll=10&filter=#migrFilesToCopy" />
<route id="chMigrate" autoStartup="true">
<from uri="ref:endpoint_migrFilesToCopy" />
<pipeline>
<log message="Procesing file: ${header.CamelFileName}" />
<!--threads executorServiceRef="migrThreadPool" -->
<bean ref="migrationProcessor" method="createMetadata" /><!-- MetaDataVo -->
<bean ref="migrationProcessor" method="createCopyObj" /><!-- CacheCopyObj -->
<bean ref="migrationProcessor" method="migrate" />
<!--/threads -->
</pipeline>
</route>
Resolved by extending ant filter:
public class MigrFileFilter extends AntPathMatcherGenericFileFilter implements GenericFileFilter {
private static final Logger log = LoggerFactory.getLogger(MigrFileFilter.class);
#Autowired
DefaultMigrationProcessor defaultMigrationProcessor;
public MigrFileFilter() {
super();
}
#Override
public boolean accept(GenericFile<T> file) {
String fileAbsPath = file.getAbsoluteFilePath();
File inMigrFile = new File(fileAbsPath);
boolean readyForProcessing = false;
if (Files.isDirectory(inMigrFile.toPath())) {
readyForProcessing = true; //To recursivly process directories.
} else {
boolean validFilePatten = super.accept(file);
boolean preprocessDataExist = false;
if (validFilePatten) {
preprocessDataExist = defaultMigrationProcessor.isFileReadyForProcessing(inMigrFile);
}
readyForProcessing = (validFilePatten && preprocessDataExist);
}
return readyForProcessing;
}
Use the filter to filter out unwanted files
You can implement a custom implementation, and just return true|false if you want to include the file or not.
See the section Filter using org.apache.camel.component.file.GenericFileFilter at
http://camel.apache.org/file2
We are using RestEasy Client version 3.0*.
We are trying to post very large content in the request body.
When the content length is less than 1 MB the following code is running correctly.
When the content length is very large (about 500 MB) the request is getting stuck.
The code is looking like this:
InputStream inputStream = new FileInputStream(tempFile);
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target("<SomeUrl>");
response = target.request(MediaType.WILDCARD).post(Entity.entity(inputStream, MediaType.WILDCARD));
How should I change the code to support large content?
After a week...
Since nobody answered me - I used the good old Spring solution (see below).
Is Spring better than RestEasy client?
InputStream inputStream = new FileInputStream(tempFile);
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setBufferRequestBody(false);
RestTemplate r = new RestTemplate(factory);
RequestCallback requestCallback = new RequestCallback() {
#Override
public void doWithRequest(ClientHttpRequest clientHttpRequest) throws IOException {
List<org.springframework.http.MediaType> MEDIA_TYPES = Collections.unmodifiableList(Arrays.asList(org.springframework.http.MediaType.ALL));
clientHttpRequest.getHeaders().setAccept(MEDIA_TYPES);
OutputStream requestOutputStream = clientHttpRequest.getBody();
try {
int copiedBytes = IOUtils.copy(inputStream, requestOutputStream);
} finally {
IOUtils.closeQuietly(requestOutputStream);
}
}
};
ResponseExtractor<Response> responseExtractor = new ResponseExtractor<Response>() {
#Override
public Response extractData(ClientHttpResponse response) throws IOException {
return Response.status(response.getRawStatusCode()).build();
}
};
response = r.execute(url, HttpMethod.POST, requestCallback, responseExtractor);
I guess in Spring 4.0.1 you can use Apache HTTP client and HttpComponentsClientHttpRequestFactory instead of SimpleClientHttpRequestFactory. Here is the original note: SPR-10728
<bean id="restTemplateStreaming" class="org.springframework.web.client.RestTemplate">
<constructor-arg>
<bean class="org.springframework.http.client.HttpComponentsClientHttpRequestFactory">
<property name="bufferRequestBody" value="false" />
<property name="httpClient">
<bean class="com.spotfire.server.http.spring.HttpClientFactory">
<property name="clientBuilder">
<bean class="org.apache.http.impl.client.HttpClientBuilder">
<property name="connectionManager" ref="poolingHttpClientConnectionManager" />
<property name="redirectStrategy">
<bean class="org.apache.http.impl.client.LaxRedirectStrategy" />
</property>
</bean>
</property>
</bean>
</property>
</bean>
</constructor-arg>
</bean>
Note the
However callback implementation changes as well. You no longer can call clientHttpRequest.getBody();
Instead you have to use a bit convoluted structure as shown below:
class StreamingRequestCallback implements RequestCallback {
private final InputStream inputStream;
StreamingRequestCallback(InputStream inputStream) {
this.inputStream = inputStream;
}
#Override
public void doWithRequest(final ClientHttpRequest request) throws IOException {
request.getHeaders().add("Content-type", MediaType.APPLICATION_OCTET_STREAM_VALUE);
((StreamingHttpOutputMessage) request).setBody(new StreamingHttpOutputMessage.Body() {
#Override
public void writeTo(final OutputStream outputStream) throws IOException {
IOUtils.copy(inputStream, outputStream);
}
});
}
};
I developed a web service with CXF and It work fine.
I have a service with two input parameters and both of them should be mandatory.
but when I call my service just the first parameter is mandatory.
please let me know what should I do?
my SEI
#WebService(
endpointInterface = "com.myCompany.product.webService",
targetNamespace = "http://product.myCompany.com",
portName = "product",
serviceName = "ProductService")
#DataBinding(org.apache.cxf.aegis.databinding.AegisDatabinding.class)
public interface ProductService {
#WebMethod(operationName = "authentication")
#WebResult(name = "authenticationResponseParam")
public AuthenticationResponseParam authentication(#WebParam(name = "user", header = true) String user,
#WebParam(name = "authenticationRequestParam") AuthenticationRequestParam authenticationRequestParam);
}
and my AuthenticationResponseParam class
#XmlAccessorType(XmlAccessType.FIELD
)
#XmlType(name = "authenticationRequestParam", propOrder = {
"account", "password"
})
public class AuthenticationRequestParam implements Serializable {
#XmlElement(name = "account", required = true)
private BigDecimal account;
#XmlElement(name = "password", required = true)
private String password;
public BigDecimal getAccount() {
return account;
}
public void setAccount(BigDecimal account) {
this.account = account;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
#Override
public String toString() {
return "AuthenticationRequestParam{" +
"account=" + account +
", password='" + password + '\'' +
'}';
}
}
and my CXF servlet 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:jaxws="http://cxf.apache.org/jaxws"
xmlns:cxf="http://cxf.apache.org/core"
xmlns:soap="http://cxf.apache.org/bindings/soap"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd
http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
http://cxf.apache.org/bindings/soap
http://cxf.apache.org/schemas/configuration/soap.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml"/>
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
<import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
<cxf:bus>
<cxf:features>
<cxf:logging/>
</cxf:features>
</cxf:bus>
<!--Data binding-->
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype"/>
<bean id="jaxws-and-aegis-service-factory"
class="org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean"
scope="prototype">
<property name="dataBinding" ref="aegisBean"/>
</bean>
<jaxws:endpoint id="telBank" implementor="#myService" address="/telBank">
<jaxws:binding>
<soap:soapBinding mtomEnabled="false" version="1.2"/>
</jaxws:binding>
</jaxws:endpoint>
<bean id="myService" class="com.myCompany.product.webService.impl.ProductServiceImpl"/>
</beans>
thank you
Hey guys
I added a new service in my web service
public BigDecimal sample(#WebParam(name = "sam1") BigDecimal a1,#WebParam(name = "sam2") BigDecimal a2);
and none of both parameters are mandatory
what should I do?please help me
I found what my problem.
I use org.apache.cxf.aegis.databinding.AegisDatabinding az data binder and it just recognize primitive type az mandatory.when I commend that my input param become mandatory.
what kind of data binder should I use?
If you want to use AegisDatabinding class as data binder,set this property it bean definition.
<bean id="aegisBean" class="org.apache.cxf.aegis.databinding.AegisDatabinding" scope="prototype">
<property name="configuration">
<bean class="org.apache.cxf.aegis.type.TypeCreationOptions">
<property name="defaultMinOccurs" value="1"/>
<property name="defaultNillable" value="false"/>
</bean>
</property>
</bean>