any way to force marshalling type/class?

37 views
Skip to first unread message

don...@i.ua

unread,
Dec 15, 2015, 3:20:18 AM12/15/15
to Quercus
Hey

There's Java method which accepts Object parameter, but the method itself is smart, and behaves differently depending on what kind of Object is passed. I need to force the argument to be String, for instance, so the void doSomething(Object o) and $obj->doSomething("doing something") will use String with it. Any way to trick it, or any workaround? Custom quercus module?

Cheers,
Oles

immanuel...@apparentmedia.de

unread,
Jan 5, 2016, 2:36:48 PM1/5/16
to Quercus
Hi Oles,

which type is passed to "void doSomething(Object o)" when you invoke $obj->doSomething("doing something")? Not a string?
Best,

Immanuel

donoles2

unread,
Feb 11, 2016, 10:10:40 AM2/11/16
to Quercus
Hi All

I found really disappointing example. The function is like doSomething(SomeObject someObject, Object value), and for the instance of someObject the value is expected to be Timestamp, but when I provide Timestamp object as value, the real java method gets Date object, and complains a lot. I believe that's because Date is kept in Quercus as 'effectively int', and treats Timestamp alike.

Cheers
Oles

Nam Nguyen

unread,
Feb 11, 2016, 12:10:22 PM2/11/16
to caucho-...@googlegroups.com
Hi Oles,

1. What is your Java method signature?

2. How are you calling it in PHP?

-- Nam

>
> Cheers
> Oles
>
> --
> You received this message because you are subscribed to the Google
> Groups "Quercus" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to caucho-quercu...@googlegroups.com
> <mailto:caucho-quercu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

donoles2

unread,
Feb 11, 2016, 12:46:20 PM2/11/16
to Quercus, n...@caucho.com
Hi Nam

public void setCustomFieldValue(CustomField customField, Object value);
it was called like $issue->setCustomFieldValue($fieldObj, new Timestamp(time()*1000));
And it throws: Java type java.util.Date not currently supported. I googled it to be in SqlJdbcUtil.java from Ofbiz. That's what JIRA uses.

Cheers
Oles


Nam Nguyen

unread,
Feb 11, 2016, 1:51:30 PM2/11/16
to caucho-...@googlegroups.com
Thanks. Is it java.sql.Timestamp? I don't see the string "not
currently supported" anywhere in our code base. Do you have the
exception stacktrace?

I believe the issue is on your side, where the Java class for $issue
does not accept a Date object, which java.sql.Timestamp extends.

donoles2

unread,
Feb 11, 2016, 2:44:41 PM2/11/16
to Quercus, n...@caucho.com
I found this here: http://svn.apache.org/repos/asf/ofbiz/tags/REL-4.0/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
I believe JIRA just uses it, that's why it is not in JIRA codebase.

I just did a test setting Due Date of an issue.
It's defined as void setDueDate(Timestamp dueDate);

Code
import com.atlassian.jira.component.ComponentAccessor;
import java.sql.Timestamp;
$issueManager
= ComponentAccessor::getIssueManager();
$issue
= $issueManager->getIssueByCurrentKey("TEST-1");
$now
= new Timestamp(time()*1000);
$issue
->setDueDate($now);

for some reason printed to STDOUT
eval::6: Warning: 'Thu Feb 11 21:22:24 EET 2016' of type 'Date' is an unexpected argument, expected Timestamp

Now I try to update a real custom field:

$customFieldManager = ComponentAccessor::getCustomFieldManager();
$dateField
= $customFieldManager->getCustomFieldObject("customfield_11704");
$issue
->setCustomFieldValue($dateField,$now);
$currentUser
= ComponentAccessor::getJiraAuthenticationContext()->getLoggedInUser();
$issueManager
->updateIssue($currentUser,$issue,null,false);


And got exception:

Caused by: com.atlassian.jira.exception.DataAccessException: org.ofbiz.core.entity.GenericEntityException: while inserting: [GenericEntity:CustomFieldValue][parentkey,null][customfield,11704][issue,10100][datevalue,Thu Feb 11 21:38:08 EET 2016][id,10308] (Java type java.util.Date not currently supported. Sorry.)
    at com
.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:398)
    at com
.atlassian.jira.ofbiz.WrappingOfBizDelegator.createValue(WrappingOfBizDelegator.java:219)
    at com
.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValuesInt(OfBizCustomFieldValuePersister.java:128)
    at com
.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.updateValues(OfBizCustomFieldValuePersister.java:137)
    at com
.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.updateValues(EagerLoadingOfBizCustomFieldPersister.java:51)
    at com
