How to activate datanucleus java-type extensions for JPA? - google-app-engine

I have a simple JPA #Entity that has a property of type
java.util.Locale.
When I try and persist this, I get the following error:
java.lang.IllegalArgumentException: locale: java.util.Locale is not a supported property type.
at com.google.appengine.api.datastore.DataTypeUtils.checkSupportedSingleValue( DataTypeUtils.java:174)
...
In the appengine SDK (1.3.1), datanucleus-core-1.1.5.jar contains
plugin.xml which contains the following type conversion "extension":
<java-type name="java.util.Locale" persistent="true" embedded="true"
string-converter="org.datanucleus.store.types.LocaleStringConverter"/>
How do I "activate" this type converter in my #Entity class?

This seems to be a significant limitation of Google's use of datanucleus. See the following (2nd last heading):
http://datanucleus.blogspot.com/2010/01/gaej-and-jdojpa.html

Related

camel - spring:bean syntax with dynamic class casting

I'm attempting to convert the following Java object initalization with dynamic class casting to camel spring bean syntax. I'm adding my broken spring bean sample as well. I dont have much familiarity with spring beans, so would very much appreciate some input. The Java syntax is:
import com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider;
STSAssumeRoleSessionCredentialsProvider credentials = new STSAssumeRoleSessionCredentialsProvider.Builder(
"arn:aws:iam::***:role/myRole-QA", "sessionName").build();
and broken spring bean:
<spring:bean id="sqsCredentials" class="com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider.Builder" >
<spring:constructor-arg index="0" value="arn:aws:iam:***:role/myRole-QA" />
<spring:constructor-arg index="1" value="sessionName" />
<spring:property name="targetMethod">
<spring:value>build</spring:value>
</spring:property>
</spring:bean>
I'm not sure if what I have for method build is correct, but there are two classes at play: .Builder and just STSAssumeRoleSessionCredentialsProvider. So Builder class returns STSAssumeRoleSessionCredentialsProvider. Most likely i have more then one issue to solve here, but the error I think is related to class mismatch ... much appreciate your time:
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'targetMethod' of bean class
[com.amazonaws.auth.STSAssumeRoleSessionCredentialsProvider$Builder]: Bean property 'targetMethod' is not writable
or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

Extracting Salesforce data using Camel throws org.apache.camel.NoTypeConversionAvailableException

I am new to Apache Camel and working on a simple java program that can extract Salesforce custom object data using Apache Camel. While running the program it throws org.apache.camel.NoTypeConversionAvailableException. Objects QueryRecordsLine_Item__c and Line_Item__c implements Serializable interface. Kindly help me to fix this.
Code snippet:
from("direct:query")
.to("salesforce:query?sObjectQuery=SELECT name, Unit_Price__c, Units_sold__c, Merchandise__c, Invoice_Statement__c from Line_Item__c&sObjectClass=" + QueryRecordsLine_Item__c.class.getName())
.to("file:E:\\ajagan\\datafiles\\out");
Exception:
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: org.apache.camel.component.salesforce.dto.generated.QueryRecordsLine_Item__c to the required type: java.io.InputStream with value {"done":true,"totalSize":280,"records":[.....]}
at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:181)
at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
... 31 more
You should add camel-jaxb to the classpath, so Camel can covert the salesforce DTO objects (they are JAXB annottated) to XML representation in a stream, that the file endpoint can use.
How about you try converting to a string first:
from("direct:query")
.to(...)
.convertBodyTo(String.class)
.to(...)

Unable to pick up custom camel converter

I've created a new converter with the following structure:
package com.mycompany;
#Converter
public final class MyCustomConverter {
#Converter
public static TypeB convert(TypeA typeA) {
// do the conversion
}
}
I've also created in my src/main/java/resources folder the following package, META-INF.services.org.apache.camel and within that a TypeConverter file which just says:
com.mycompany
Within my route from TypeA I have got:
<convertBodyTo type="com.mycompany.TypeB" />
Yet my tests constantly fail to pick up the file and thus cannot find the converter, with the exception being:
Caused by: org.apache.camel.NoTypeConversionAvailableException: No
type converter available to convert from type: com.mycompany.TypeA to
the required type: com.mycompany.TypeB with value TypeA[value1="blah"]
Am I meant to do something else to get my test to pick up the TypeConverter file? Surely putting it in that resources folder with the exact structure adds it to the classpath and so it would be accessible.
Its recommended in the TypeConverter file to list the FQN of all the type conveters, eg
com.mycompany
Should be
com.mycompany.MyCustomConverter
This is also what we say on this page: http://camel.apache.org/type-converter.html
And could you check inside the generated JAR file of yours, that the META-INF/services/org/apache/camel directory is there, and that the TypeConverter file is present (and it is not in some directory like META-INF/org.apache.camel).
Also what is the runtime environment you use? Do you run Camel standalone, Tomcat, OSGi or something else?

Fully qualified class name while using exceptionSuper argument in CXF Wsdl2Java utilty

This is related to this question and the subsequent patch applied to cxf .
When using a WSDL-first approach to generate java stubs, is there a way to make exceptions extend RuntimeException instead of Exception?
Thanks Daniel and Piepera for the patch . But the generated code only adds the classname instead of fully qualified name and there is no import statement added for the custom exception supplied.
I have specified to use "com.google.adwords.api.AdwordsException" as exceptionSuper and wsdl2java maven plugin creates the following wsdl fault . But it didn't add an import statement for com.google.adwords.api.AdwordsException and compilation failed.
#WebFault(name = "ApiExceptionFault", targetNamespace = "https://adwords.google.com/api/adwords/billing/v201209")
public class ApiException extends AdwordsException {
Could you please fix it to either add the import statement or use the fully qualified name.
WSDL2JAVA Usage
wsdl2java -d C:\Dev\src\main\java -exceptionSuper com.google.adwords.api.AdwordsException -client -verbose -xjc-Xvalue-constructor -xjc-npa https://adwords.google.com/api/adwords/cm/v201209/CampaignService?wsdl

mybatis config problem

I'm new to MyBatis.
Ive been trying to configure mybatis in a webservice I'm writing but with no luck yet.
What I've done already is,
UserInfoMapper interface
UserInfoMapper.xml with mapper namespace with my UserInfoMapper interface and a select
mybatis-config.xml with typeAlias to use as result type in UserInfoMapper.xml
dataSource bean for oracle (I get connected) in datasourceContext.xml
org.mybatis.spring.mapper.MapperScannerConfigurer bean with basePackage pointing to my UserInfoMapper interface in datasourceContext.xml
sqlSessionFactory bean ie. org.mybatis.spring.SqlSessionFactoryBean with property for my dataSource and configLocation
userInfoMapper bean ie. org.mybatis.spring.mapper.MapperFactoryBean with property mapperInterface (value="is.simnn.act.web.ngs.persistence.UserInfoMapper") and sqlSessionFactory property (ref="sqlSessionFactory") in datasourceContext.xml
then in my applicationContext.xml I have following,
<import resource="classpath:META-INF/wsContext.xml" />
<import resource="classpath:META-INF/db/datasourceContext.xml" />
In my test case I keep getting NullPointerException when I call jaxws:endpoint and it leads me to my UserInfoMapper interface.
Any idea or hints to what might be wrong with my config?
Thanks,
Gunnlaugur
It is hard to comment without having more information. Can you post your UserInfoMapper.java interface, your UserInfoMapper.xml and your stack trace, please? Are you certain that the method name in your interface matches the ID of your SELECT in the XML?

Resources