Thursday, September 29, 2016

UnknownHostException returned by DNS, in reality due to not enough file descriptors available

interesting case, intermittently we get this error:


java.net.UnknownHostException: somehostnamehere
                at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
                at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:922)
                at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1316)
                at java.net.InetAddress.getAllByName0(InetAddress.java:1269)
                at java.net.InetAddress.getAllByName(InetAddress.java:1185)
                at java.net.InetAddress.getAllByName(InetAddress.java:1119)
                at org.apache.http.impl.conn.SystemDefaultDnsResolver.resolve(SystemDefaultDnsResolver.java:44)
                at org.apache.http.impl.conn.HttpClientConnectionOperator.connect(HttpClientConnectionOperator.java:102)
                at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:314)
                at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:357)
                at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:218)
                at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:194)
                at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:85)
                at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:108)
                at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:186)
                at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
                at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
                


https://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/SystemDefaultDnsResolver.html

"DNS resolver that uses the default OS implementation for resolving host names"

public InetAddress[] resolve(String host) throws UnknownHostException 
{ return InetAddress.getAllByName(host); } 



https://docs.oracle.com/javase/7/docs/api/java/net/Inet4Address.html

https://docs.oracle.com/javase/7/docs/api/java/net/InetAddress.html#getAllByName(java.lang.String)


InetAddress Caching 
 The InetAddress class has a cache to store successful as well as unsuccessful host name resolutions. 
 By default, when a security manager is installed, in order to protect against DNS spoofing attacks, the result of positive host name resolutions are cached forever. When a security manager is not installed, the default behavior is to cache entries for a finite (implementation dependent) period of time. The result of unsuccessful host name resolution is cached for a very short period of time (10 seconds) to improve performance. 

If the default behavior is not desired, then a Java security property can be set to a different Time-to-live (TTL) value for positive caching. Likewise, a system admin can configure a different negative caching TTL value when needed. 

Two Java security properties control the TTL values used for positive and negative host name resolution caching: 

networkaddress.cache.ttl Indicates the caching policy for successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the successful lookup. The default setting is to cache for an implementation specific period of time. 
 A value of -1 indicates "cache forever". 

networkaddress.cache.negative.ttl (default: 10)Indicates the caching policy for un-successful name lookups from the name service. The value is specified as as integer to indicate the number of seconds to cache the failure for un-successful lookups. 
 A value of 0 indicates "never cache". A value of -1 indicates "cache forever". 



Unfortunately public native InetAddress[] lookupAllHostAddr(String hostname) throws UnknownHostException; is a NATIVE method, and it seems that the only exception he is capable of is UnknownHostException.. that is, even if the OS can't connect to DNS server, you get a UnknownHostException (which is totally incorrect)



Monday, September 26, 2016

List of videos to learn German - for beginners A1-B1

https://www.youtube.com/watch?v=yhP3OT2hxAE "Deutsch lernen Extra auf Deutsch Abschnitt 1 " there are some 20 episodes of this series, of growing difficulty. It's a funny sit-com a bit silly but enjoyable.

https://www.youtube.com/watch?v=4lk9rS7n-4Q Deutsch Plus - BBC , there are 20 episodes. VERY nice and realistic, the story of a Romanian immgrant in Germany.

https://www.youtube.com/watch?v=L3uatU-UH60 Deutschlandlabor by Goethe Institut - not much fun but decent. There are some 15 episodes (Folge)

https://www.youtube.com/watch?v=X-J1t8q0wxM Typisch, also by Goethe Institut, again not too enjoyable but decent. Some 12 episodes (Folge)

https://www.youtube.com/watch?v=PMj9kUPrnBk Mein Weg nach Deutschland , some 8 episodes, really really cool.

Wednesday, September 21, 2016

WebLogic fails with NullPointerException at weblogic.deploy.service.internal.adminserver.AdminDeploymentService$2.run(AdminDeploymentService.java:311)


<Sep 20, 2016 9:26:42 PM CEST> <Error> <Kernel> <BEA-000802> <ExecuteRequest failed
 java.lang.NullPointerException.
java.lang.NullPointerException
        at weblogic.deploy.service.internal.adminserver.AdminDeploymentService$2.run(AdminDeploymentService.java:311)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:553)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:311)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:263)
> 


We had similar cases ... always look in the weblogic_yyyy....log file for a root cause, it could be that the port used for administration is already in use, or that some security setting is messed up... you can also use "strace" to trace in detail the issue


Tuesday, September 6, 2016

WebLogic cluster: "Failed to deserialize statedump from server "

If you have an error "Failed to deserialize statedump from server " "java.lang.ClassNotFoundException"
you should read Oracle Document:

"How To Avoid De-Serialize Statedump Errors While Starting Manage Servers in Cluster Environment (java.lang.ClassNotFoundException) (Doc ID 796357.1)"

The solution is to start first the Admin, and only when this is running you should start the managed servers one by one, and not in parallel (the Oracle doc says the opposite). Don't ask me questions, I have no clue.

The other possible root cause could be an invalid EAR, try rebuilding it and redeploying it.

http://oraclefmwadmins.blogspot.ch/2014/07/bea-000140-failed-to-deserialize.html

Reason:
 Corrupted EJB files due to temporary communication failure between WebLogic admin and managed server instances

Solution:
 1. Stop Weblogic Managed/Admin Server
 2.Delete the directory under $DOMAIN_HOME/servers//tmp/_WL_user/
 3.Restart Admin/Managed servers. The file will create automatically.



