problem with open jpa - jpa

I am getting following error on console when using open jpa.What may be the possible cause?I cant post the code as its against my company policies.
[12/31/10 14:54:13:279 GMT+05:30] 00000063 MetaData W CWWJP9991W: openjpa.MetaData: Warn: OpenJPA cannot map field "abc.xyz" efficiently. It is of an unsupported type. The field value will be serialized to a BLOB by default.
[12/31/10 14:54:13:295 GMT+05:30] 00000063 MetaData W CWWJP9991W: openjpa.MetaData: Warn: The class "pqr.xyz" listed in the openjpa.MetaDataFactory configuration property could not be loaded; ignoring.
[12/31/10 14:54:13:295 GMT+05:30] 00000063 MetaData W CWWJP9991W: openjpa.MetaData: Warn: OpenJPA cannot map field "pqr.xyz" efficiently. It is of an unsupported type. The field value will be serialized to a BLOB by default.
Failed to create Bundle in DB:
<openjpa-1.2.2-SNAPSHOT-r422266:778978M-OPENJPA-975 fatal user error> org.apache.openjpa.persistence.ArgumentException: Field "abc.xyz" cannot declare that it is mapped by another field. Its mapping strategy (org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy) does not support mapping by another field.
at org.apache.openjpa.jdbc.meta.strats.AbstractFieldStrategy.assertNotMappedBy(AbstractFieldStrategy.java:59)
at org.apache.openjpa.jdbc.meta.strats.HandlerFieldStrategy.map(HandlerFieldStrategy.java:71)
at org.apache.openjpa.jdbc.meta.FieldMapping.setStrategy(FieldMapping.java:121)
at org.apache.openjpa.jdbc.meta.RuntimeStrategyInstaller.installStrategy(RuntimeStrategyInstaller.java:80)
at org.apache.openjpa.jdbc.meta.FieldMapping.resolveMapping(FieldMapping.java:454)
at org.apache.openjpa.jdbc.meta.FieldMapping.resolve(FieldMapping.java:419)
at org.apache.openjpa.jdbc.meta.ClassMapping.resolveNonRelationMappings(ClassMapping.java:879)
at org.apache.openjpa.jdbc.meta.MappingRepository.prepareMapping(MappingRepository.java:339)
at org.apache.openjpa.meta.MetaDataRepository.preMapping(MetaDataRepository.java:662)
at org.apache.openjpa.meta.MetaDataRepository.resolve(MetaDataRepository.java:549)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:308)
at org.apache.openjpa.meta.MetaDataRepository.getMetaData(MetaDataRepository.java:363)
at org.apache.openjpa.kernel.QueryImpl.classForName(QueryImpl.java:1569)
at org.apache.openjpa.kernel.ExpressionStoreQuery$1.classForName(ExpressionStoreQuery.java:108)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getClassMetaData(JPQLExpressionBuilder.java:168)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.resolveClassMetaData(JPQLExpressionBuilder.java:139)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:225)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateMetaData(JPQLExpressionBuilder.java:195)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.getCandidateType(JPQLExpressionBuilder.java:188)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder.access$600(JPQLExpressionBuilder.java:69)
at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.populate(JPQLExpressionBuilder.java:1756)
at org.apache.openjpa.kernel.jpql.JPQLParser.populate(JPQLParser.java:56)
at org.apache.openjpa.kernel.ExpressionStoreQuery.populateFromCompilation(ExpressionStoreQuery.java:153)
at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:658)
at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:639)
at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:605)
at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:667)
at org.apache.openjpa.kernel.QueryImpl.compile(QueryImpl.java:574)
at com.xyz.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:105)
at com.xyz.ws.persistence.EntityManagerImpl.createNamedQuery(EntityManagerImpl.java:37)
at com.xyz.ws.jpa.management.JPATxEmInvocation.createNamedQuery(JPATxEmInvocation.java:116)
at com.xyz.ws.jpa.management.JPAEntityManager.createNamedQuery(JPAEntityManager.java:302)

I just solved an error like this. The error was quite misleading. The problem was I forgot to put the entity into the persistence.xml file.

I was having the same problem.
The message is not clear!
What solved my problem was implementing equals() and hashCode() in the entity object and its pk object.
Also see if the class is declared inside the persistence.xml
Hope it helps someone.

