[JBoss Seam] - seam remoting - metadata array length
by egogenesic
Hi,
I have experienced an error using IE (5.5 and 6) with seam remoting.
I believe I have a fix for the error, but was just wanting to check if anyone else has experienced it and whether my understanding is correct.
The error message is 'field is null or not an object' and occurs in 'data += meta.field;' from seam/remoting/resource/remote.js :
| var meta = isComponent ? Seam.Component.getMetadata(obj) : Seam.Remoting.getMetadata(obj);
| for (var i = 0; i < meta.length; i++)
| {
| data += "<member name=\"";
| data += meta.field;
| data += "\">";
| data += Seam.Remoting.serializeValue(obj[meta.field], meta.type, refs);
| data += "</member>\n";
| }
|
Here is the generated interface the error occurred on:
| Seam.Remoting.type.status.__name = "status";
| Seam.Remoting.type.status.__metadata = [
| {field: "code", type: "str"},
| {field: "disabled", type: "bool"},
| {field: "description", type: "str"},
| {field: "id", type: "number"},
| {field: "version", type: "number"},
| ];
|
The generated interface code has a comma after the last field array value which makes IE treat the whole array as having length 6 (with an undefined element at the end) whereas firefox ignores the comma and treats the array as having a length of 5. IE iterates through all 5 valid fields, but then can't process the undefined 6th array element and fails.
IE seems in this case to have the more correct javascript interpretation.
To fix the issue, I made the following minor change to the org.jboss.seam.remoting.InterfaceGenerator class, rebuilt it and now it works fine on IE and Firefox.
| int i = 0;
| for (String key : metadata.keySet())
| {
| typeSource.append(" {field: \"");
| typeSource.append(key);
| typeSource.append("\", type: \"");
| typeSource.append(metadata.get(key));
| typeSource.append("\"}");
|
| // can't put ',' after last element of the generated array or javascript will interpret as undefined element
| if(i != metadata.keySet().size() -1){
| typeSource.append(",");
| }
| typeSource.append("\n");
|
| i++;
| }
|
Happy to create a JIRA issue, but just wanted to check I was on the right track,
Regards
Samual
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966206#3966206
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966206
19 years, 8 months
[JNDI/Naming/Network] - JNDI/HTTP/4.0.4GA
by jwcone
I'm getting a java.io.EOFException on the server when trying to use JNDI over HTTP.
I'm trying to get an InitialContext using:
Properties prop = new Properties();
| prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,
| "org.jboss.naming.HttpNamingContextFactory");
| prop.setProperty(Context.PROVIDER_URL,
| "http://192.168.1.4:8080/invoker/JMXInvokerServlet");
| prop.setProperty(Context.URL_PKG_PREFIXES,
| "org.jboss.naming:org.jnp.interfaces");
| Context ctx = new InitialContext(prop);
The server configuration is set up like this:
<!-- Expose the Naming service interface via HTTP -->
| <mbean code="org.jboss.invocation.http.server.HttpProxyFactory"
| name="jboss:service=invoker,type=http,target=Naming">
| <!-- The Naming service we are proxying -->
| <attribute name="InvokerName">jboss:service=Naming</attribute>
| <!-- Compose the invoker URL from the cluster node address -->
| <attribute name="InvokerURLPrefix">http://</attribute>
| <attribute name="InvokerURLSuffix">:8080/invoker/JMXInvokerServlet</attribute>
| <attribute name="UseHostName">true</attribute>
| <attribute name="ExportedInterface">org.jnp.interfaces.Naming</attribute>
| <attribute name="JndiName"></attribute>
| <attribute name="ClientInterceptors">
| <interceptors>
| <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
| <interceptor>org.jboss.proxy.SecurityInterceptor</interceptor>
| <interceptor>org.jboss.naming.interceptors.ExceptionInterceptor</interceptor>
| <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
| </interceptors>
| </attribute>
| </mbean>
The client throws this exception when trying to get the InitialContext:
javax.naming.NamingException: Failed to retrieve Naming interface [Root exception is java.io.IOException: Invalid reply content seen: class org.jboss.invocation.InvocationException]
| at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:84)
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
| at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at javax.naming.InitialContext.init(InitialContext.java:223)
| at javax.naming.InitialContext.<init>(InitialContext.java:197)
| at com.centerforce.ClientTestUI.initMessaging(ClientTestUI.java:37)
| at com.centerforce.ClientTestUI.<init>(ClientTestUI.java:25)
| at com.centerforce.ClientTestUI$1.run(ClientTestUI.java:105)
| at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
| at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
| at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
| at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
| at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
| at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
| at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
| Caused by: java.io.IOException: Invalid reply content seen: class org.jboss.invocation.InvocationException
| at org.jboss.naming.HttpNamingContextFactory.getNamingServer(HttpNamingContextFactory.java:153)
| at org.jboss.naming.HttpNamingContextFactory.getInitialContext(HttpNamingContextFactory.java:80)
| ... 14 more
Any help is appreciated.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966203#3966203
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966203
19 years, 8 months