See also http://www.ateam-oracle.com/weblogic-server-cluster-messaging-protocols/ "When a server (re)joins the cluster, that server will ask another server in the cluster to provide the current view of its JNDI tree (known as a JNDI state dump) to initialize its view and then rely on JNDI replication messages to maintain it. This JNDI state dump does not use the cluster messaging protocol and relies on a point-to-point connection with the other server."


 <BEA-000140> <Failed to deserialize statedump from server 8572742343661541822S:169.13.12.236:[-1,-1,31623,31623,-1,-1,-1]:pipposerver_cluster2:pippovaimsi0_chlp2520199_server with java.lang.ClassNotFoundException: com.pippo.Pluto.
java.lang.ClassNotFoundException: com.pippo.Pluto
                at weblogic.application.internal.AppClassLoaderManagerImpl.loadApplicationClass(AppClassLoaderManagerImpl.java:164)
                at weblogic.common.internal.ProxyClassResolver.resolveProxyClass(ProxyClassResolver.java:68)
                at weblogic.common.internal.WLObjectInputStream.resolveProxyClass(WLObjectInputStream.java:76)
                at java.io.ObjectInputStream.readProxyDesc(ObjectInputStream.java:1537)
                at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1493)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1977)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1901)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
                at weblogic.common.internal.WLObjectInputStream.readObjectWL(WLObjectInputStream.java:98)
                at weblogic.cluster.BasicServiceOffer.readExternal(BasicServiceOffer.java:172)
                at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1818)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1775)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
                at java.util.ArrayList.readObject(ArrayList.java:593)
                at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
                at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
                at java.lang.reflect.Method.invoke(Method.java:597)
                at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1019)
                at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1877)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
                at weblogic.common.internal.WLObjectInputStream.readArrayList(WLObjectInputStream.java:116)
                at weblogic.cluster.StateDumpMessage.readExternal(StateDumpMessage.java:53)
                at java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1818)
                at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1775)
                at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
                at java.io.ObjectInputStream.readObject(ObjectInputStream.java:349)
                at weblogic.cluster.HTTPExecuteRequest.run(HTTPExecuteRequest.java:90)
                at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
                at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)



One should assign a warmup period https://docs.oracle.com/cd/E13222_01/wls/docs100/schemaref/config/http.www.bea.com.ns.weblogic.920.domain/types/clustertype.member-warmup-timeout-seconds.html and make sure you use default protocol t3s


Thursday, September 1, 2016

WebLogic deployment plan for a EAR with EJB deployed in a WAR and not in a separate JAR module

https://docs.oracle.com/cd/E19798-01/821-1841/gippi/index.html

"To include enterprise bean class files in a WAR module, the class files should be in the WEB-INF/classes directory. To include a JAR file that contains enterprise beans in a WAR module, add the JAR to the WEB-INF/lib directory of the WAR module. WAR modules that contain enterprise beans do not require an ejb-jar.xml deployment descriptor. If the application uses ejb-jar.xml, it must be located in the WAR module’s WEB-INF directory. "

in this case you MUST put an empty weblogic-ejb-jar.xml in the WAR's file WEB-INF directory:


<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/weblogic-ejb-jar"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/weblogic-ejb-jar http://www.bea.com/ns/weblogic/weblogic-ejb-jar/1.0/weblogic-ejb-jar.xsd">
</weblogic-ejb-jar>





then you can provide a deployment plan plan.xml :


<?xml version='1.0' encoding='UTF-8'?>
<deployment-plan xmlns="http://xmlns.oracle.com/weblogic/deployment-plan" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/weblogic/deployment-plan http://xmlns.oracle.com/weblogic/deployment-plan/1.0/deployment-plan.xsd">
  <application-name>PippoApplication.ear</application-name>
  <variable-definition>
    <variable>
      <name>WeblogicEnterpriseBean_com.pippo.PippoBean_CreateAsPrincipalName_14562212116401</name>
      <value>SERVERSTARTUP.CREATE.PRINCIPAL</value>
    </variable>
  </variable-definition>
  <module-override>
    <module-name>PippoDashboard.war</module-name>
    <module-type>war</module-type>
    <module-descriptor external="false">
      <root-element>weblogic-ejb-jar</root-element>
      <uri>WEB-INF/weblogic-ejb-jar.xml</uri>
      <variable-assignment>
        <name>WeblogicEnterpriseBean_com.pippo.PippoBean_CreateAsPrincipalName_14562212116401</name>
        <xpath>/weblogic-ejb-jar/weblogic-enterprise-bean/[ejb-name="PippoBean"]/create-as-principal-name</xpath>
      </variable-assignment>
    </module-descriptor>
    <module-descriptor external="false">
      <root-element>ejb-jar</root-element>
      <uri>META-INF/ejb-jar.xml</uri>
    </module-descriptor>
  </module-override>
  <config-root>/path/to/envconfig/deployplans/</config-root>
</deployment-plan>


and in the config.xml you configure the deployment plan:

  <app-deployment>
    <name>PippoApplication</name>
    <target>mywlsserver</target>
    <module-type>ear</module-type>
    <source-path>/path/to/PippoApplication.ear</source-path>
    <deployment-principal-name>PIPPO.deployment.principal</deployment-principal-name>
    <plan-dir>/path/to/plan</plan-dir>
    <plan-path>/path/to/envconfig/deployplans/plan.xml</plan-path>
    <security-dd-model>Advanced</security-dd-model>
    <staging-mode>nostage</staging-mode>
  </app-deployment>