I'm going to guess (best I can do without seeing code) that you have a relationship to another class that you have failed to annotate with #ManyToOne, #OneToMany or similar.

Related

Wildfly 10 in cluster tries to serialize JSP with org.infinispan.commons.marshall.NotSerializableException

I'm trying to use my application with following code in JPS
<c:forEach var="area" items="#{MissingSearchBean.workingAreas}">
<h:commandButton value="#{area.workingAreaName}(#{area.count})"
action="#{MissingSearchBean.selectWorkingArea(area.workingAreaName)}"
styleClass="commandButton" />
</c:forEach>
inside wilfly 10. Everything works fine, but when I open view, containing code above I see following error in logs:
Caused by: org.infinispan.commons.marshall.NotSerializableException: javax.servlet.jsp.jstl.core.IteratedExpression
Caused by: an exception which occurred:
in field iteratedExpression
in field delegate
in field savedState
in field m
in object java.util.HashMap#85e645ff
in object org.wildfly.clustering.marshalling.jboss.SimpleMarshalledValue#85e645ff
I think that wildfly tries to persist view into infinispan to be able to recover view in case if I'll reload page or hit this page on another node.
I've tried to change scope of bean to request and even to none, but wildfly still tries to serialize view. I'm absolutely sure that the problem is in c:forEach because when I comment it (ot its' content) out — I don't get any exceptions.
Also obviously IteratedExpression contains Iterator inside, which is not Serializable true.
I'm looking for any solution/workaround for this be able to work in cluster without throwing exceptions.
The problem is c:forEach creates IteratedValueExpression, which is not Serializable because contains the Iterator inside. Simple workaround for this is to change return type of MissingSearchBean.workingAreas to array.
In case when value is represented by array, LoopTagSupport creates IndexedValueExpression instead of IteratedValueExpression and this is explicitly Serializable.

What type of exception is raised if "service.Retrieve" method doesn't find the specified entity Id in CRM?

I am retrieving an annotation from CRM
service.Retrieve("annotation", annotationId, col);
What type of exception is raised if above "service.Retrieve" method doesn't find the specified "annotationId" in CRM?
Its probably going to be an OrganizationServiceFault, see Handle exceptions in your code for further advice.

HasMaxLength value increase in entity type configuration not pulling through to migration?

I have an odd one whereby increasing the value of HasMaxLength (FYI, from 200 to 500) in an EntityTypeConfiguration class seems to have no effect on the next migration that I create. I would have hoped for a modification to the column's data type length obviously.
Having discovered this I have tried adding a MaxLength attribute to the related property in my model but this had no impact on the migration created either. In both cases the migration contains empty up and down methods.
Migrations have been working flawlessly up until now. What am I missing?
Edit
To confirm, if I add an entity then I get a migration as expected with the relevant populated Up and Down methods.
As requested in comments, here is some code:
Configuration constructor:
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
DbContext constructor:
public ProjectNameContext()
: base("ProjectName")
{
Configuration.LazyLoadingEnabled = false;
}
I'm not going to post the entire config of the startup project (UI) for obvious reasons but the connection string (which is working fine) is as follows:
<add name="ProjectName" connectionString="server=.;database=ProjectName;Persist Security Info=False;MultipleActiveResultSets=true;Integrated Security=True" providerName="System.Data.SqlClient"/>
Edit 2
I've been experimenting and tried introducing a HasColumnName and the next migration has code for the column rename. If I do a HasColumnName and update the HasMaxLength then the next migration only has the rename, no change to the length. Very odd!
It would appear that the answer to the question is to upgrade Entity Framework from 6.1.0 to 6.1.1. Doing so results in a migration being created that includes the change to the HasMaxLength value. It could be a coincidence I guess but its the only change that I can attribute to the migration being created successfully.

Prefix is null when using client stubs

I had to use axis to generate stubs because the SOAP I am working with uses RPC. After setting up the code to post I am receiving the below stack trace. If anyone has had this issue please help. From using the debug tool in Eclipse I can see that Axis is using default prefixes, but the issue is that one of the prefixes it uses has already been used so it returns null. Does anyone know why this may be happening?
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.io.IOException: java.io.IOException: Non nillable element 'prefix' is null.
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.io.IOException: java.io.IOException: Non nillable element 'prefix' is null.
at org.apache.axis.encoding.ser.BeanSerializer.serialize(BeanSerializer.java:275)
at org.apache.axis.encoding.SerializationContext.serializeActual(SerializationContext.java:1504)
at org.apache.axis.encoding.SerializationContext.serialize(SerializationContext.java:980)
at org.apache.axis.encoding.SerializationContext.outputMultiRefs(SerializationContext.java:1055)
at org.apache.axis.message.SOAPBody.outputImpl(SOAPBody.java:145)
at org.apache.axis.message.SOAPEnvelope.outputImpl(SOAPEnvelope.java:478)
at org.apache.axis.message.MessageElement.output(MessageElement.java:1208)
at org.apache.axis.client.Call.invoke(Call.java:2757)
at org.apache.axis.client.Call.invoke(Call.java:2443)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
Though that this question is not answered after one year I thought that it might help you since you are working with RPC and probably a legacy system.
In your generated client stub with Apache Axis under packaging that ends with "_xsd" where the Objects of the web service provider are created open classes one by one.
Somewhere in the middle of the class you will find a static block code like this:
static {
typeDesc.setXmlType(...);
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("prefix");
elemField.setXmlName(new javax.xml.namespace.QName("", "prefix"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
just change the value of nillable to true like this:
elemField.setNillable(true);
You should repeat this action for all classes and all fields of those classes if they do not match with their corresponding values in your WSDL (i.e. based on the definition of your WSDL they are nullable).
I've noticed that Apache Axis 1.2 - 1.4 automatically makes attributes not 'nillable' by default. I don't know why is this the case but I think this is the solution.

Entity Framework ConnectionString Parsing Exception

I can't find how my connectionString syntax is wrong. Can anyone suggest a way to figure this out? I am having a difficulty using EF with my connection string. I am new to EF.
I am using Sybase Anywhere 12 database.
I'm using the Table-First ObjectContext with EDMX in a separate class library refenced by a web application.
I'm using a Ninject Module in my class library to bind my repositories.
I'm using a ODBC DataStore called "Test"
Other information EF 4.3.1.0, .NET 4, VS2010
My main web application web.config has the EF connection string copied to it as:
<connectionStrings>
<add name="Entities"connectionString="metadata=res://*/MyEntities.csdl|res://*/MyEntities.ssdl|res://*/MyEntities.msl;provider=iAnywhere.Data.SQLAnywhere;provider connection string="UserID=aUser;Password=aPassword;DataSourceName=Test"" providerName="iAnywhere.Data.SQLAnywhere"/>
</connectionStrings>
When I initialize my Entity/ObjectContext in my Repository (see using statement below) it returns an error: "The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
using (var context = new Entities())
{
return {Linq to Entity here}
}
I turned on CLR exceptions on the debugger and found the code throws the error in the .NET Framework here:
EntityConnection.cs
effectiveConnectionOptions = new DbConnectionOptions(setting.ConnectionString, EntityConnectionStringBuilder.Synonyms, false);
edmx designer generated:
/// <summary>
/// Initializes a new Entities object using the connection string found in the 'Entities' section of the application configuration file.
/// </summary>
public Entities() : base("name=Entities", "Entities")
{
this.ContextOptions.LazyLoadingEnabled = true;
OnContextCreated();
}
I can see my connection string there, so it is having a difficult time parsing the connectionString. I have tried many different permutations of syntax and haven't found anything it accepts including:
Explicitly naming the assembly for entity files instead of a wildcard(e.g. metadata=res://MyDomain/MyEntities.csdl...)
Using Sybase friendly ODBC attributes such as UID instead of UserID, PWD instead of Password, and DBN instead of DataSourceName.
Thanks.
I got everything working and the only reason I can think of is that I deleted my ASP .NET 4.0 temp files. Also, I must add I changed my process from using an integration test to test this piece to using a unit test. I did not do unit tests first, because our build server does not have a database on it.
Once I was able to prove that it was working there, I decided to delete my temp files. After that, everything started working properly. So, some sort of cache issue was occurring in my application. I used the same connectionString that I mentioned above.
Actually, I used the domain name of the Metadata "metadata=res://MyDomain/MyEntitities.csdl" rather than */MyEntities.csdl. I don't plan on changing the domain any time soon. In fact, that is just what may have caused some of the issue, because I had changed the location, name, and namespace of MyEntities.Domain where the EF was.