ObjectDB ObjectDB

WebService : Failed to get reference value of field using enhanced method

#1

Hi, I try to use objectdb from Tomcat Webservice

without webservice it's works fine:

error:

org.apache.axis2.AxisFault: Failed to commit transaction: Failed to get reference value of field field de.tud.stg.emergent.policy.persistence.PolicyEntity.policyString using enhanced method
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at de.tud.stg.emergent.policy.client.PolicyServiceStub.policyIntersectionOperation(PolicyServiceStub.java:339)
at de.tud.stg.emergent.policy.test.jaxbri.jgj.testIntersectPolicyll(jgj.java:66)
at de.tud.stg.emergent.policy.test.jaxbri.jgj.main(jgj.java:21)
edit
delete
#2

Please post the complete stack trace including nested exceptions (check the ObjectDB log file).

ObjectDB Support
edit
delete
#3

I added objectdb.jar to Tomcat-Dir/lib directory. (I use axis2 Web Service Framework)

Once it was another exception:

cannot cast de.tud.stg.emergent.policy.persistence.ClientEntity to de.tud.stg.emergent.policy.persistence.ClientEntity 

-----

complete stack trace including nested exceptions:

org.apache.axis2.AxisFault: Failed to commit transaction: Failed to get reference value of field field de.tud.stg.emergent.policy.persistence.PolicyEntity.policyString using enhanced method

at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:531)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:375)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:421)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at de.tud.stg.emergent.policy.client.PolicyServiceStub.policyIntersectionOperation(PolicyServiceStub.java:339)
at de.tud.stg.emergent.policy.test.jaxbri.jgj.testIntersectPolicyll(jgj.java:66)
at de.tud.stg.emergent.policy.test.jaxbri.jgj.main(jgj.java:21)
edit
delete
#4

The problem is expressed by the first exception:

cannot cast de.tud.stg.emergent.policy.persistence.ClientEntity to de.tud.stg.emergent.policy.persistence.ClientEntity

It is just wrapped by another general exception.

At a first glance this error message looks weird (ClientEntity cannot be casted to itself?!), but actually it indicates a class loading issue. You have two instances of ClientEntity loaded using difference class loaders. ObjectDB uses the current thread context class loader (as web applications) but apparently that specific class has also be loaded using another class loader.

First of all please check if you have your classes in more than one place in the class path.

If you cannot solve the problem - try to isolate it and to post a simple test case that demonstrates it.

ObjectDB Support
edit
delete
#5

hi

I think it is general problem with objectdb and webservice: if you archive java classes to .aar file and deploy on application server (Tomcat) - you become this error.

With logging I know, that error take place on this line: em.getTransaction().commit();

As attachment I uploaded a simple testcase, but you have to archive to .aar file and deploy web service in order to get this error.

>First of all please check if you have your classes in more than one place in the class path.

no, all my classes situated in one place

---

I get always this error : "Failed to get reference value of field using enhanced method" . ClassCast error was only once by me...

---

I tried to use External Objectdb Server, but it doesn't help.

I know, there is another post about objectdb classloader Problem (https://www.objectdb.com/forum/393)

edit
delete
#6

Please wrap the PolicyEntity class with a runnable test and post an Eclipse/NetBeans/Maven project with detailed running instructions.

ObjectDB Support
edit
delete
#7

I found a solution for this class loader Problem in Axis2 Web Service Framework!

 

“Axis2’s service class loader prime use case is service isolation, hot deployment and hot updates. So Axis2 creates a new class loader for every service and carefully manages which jars are available in that class loader. One common problem is that an external project uses a Thread Context class loader to load classes or resources from its environment. (TCCL-Thread Context Class Loader ) instead of trying to use the classloader that the class itself was loaded with. So to facilitate this mechanism you can specify a parameter in your services.xml file as under.( from the wso2 site )”

<serviceGroup>
<service name=“DSService”>
<!– added for loading libraries files from the lib folder inside aar file –>
<parameter name=“ServiceTCCL”>composite</parameter>

. . . .
. . . .
<!– More configurations as per your service 
</service>
</serviceGroup>
By doing this libraries inside your aar file will be accessed.

edit
delete
#8

Thank you for this update. Your solution may be useful to other users.

ObjectDB Support
edit
delete

Reply

To post on this website please sign in.