So changing this around seems to correct it. I'm not sure why though, to
my knowledge it shouldn't have been using a proxy.
public class ChangeProcessAction {
private StatusService statusService;
private OrderService orderService;
private Status status;
private Integer orderId;
public String execute() throws Exception {
status = statusService.findByID("C");
Order order = orderService.findById(orderId);
order.setStatus(status);
orderService.update(order);
return SUCCESS;
}
public Status getStatus() {
return status;
}
}
Didn't work when serializing the Status object.
However:
public class ChangeProcessAction {
private StatusService statusService;
private OrderService orderService;
private String statusName;
private Integer orderId;
public String execute() throws Exception {
Status status;
status = statusService.findByID("C");
Order order = orderService.findById(orderId);
order.setStatus(status);
orderService.update(order);
statusName = status.getName();
return SUCCESS;
}
public String getStatusName() {
return statusName;
}
}
Works fine. Maybe I'm wrong, but shouldn't the status be the full object
and not a proxy when I do findById?
Thanks,
-Tim
Timothy Orme wrote:
Ill give this a whirl, and you're probably right, but this used to
work while using DBCP. Any idea as to why this would be broken in
c3p0? I tried to do some digging under the hood but couldn't find
sources the classes that were breaking.
Thanks,
-Tim
Greg Lindholm wrote:
Wild guess.... you are trying to serialize (with JSON plugin) a
Hibernate proxy object.
Maybe your object has a reference to another lazy loaded object or
collection.
Using reflection on a proxy object is usually a bad idea.
You may need to clone the object (to get a real one) first before
serializing it with JSON.
Greg
On Mon, Dec 14, 2009 at 3:45 PM, Timothy Orme
<to...@genome.med.harvard.edu> wrote:
Hello,
I just recently switched to c3p0 and it fixed some other issues I was
having with dbcp, but another has arisen.
It seems to be a combination of using the c3p0 data source along
with the
JSON plugin. Here's my (slightly shortened) stacktrace:
Caused by: org.apache.struts2.json.JSONException:
org.apache.struts2.json.JSONException:
org.apache.struts2.json.JSONException:
java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
... 91 more
Caused by: org.apache.struts2.json.JSONException:
org.apache.struts2.json.JSONException:
java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
... 95 more
Caused by: org.apache.struts2.json.JSONException:
java.lang.reflect.InvocationTargetException
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:243)
at org.apache.struts2.json.JSONWriter.process(JSONWriter.java:165)
at org.apache.struts2.json.JSONWriter.value(JSONWriter.java:131)
at org.apache.struts2.json.JSONWriter.add(JSONWriter.java:329)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:228)
... 99 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts2.json.JSONWriter.bean(JSONWriter.java:227)
... 103 more
Caused by: java.sql.SQLException: Unsupported feature: getCursorName
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at
oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at
oracle.jdbc.driver.BaseResultSet.getCursorName(BaseResultSet.java:37)
at
com.mchange.v2.c3p0.impl.NewProxyResultSet.getCursorName(NewProxyResultSet.java:545)
... 108 more
I'm runing c3p0-0.9.1.2, struts 2.1.8.1 and its corresponding json
plugin,
Oracle 10, and Hibernate 3.3.1.GA
Heres my datasource in spring. Just using the defaults:
<bean id="dataSource"
class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="${database.driver}" />
<property name="jdbcUrl" value="${database.connectionString}" />
<property name="user" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
Should note that other pages seem to work fine and lazy load as
well. Just
this json action is giving me problems. If you need more info let me
know.
Thanks!
-Tim
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org