1 Reply Latest reply on May 27, 2004 4:51 PM by kaobiore

    [urgent] URLConnection from EJB

    kaobiore

      Hi all!

      I really don't know what i'm doing wrong.
      Please help me out!

      I try to make an http-post-request within a stateless session bean with no success!

      URL url = new URL(serverUrl);
      URLConnection connection = url.openConnection();
      HttpURLConnection wcon = (HttpURLConnection) connection;
      wcon.setDoOutput(true);
      OutputStreamWriter wr = new OutputStreamWriter(wcon.getOutputStream());
      


      All I got is this error-message:

      22:09:48,446 ERROR [ProcessLookupBean] An Exception happend in doLookup() - Here is what I know:
      java.net.ProtocolException: cannot write to a URLConnection if doOutput=false - call setDoOutput(true)
      22:09:48,446 INFO [ProcessLookupBean] Rolled-back successfully!
      22:09:48,446 INFO [STDOUT] java.net.ProtocolException: cannot write to a URLConnection if doOutput=false - call setDoOutput(true)
      22:09:48,456 INFO [STDOUT] at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:541)
      22:09:48,466 INFO [STDOUT] at com.be.jaxo.ejb.ProcessLookupBean.sendConfirmACK(ProcessLookupBean.java:167)
      22:09:48,466 INFO [STDOUT] at com.be.jaxo.ejb.ProcessLookupBean.doLookup(ProcessLookupBean.java:127)
      22:09:48,466 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      22:09:48,466 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      22:09:48,466 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      22:09:48,466 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:683)
      22:09:48,466 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:72)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:84)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:313)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:147)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:118)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
      22:09:48,466 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
      22:09:48,486 INFO [STDOUT] at org.jboss.ejb.StatelessSessionContainer.internalInvoke(StatelessSessionContainer.java:331)
      22:09:48,486 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java:713)
      22:09:48,486 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      22:09:48,486 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      22:09:48,486 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      22:09:48,486 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      22:09:48,486 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispatch(ReflectedDispatcher.java:72)
      22:09:48,486 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:45)
      22:09:48,486 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocation.java:70)
      22:09:48,486 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:187)
      22:09:48,486 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:480)
      22:09:48,486 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:367)
      22:09:48,486 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      22:09:48,486 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      22:09:48,486 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      22:09:48,486 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:324)
      22:09:48,486 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:261)
      22:09:48,486 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.java:148)
      22:09:48,486 INFO [STDOUT] at java.security.AccessController.doPrivileged(Native Method)
      22:09:48,486 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Transport.java:144)
      22:09:48,486 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
      22:09:48,486 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
      22:09:48,486 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534)
      


      I've left the server.policy-file untasted (default config) and i'm using jboss 3.2.4rc1.

      Please help me out!

      thanks
      harry