.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:543)
    at com
.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:504)
    at com
.atlassian.jira.issue.managers.DefaultIssueManager.updateFieldValues(DefaultIssueManager.java:913)
    at com
.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(DefaultIssueManager.java:875)
    at com
.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(DefaultIssueManager.java:860)  <+3> (NativeMethodAccessorImpl.java:62) (DelegatingMethodAccessorImpl.java:43)
    at java
.lang.reflect.Method.invoke(Method.java:497)
    at com
.caucho.quercus.env.JavaMethod.invoke(JavaMethod.java:105)
   
... 201 more


Cheers
Oles








Nam Nguyen

unread,
Feb 11, 2016, 5:48:07 PM2/11/16
to donoles2, Quercus
Thanks. It's fixed for the next release.

add support for java.sql.Timestamp
- http://bugs.caucho.com/view.php?id=5977

-- Nam

On 2/11/16 11:44 AM, donoles2 wrote:
> I found this here:
> http://svn.apache.org/repos/asf/ofbiz/tags/REL-4.0/framework/entity/src/org/ofbiz/entity/jdbc/SqlJdbcUtil.java
> I believe JIRA just uses it, that's why it is not in JIRA codebase.
>
> I just did a test setting Due Date of an issue.
> It's defined as void setDueDate(Timestamp dueDate);
>
> Code
> |
> importcom.atlassian.jira.component.ComponentAccessor;
> importjava.sql.Timestamp;
> $issueManager =ComponentAccessor::getIssueManager();
> $issue =$issueManager->getIssueByCurrentKey("TEST-1");
> $now =newTimestamp(time()*1000);
> $issue->setDueDate($now);
> |
>
> for some reason printed to STDOUT
> eval::6: Warning: 'Thu Feb 11 21:22:24 EET 2016' of type 'Date' is an
> unexpected argument, expected Timestamp
>
> Now I try to update a real custom field:
>
> |
> $customFieldManager =ComponentAccessor::getCustomFieldManager();
> $dateField =$customFieldManager->getCustomFieldObject("customfield_11704");
> $issue->setCustomFieldValue($dateField,$now);
> $currentUser
> =ComponentAccessor::getJiraAuthenticationContext()->getLoggedInUser();
> $issueManager->updateIssue($currentUser,$issue,null,false);
>
> |
>
> And got exception:
>
> |
> Causedby:com.atlassian.jira.exception.DataAccessException:org.ofbiz.core.entity.GenericEntityException:whileinserting:[GenericEntity:CustomFieldValue][parentkey,null][customfield,11704][issue,10100][datevalue,ThuFeb1121:38:08EET
> 2016][id,10308](Javatype java.util.Datenotcurrently supported.Sorry.)
> at
> com.atlassian.jira.ofbiz.DefaultOfBizDelegator.createValue(DefaultOfBizDelegator.java:398)
> at
> com.atlassian.jira.ofbiz.WrappingOfBizDelegator.createValue(WrappingOfBizDelegator.java:219)
> at
> com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.createValuesInt(OfBizCustomFieldValuePersister.java:128)
> at
> com.atlassian.jira.issue.customfields.persistence.OfBizCustomFieldValuePersister.updateValues(OfBizCustomFieldValuePersister.java:137)
> at
> com.atlassian.jira.issue.customfields.persistence.EagerLoadingOfBizCustomFieldPersister.updateValues(EagerLoadingOfBizCustomFieldPersister.java:51)
> at
> com.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:543)
> at
> com.atlassian.jira.issue.fields.CustomFieldImpl.updateValue(CustomFieldImpl.java:504)
> at
> com.atlassian.jira.issue.managers.DefaultIssueManager.updateFieldValues(DefaultIssueManager.java:913)
> at
> com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(DefaultIssueManager.java:875)
> at
> com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue(DefaultIssueManager.java:860)<+3>(NativeMethodAccessorImpl.java:62)(DelegatingMethodAccessorImpl.java:43)

donoles2

unread,
Feb 11, 2016, 6:21:06 PM2/11/16
to Quercus, don...@i.ua, n...@caucho.com
Thanks Nam.
Is there any subscription so I could be notified on new Quercus releases?

Nam Nguyen

unread,
Feb 11, 2016, 6:43:38 PM2/11/16
to caucho-...@googlegroups.com
No, but we're releasing 4.0.48 within a few weeks.

-- Nam

On 2/11/16 3:21 PM, donoles2 wrote:
> Thanks Nam.
> Is there any subscription so I could be notified on new Quercus releases?
>
Reply all
Reply to author
Forward
0 new messages