java.net.BindException: Address already in use

jakarta-jcs-users | gerald ternola | 7 years ago
  1. 0

    Re: Need help in setting up RMI Server as Standalone

    jakarta-jcs-users | 7 years ago | gerald ternola
    java.net.BindException: Address already in use
  2. 0

    Re: Need help in setting up RMI Server as Standalone

    jakarta-jcs-users | 7 years ago | gerald ternola
    java.net.BindException: Address already in use
  3. 0

    Hello, we use Ehcache as 2nd level Hibernate cache only, having RMI replication enabled with all the following ports statically set: - net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory multicastGroupPort - net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory port remoteObjectPort However the last one (remoteObjectPort) causes troubles when application is restarted without restarting the whole application server. I noticed that when ehcache starts it creates sockets for all those configured ports and when it's stopped but the application server left running all these sockets remain open. When it's started again then, with the first two mentioned ports there appears to be no problem, but for remoteObjectPort we get the followin exception: Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not instantiate cache implementation at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:737) at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:127) at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:224) at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:291) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335) ... 143 more Caused by: org.hibernate.HibernateException: Could not instantiate cache implementation at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:64) at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:214) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:730) ... 148 more Caused by: org.hibernate.cache.CacheException: net.sf.ehcache.CacheException: Problem starting listener for RMICachePeer null. Initial cause was Port already in use: 41103; nested exception is: java.net.BindException: Address already in use at net.sf.ehcache.hibernate.EhCacheProvider.buildCache(EhCacheProvider.java:96) at org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:61) ... 152 more Caused by: net.sf.ehcache.CacheException: Problem starting listener for RMICachePeer null. Initial cause was Port already in use: 41103; nested exception is: java.net.BindException: Address already in use at net.sf.ehcache.distribution.RMICacheManagerPeerListener.notifyCacheAdded(RMICacheManagerPeerListener.java:529) at net.sf.ehcache.event.CacheManagerEventListenerRegistry.notifyCacheAdded(CacheManagerEventListenerRegistry.java:157) at net.sf.ehcache.CacheManager.addCacheNoCheck(CacheManager.java:708) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:685) at net.sf.ehcache.CacheManager.addCache(CacheManager.java:643) at net.sf.ehcache.hibernate.EhCacheProvider.buildCache(EhCacheProvider.java:90) ... 153 more Caused by: java.rmi.server.ExportException: Port already in use: 41103; nested exception is: java.net.BindException: Address already in use at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:284) at sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:219) at sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:398) at sun.rmi.transport.LiveRef.exportObject(LiveRef.java:131) at sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:195) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:306) at java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:269) at java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:168) at net.sf.ehcache.distribution.RMICachePeer.<init>(RMICachePeer.java:65) at net.sf.ehcache.distribution.RMICacheManagerPeerListener.notifyCacheAdded(RMICacheManagerPeerListener.java:525) ... 158 more Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:417) at java.net.ServerSocket.bind(ServerSocket.java:342) at java.net.ServerSocket.<init>(ServerSocket.java:208) at java.net.ServerSocket.<init>(ServerSocket.java:120) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createServerSocket(RMIDirectSocketFactory.java:46) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createServerSocket(RMIMasterSocketFactory.java:350) at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(TCPEndpoint.java:638) at sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:272) ... 167 more So it tried to create the same socket again and thus fails. Simple workaround is to not specify the static value for remoteObjectPort so that it another socket is open, however this could lead to many sockets left open after series ot application restarts and also disallows the use of static port in there.

    Terracotta Project Issue Tracker | 7 years ago | Petr H
    java.net.BindException: Address already in use
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    2.0.0-RC1 server start failed in Cloud9

    GitHub | 3 years ago | richard-tian
    java.net.BindException: Permission denied
  6. 0

    error while creating datasource in planing. very urgent

    Oracle Community | 8 years ago | 654316
    java.net.BindException: Address already in use: JVM_Bind

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.net.BindException

      Address already in use

      at sun.rmi.transport.tcp.TCPTransport.listen()
    2. Java RT
      UnicastRemoteObject.<init>
      1. sun.rmi.transport.tcp.TCPTransport.listen(TCPTransport.java:310)
      2. sun.rmi.transport.tcp.TCPTransport.exportObject(TCPTransport.java:218)
      3. sun.rmi.transport.tcp.TCPEndpoint.exportObject(TCPEndpoint.java:393)
      4. sun.rmi.transport.LiveRef.exportObject(LiveRef.java:129)
      5. sun.rmi.server.UnicastServerRef.exportObject(UnicastServerRef.java:190)
      6. java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:293)
      7. java.rmi.server.UnicastRemoteObject.exportObject(UnicastRemoteObject.java:235)
      8. java.rmi.server.UnicastRemoteObject.<init>(UnicastRemoteObject.java:133)
      8 frames
    3. JCS
      RemoteCacheServer.<init>
      1. org.apache.jcs.auxiliary.remote.server.RemoteCacheServer.<init>(RemoteCacheServer.java:111)
      1 frame