Hi folks,
I have a project that uses XMLTools.loadWSDL to load a WSDL. To avoid the SOP I also have a HttpProxy servlet that fetches the WSDL from a remote server. When the remote server is reachable, everything works fine. However, in Gwt DevMode, when the remote server is not reachable, FireFox reports an error:
This might result from a bug in FF: https://bugzilla.mozilla.org/show_bug.cgi?id=428602
but switching to chrome does not improve things much:
I’m new to SmartGwt so I assume I’m doing something wrong and hope one of you experts out there can help me with a fix or workaround.
The stack I’m using is: SmartGwt 3.0, GWT 2.4, Java 1.6.0_31 on OSX 10.6.8 with FireFox 11.0 and Chrome 20.0.1132.47. Right after the above mentioned error is discovered, I can start the SmartClient Developer Console in FireFox. It reports the SmartClient version as: SmartClient Version: SC_SNAPSHOT-2011-12-05/LGPL Development Only (built 2011-12-05)
The SmartClient Developer Console appears to shows no real issues:
To complete the post I’ll include the stripped down project files that demonstrate the error (but do nothing very useful). These include the host page index.html, the GWT module SmartGwtDemo.gwt.xml, the client-side class AppLoader.java (which does nothing other than load the wsdl), the server-side class HttpProxySapServlet.java (which now returns either (a) 200 with a hard-coded wsdl instead of fetching it remotely, or (b) 503 with an error message), web.xml and pom.xml for maven 3.0.3.
If I've forgotten anything, please let me know.
Sincere thanks for your help!!
Index.html
SmartGwtDemo.gwt.xml
AppLoader.java:
HttpProxySapServlet.java:
web.xml:
pom.xml:
I have a project that uses XMLTools.loadWSDL to load a WSDL. To avoid the SOP I also have a HttpProxy servlet that fetches the WSDL from a remote server. When the remote server is reachable, everything works fine. However, in Gwt DevMode, when the remote server is not reachable, FireFox reports an error:
Code:
[ERROR] Uncaught JavaScript exception [uncaught exception: [Exception... "Cannot modify properties of a WrappedNative" nsresult: "0x80570034 (NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN)" location: "JS frame :: http://127.0.0.1:8888/gwt_smartgwtdemo/sc/modules/ISC_Core.js :: <TOP_LEVEL> :: line 911" data: no]] in , line 0
but switching to chrome does not improve things much:
Code:
[ERROR] Uncaught JavaScript exception [Uncaught TypeError: Cannot set property 'location' of undefined] in http://127.0.0.1:8888/gwt_smartgwtdemo/sc/modules/ISC_Core.js, line 301
The stack I’m using is: SmartGwt 3.0, GWT 2.4, Java 1.6.0_31 on OSX 10.6.8 with FireFox 11.0 and Chrome 20.0.1132.47. Right after the above mentioned error is discovered, I can start the SmartClient Developer Console in FireFox. It reports the SmartClient version as: SmartClient Version: SC_SNAPSHOT-2011-12-05/LGPL Development Only (built 2011-12-05)
The SmartClient Developer Console appears to shows no real issues:
Code:
09:10:45.233:INFO:Log:initialized 09:10:45.248:WARN:Log:NOTE: Firebug is enabled. Firebug greatly slows the performance of applications that make heavy use of JavaScript. Isomorphic highly recommends Firebug for troubleshooting, but Firebug and other development tools should be disabled when assessing the real-world performance of SmartClient applications. 09:10:47.075:SCR3:INFO:Log:isc.Page is loaded
If I've forgotten anything, please let me know.
Sincere thanks for your help!!
Index.html
Code:
<!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>SmartGwtDemo</title> <link rel="shortcut icon" href="images/favicon.ico" /> <script> var isomorphicDir = "gwt_smartgwtdemo/sc/"; </script> <script>window.isc_useSimpleNames = false</script> <script type="text/javascript" src="gwt_smartgwtdemo/gwt_smartgwtdemo.nocache.js"></script> </head> <body id="page"> <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe> <noscript> <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif"> Your web browser must have JavaScript enabled in order for this application to display correctly. </div> </noscript> </body> </html>
Code:
<?xml version="1.0" encoding="UTF-8"?> <module rename-to='gwt_smartgwtdemo'> <!-- The gwt javascript output will reside in war/gwt_smartgwt --> <source path='client' /> <source path='shared' /> <source path='test' /> <inherits name="com.google.gwt.resources.Resources" /> <inherits name="com.smartgwt.SmartGwt" /> <inherits name="com.smartclient.theme.enterprise.Enterprise" /> <inherits name="com.smartclient.theme.enterprise.EnterpriseResources" /> <inherits name="com.smartgwt.tools.SmartGwtTools" /> <!-- When using SmartGWT, the entry-point must be included AFTER the inherit's tag (above) --> <entry-point class='de.jaemc.smartgwtdemo.client.AppLoader' /> <!-- Client-side logging --> <inherits name="com.allen_sauer.gwt.log.gwt-log-DEBUG" /> <set-property name="log_DivLogger" value="DISABLED" /> <set-configuration-property name="document.compatMode" value="CSS1Compat"/> </module>
Code:
package de.jaemc.smartgwtdemo.client; import com.google.gwt.core.client.EntryPoint; public class AppLoader implements EntryPoint { private String gwtAppName = "/smartgwtdemo"; @Override public void onModuleLoad() { RPCManager.setHandleTransportErrorCallback(new HandleTransportErrorCallback() { public void handleTransportError(int transactionNum, int status, int httpResponseCode, String httpResponseText) { SC.clearPrompt(); SC.warn("Call to server failed : " + httpResponseCode + " : "+ httpResponseText, new BooleanCallback() { @Override public void execute(Boolean value) {} }); } }); if (com.google.gwt.user.client.Window.Location.getHref().indexOf("gwt.codesvr") >= 0) gwtAppName = ""; final String wsdlURL = gwtAppName + "/sap/bc/soap/wsdl/?services=RFC_FUNCTION_SEARCH"; SC.say("SmartGwtDemo","Attempting to load :" + wsdlURL); final RPCRequest rpc = new RPCRequest(); rpc.setShowPrompt(false); rpc.setWillHandleError(true); rpc.setUseSimpleHttp(true); XMLTools.loadWSDL(wsdlURL, new WSDLLoadCallback() { @Override public void execute(WebService service) { SC.clearPrompt(); if (service == null) { SC.warn("Failed to load " + wsdlURL, new BooleanCallback() { @Override public void execute(Boolean value) {} }); return; }else{ SC.say("SmartGwtDemo","Successfully loaded :" + wsdlURL); } } },rpc,true); } }
Code:
package de.jaemc.smartgwtdemo.server; import java.io.IOException; import java.io.PrintWriter; import java.util.Date; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class HttpProxySapServlet extends HttpServlet { private static final long serialVersionUID = 1L; public void doGet(HttpServletRequest request, HttpServletResponse response) { Long now = new Date().getTime(); response.addHeader("Content-Type", "text/xml; charset=utf-8"); response.addDateHeader("Last-Modified", now); response.addDateHeader("Date", now); response.addDateHeader("Expires", now); response.addHeader("Cache-Control", "private, max-age=0, no-cache, no-store"); response.addHeader("X-Content-Type-Options", "nosniff"); // doSucceed(request, response); doFail(request, response); } public void doSucceed(HttpServletRequest request, HttpServletResponse response) { PrintWriter out; try { response.setStatus(HttpServletResponse.SC_OK); out = response.getWriter(); out.println(getWsdlString()); out.close(); } catch (IOException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } public void doFail(HttpServletRequest request, HttpServletResponse response) { PrintWriter out; try { response.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); out = response.getWriter(); out.println("The remote service is unavailable"); out.close(); } catch (IOException e) { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } } private String getWsdlString(){ return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><definitions targetNamespace=\"urn:sap-com:document:sap:rfc:functions\" xmlns:s0=\"urn:sap-com:document:sap:rfc:functions\" xmlns=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:http=\"http://schemas.xmlsoap.org/wsdl/http/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\"><types><xsd:schema targetNamespace=\"urn:sap-com:document:sap:rfc:functions\"><xsd:element name=\"RFC_FUNCTION_SEARCH\"><xsd:complexType><xsd:all><xsd:element name=\"FUNCNAME\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"30\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element name=\"FUNCTIONS\"><xsd:complexType><xsd:sequence><xsd:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"item\" type=\"s0:RFCFUNC\"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element minOccurs=\"0\" name=\"GROUPNAME\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"26\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element minOccurs=\"0\" name=\"LANGUAGE\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"1\"/></xsd:restriction></xsd:simpleType></xsd:element></xsd:all></xsd:complexType></xsd:element><xsd:element name=\"RFC_FUNCTION_SEARCH.Response\"><xsd:complexType><xsd:all><xsd:element name=\"FUNCTIONS\"><xsd:complexType><xsd:sequence><xsd:element maxOccurs=\"unbounded\" minOccurs=\"0\" name=\"item\" type=\"s0:RFCFUNC\"/></xsd:sequence></xsd:complexType></xsd:element></xsd:all></xsd:complexType></xsd:element><xsd:complexType name=\"RFCFUNC\"><xsd:sequence><xsd:element minOccurs=\"0\" name=\"FUNCNAME\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"30\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element minOccurs=\"0\" name=\"GROUPNAME\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"26\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element minOccurs=\"0\" name=\"APPL\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"1\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element minOccurs=\"0\" name=\"HOST\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"32\"/></xsd:restriction></xsd:simpleType></xsd:element><xsd:element minOccurs=\"0\" name=\"STEXT\"><xsd:simpleType><xsd:restriction base=\"xsd:string\"><xsd:maxLength value=\"74\"/></xsd:restriction></xsd:simpleType></xsd:element></xsd:sequence></xsd:complexType></xsd:schema> </types> <message name=\"RFC_FUNCTION_SEARCHOutput\"> <part name=\"parameters\" element=\"s0:RFC_FUNCTION_SEARCH.Response\"> </part> </message> <message name=\"RFC_FUNCTION_SEARCHInput\"> <part name=\"parameters\" element=\"s0:RFC_FUNCTION_SEARCH\"> </part> </message> <portType name=\"RFC_FUNCTION_SEARCHPortType\"> <operation name=\"RFC_FUNCTION_SEARCH\"> <input message=\"s0:RFC_FUNCTION_SEARCHInput\"> </input> <output message=\"s0:RFC_FUNCTION_SEARCHOutput\"> </output> </operation> </portType> <binding name=\"RFC_FUNCTION_SEARCHBinding\" type=\"s0:RFC_FUNCTION_SEARCHPortType\"> <soap:binding style=\"document\" transport=\"http://schemas.xmlsoap.org/soap/http\"/> <operation name=\"RFC_FUNCTION_SEARCH\"> <soap:operation soapAction=\"http://www.sap.com/RFC_FUNCTION_SEARCH\"/> <input> <soap:body use=\"literal\"/> </input> <output> <soap:body use=\"literal\"/> </output> </operation> </binding> <service name=\"RFC_FUNCTION_SEARCHService\"> <documentation>SAP Service RFC_FUNCTION_SEARCH via SOAP</documentation> <port name=\"RFC_FUNCTION_SEARCHPortType\" binding=\"s0:RFC_FUNCTION_SEARCHBinding\"> <soap:address location=\"http://192.168.146.128:8000/sap/bc/soap/rfc?sap-client=800\"/> </port> </service> </definitions>"; } }
Code:
<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <!-- Default page to serve --> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list> <servlet> <servlet-name>HttpProxySapServletWsdl</servlet-name> <servlet-class>de.jaemc.smartgwtdemo.server.HttpProxySapServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HttpProxySapServletWsdl</servlet-name> <url-pattern>/sap/bc/soap/wsdl/</url-pattern> </servlet-mapping> </web-app>
Code:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>de.jaemc.smartgwtdemo</groupId> <artifactId>smartgwtdemo</artifactId> <version>1.0.7</version> <packaging>war</packaging> <name>SmartGwtDemo</name> <properties> <commons.lang3.version>3.1</commons.lang3.version> <gwt.version>2.4.0</gwt.version> <gwt.maven.plugin.version>${gwt.version}</gwt.maven.plugin.version> <gwt.log.version>3.1.3</gwt.log.version> <javax.validation.version>1.0.0.GA</javax.validation.version> <junit.version>4.8.2</junit.version> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> <maven.compiler.plugin.version>2.3.2</maven.compiler.plugin.version> <maven.war.plugin.version>2.1.1</maven.war.plugin.version> <org.springframework.version>3.0.1.RELEASE</org.springframework.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <org.slf4j.log4j12.version>1.6.1</org.slf4j.log4j12.version> <smartgwt.version>3.0</smartgwt.version> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> </properties> <repositories> <repository> <id>smartclient</id> <name>smartclient.com</name> <url>http://www.smartclient.com/maven2</url> </repository> </repositories> <build> <outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>${maven.compiler.plugin.version}</version> <configuration> <verbose>true</verbose> <fork>true</fork> <source>${maven.compiler.source}</source> <target>${maven.compiler.target}</target> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>gwt-maven-plugin</artifactId> <version>${gwt.maven.plugin.version}</version> <executions> <execution> <goals> <goal>compile</goal> <goal>test</goal> </goals> </execution> </executions> <configuration> <debugPort>8999</debugPort> <skipTests>true</skipTests> <runTarget>index.html</runTarget> <hostedWebapp>${webappDirectory}</hostedWebapp> <generateDirectory>src/main/java</generateDirectory> <testTimeOut>60</testTimeOut> <mode>htmlunit</mode> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>${maven.war.plugin.version}</version> <executions> <execution> <phase>compile</phase> <goals> <goal>exploded</goal> </goals> </execution> </executions> <configuration> <webappDirectory>${webappDirectory}</webappDirectory> <webResources> <resource> <filtering>true</filtering> <directory>src/main/webapp</directory> <includes> <include>**/*.properties</include> </includes> </resource> </webResources> </configuration> </plugin> </plugins> <pluginManagement> <plugins> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> <plugin> <groupId>org.eclipse.m2e</groupId> <artifactId>lifecycle-mapping</artifactId> <version>1.0.0</version> <configuration> <lifecycleMappingMetadata> <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <versionRange>[${maven.war.plugin.version},)</versionRange> <goals> <goal>exploded</goal> </goals> </pluginExecutionFilter> <action> <execute></execute> </action> </pluginExecution> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <versionRange>[${maven.compiler.plugin.version},)</versionRange> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </pluginExecutionFilter> <action> <execute></execute> </action> </pluginExecution> </pluginExecutions> </lifecycleMappingMetadata> </configuration> </plugin> </plugins> </pluginManagement> </build> <dependencies> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-user</artifactId> <version>${gwt.version}</version> </dependency> <dependency> <groupId>com.google.gwt</groupId> <artifactId>gwt-servlet</artifactId> <version>${gwt.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>com.smartgwt</groupId> <artifactId>smartgwt</artifactId> <version>${smartgwt.version}</version> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>${javax.validation.version}</version> </dependency> <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>${javax.validation.version}</version> <classifier>sources</classifier> </dependency> <dependency> <groupId>com.google.code</groupId> <artifactId>gwt-log</artifactId> <version>${gwt.log.version}</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <version>${org.slf4j.log4j12.version}</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>${commons.lang3.version}</version> </dependency> </dependencies> </project>
Comment