aspose file tools
The moose likes Web Services and the fly likes JAX WebService client is throwing ClosedChannelException on server. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "JAX WebService client is throwing ClosedChannelException on server." Watch "JAX WebService client is throwing ClosedChannelException on server." New topic
Author

JAX WebService client is throwing ClosedChannelException on server.

duderavindra jaiswal
Greenhorn

Joined: Apr 23, 2009
Posts: 1
We have devloped a WebService using Java 1.6 annotation which is used to upload data on remote server. The client can also download the upgrade with a latest version from the WebService. The application works fine if the upgrade.exe size is below 2MB on internet but if it exceeds this limit then the below exception is thrown and the download gets terminated. The same is working fine when we run upgrade on Company Intranet


Kindly suggest what could be the reason of failing this download for file size greater then 2MB.


javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
- with linked exception:
[java.nio.channels.ClosedChannelException]
at com.sun.xml.internal.ws.message.jaxb.JAXBMessage.writePayloadTo(Unknown Source)
at com.sun.xml.internal.ws.message.AbstractMessageImpl.writeTo(Unknown Source)
at com.sun.xml.internal.ws.encoding.StreamSOAPCodec.encode(Unknown Source)
at com.sun.xml.internal.ws.encoding.SOAPBindingCodec.encode(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.encodePacket(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.access$100(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[java.nio.channels.ClosedChannelException]
at com.sun.xml.internal.bind.v2.runtime.MarshallerImpl.write(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.BridgeImpl.marshal(Unknown Source)
at com.sun.xml.internal.bind.api.Bridge.marshal(Unknown Source)
... 19 more
Caused by: java.nio.channels.ClosedChannelException
at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at sun.net.httpserver.Request$WriteStream.write(Unknown Source)
at sun.net.httpserver.ChunkedOutputStream.writeChunk(Unknown Source)
at sun.net.httpserver.ChunkedOutputStream.write(Unknown Source)
at sun.net.httpserver.PlaceholderOutputStream.write(Unknown Source)
at java.io.FilterOutputStream.write(Unknown Source)
at java.io.FilterOutputStream.write(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.output.UTF8XmlOutput.write(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.output.Encoded.write(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.output.UTF8XmlOutput.doText(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.output.UTF8XmlOutput.text(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.leafElement(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$1.writeLeafElement(Unknown Source)
at com.sun.xml.internal.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl$1.writeLeafElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor$CompositeTransducedAccessorImpl.writeLeafElement(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.property.SingleElementLeafProperty.serializeBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.ClassBeanInfoImpl.serializeBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.BridgeImpl.marshal(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.CompositeStructureBeanInfo.serializeBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.CompositeStructureBeanInfo.serializeBody(Unknown Source)
at com.sun.xml.internal.bind.v2.runtime.XMLSerializer.childAsXsiType(Unknown Source)
... 22 more


Server Side Implementation:

@WebService(endpointInterface = "server.OasisJaxServer")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public class OasisJaxServerImpl implements OasisJaxServer {


public UploadMessageBean upgradeOasis(String version) {

UploadMessageBean uploadMessageBean = new UploadMessageBean();
System.err.println("Upgrading OASIS Version");
String resultValue = "";
if (checkUpgrade(version)) {
uploadMessageBean.setSuccess(false);
uploadMessageBean.setErrorMessage("No New Version Available.");
} else {
try {
System.err.println("Upgrading OASIS Version........ ");
ResourceBundle resourceBundle = ResourceBundle.getBundle("OIS");
String upgradePath = resourceBundle.getString("upgrade");
File myFile = new File(upgradePath);
byte[] mybytearray = new byte[(int) myFile.length()];
FileInputStream fis = new FileInputStream(myFile);
BufferedInputStream bis = new BufferedInputStream(fis);
bis.read(mybytearray, 0, mybytearray.length);
uploadMessageBean.setSuccess(true);
uploadMessageBean.setByteArray(mybytearray);
System.err.println("OASIS Version Successfully Upgraded");
} catch (FileNotFoundException e) {
System.err.println("FileNotFoundException " + e.getMessage());
System.err.println(e.getMessage());
} catch (IOException e) {
System.err.println("IOException " + e.getMessage());
System.err.println(e.getMessage());
}
}
return uploadMessageBean;
}


Client Side code to call the WebService and download the latest EXE:


public String upgrade() throws RemoteException, IOException, OASISServiceException {
String returnValue = null;
String SERVER_NAME = (String) GlobalCache
.getValueFromGlobalCache(OISConstants.OASIS_SERVER_SELECTED);
server.OasisJaxServer oasisJaxServer = JaxWSUtils.getWebService(SERVER_NAME);
UploadMessageBean messageBean;
if(oasisJaxServer!=null)
{
String oasisVersion = (String) GlobalCache.getValueFromGlobalCache(GlobalCache.OASIS_CURRENT_VERSION);

messageBean = oasisJaxServer.upgradeOasis(oasisVersion);

if (messageBean.isSuccess()) {
byte[] mybytearray = messageBean.getByteArray();
FileOutputStream fos = new FileOutputStream("c:/temp/upgrade.exe");
BufferedOutputStream bos = new BufferedOutputStream(fos);
bos.write(mybytearray);
bos.close();
} else{
returnValue = messageBean.getErrorMessage();
return returnValue;
}
}
else{
return null;
}

return returnValue;
}



public static OasisJaxServer getWebService(String ServerName) throws MalformedURLException {

try{
URL wsdlLocation = new URL("http://"+ServerName+":4446/oasisJaxServer?wsdl");

URLConnection connection = wsdlLocation.openConnection();

connection.setRequestProperty("http.keepAlive", "true");
connection.setReadTimeout(72000);
connection.setRequestProperty("sun.net.client.defaultConnectTimeout", "72000");
connection.connect();

QName serviceName = new QName("http://server/", "OasisJaxServerImplService");
Service service = Service.create(wsdlLocation, serviceName);
server.OasisJaxServer oasisJaxServer = service.getPort(server.OasisJaxServer.class);
return oasisJaxServer;
}catch(Exception e){
e.printStackTrace();
return null;
}
}
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: JAX WebService client is throwing ClosedChannelException on server.
 
Similar Threads
Wanted: Help serializing Generic Maps!
Calling a .net web service from java as a client
Service for Asynchronous Client calls (polling, callback)
javax.xml.ws.WebServiceException: java.io.IOException: Stream is closed
problem with stateful service