You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomee.apache.org by cri_sys <se...@gmail.com> on 2013/02/12 10:45:03 UTC

Possible bug in Json unmarshalling array/singleton list

Hello,
I am having a problem when trying to get the json of an array of just one
element, the response its an Object instead of an array which it confuses
the client side.
more than one element works properly:
{
"Person": [
    {
        "first": "foo",
        "last": "bar"
    },
    {
        "first": "foo2",
        "last": "bar2"
    }
]
}

But one element array..
{
"Person": {
    "first": "foo",
    "last": "bar"
}
}
It is returning an single object instead of a single objected array.



--
View this message in context: http://openejb.979440.n4.nabble.com/Possible-bug-in-Json-unmarshalling-array-singleton-list-tp4660733.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Remote access openejb from swing app and get notification possible?

Posted by Sule BASOL <ka...@icloud.com>.
	Hello , I want to access openejb remotely from my swing application.
Like;

            final Properties prop = new Properties( );
            prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
            prop.put(Context.PROVIDER_URL, "multipulse://239.255.2.3:6142?group=default&timeout=250");

            final InitialContext c = new InitialContext(prop);


this connects to openejb server great.
But i want to send notifications to many swing clients.

I heard about activemq , but i cant access activemq directly from openejb connection 'c' object.
I need to make new connection to activemq as shown below ;

        final Hashtable<String, String> ctxProps = new Hashtable<String, String>(2);
        ctxProps.put("java.naming.factory.initial", "org.apache.activemq.jndi.ActiveMQInitialContextFactory");
        ctxProps.put("java.naming.provider.url", "tcp://localhost:61616");

        return new InitialContext(ctxProps);




But , this makes some problems i think.
I need double authentication and different servers for only getting notifications ?
it seems so stupid to only get notification requires double connection to different servers?

Why i cant directly get notifications from openejb server?
I will make poll every second to get notification ?



Currently i get notification from activemq like this ;
                final Topic topic = (Topic) activeMQInitialContext.lookup( "dynamicTopics/test1" );
                final TopicConnectionFactory factory1 = (TopicConnectionFactory) activeMQInitialContext.lookup("TopicConnectionFactory");
                final TopicConnection topicConnection = factory1.createTopicConnection();
                TopicSession subSession = topicConnection.createTopicSession(false,Session.AUTO_ACKNOWLEDGE);
                // Look up a JMS topic
                TopicSubscriber subscriber = subSession.createSubscriber( topic );
		//listen for notifications.
                subscriber.setMessageListener(this);

                connection.start();


But i want to get notification from openejb connection directly.
I want to make single connection.
Possible ?

separate connections makes problem like ;
	double authentication and no dependency between openejb and activemq becomes more complex and slow.

Please help ;(


Re: Possible bug in Json unmarshalling array/singleton list

Posted by cri_sys <se...@gmail.com>.
Yeah thanks, i already did a work around for it.

Thanks!



--
View this message in context: http://openejb.979440.n4.nabble.com/Possible-bug-in-Json-unmarshalling-array-singleton-list-tp4660733p4660735.html
Sent from the OpenEJB Dev mailing list archive at Nabble.com.

Re: Possible bug in Json unmarshalling array/singleton list

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi,

yes that's the default config of the json provider of cxf (i can't remember
if we changed it on trunk because it was an issue but i remember we talked
about it).

BTW you can configure the provider and there is a property for it
(serializeAsArray IIRC).

Another solution is to use jackson as provider.

*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*



2013/2/12 cri_sys <se...@gmail.com>

> Hello,
> I am having a problem when trying to get the json of an array of just one
> element, the response its an Object instead of an array which it confuses
> the client side.
> more than one element works properly:
> {
> "Person": [
>     {
>         "first": "foo",
>         "last": "bar"
>     },
>     {
>         "first": "foo2",
>         "last": "bar2"
>     }
> ]
> }
>
> But one element array..
> {
> "Person": {
>     "first": "foo",
>     "last": "bar"
> }
> }
> It is returning an single object instead of a single objected array.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Possible-bug-in-Json-unmarshalling-array-singleton-list-tp4660733.html
> Sent from the OpenEJB Dev mailing list archive at Nabble.com.
>