Quantcast
Channel: Java mon amour
Viewing all 1124 articles
Browse latest View live

Could not create the Java Virtual Machine

$
0
0

cat Test.java
public class Test {
public static void main(String[] args) {
System.out.println("ciao");
}

}
javac Test.java
export PIPPO="ciao - bello"
java -Dpippo=$PIPPO Test
Unrecognized option: -
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.



This is how a simple space in the value of a property can mess up your JVM.
if you run this
java -Dpippo="$PIPPO" Test
(with additional quotes) all works fine!

Security: how to sign a message

$
0
0

BEA-000449 Closing the socket, as no data read from it on 1.2.3.4:5,6789

$
0
0
BEA-000449 Closing the socket, as no data read from it on 1.2.3.4:5,6789 during the configured idle timeout of 5 seconds

1.2.3.4:5,6789 represents an IP (1.2.3.4) and port number 5,6789 (I find irritating that then print the , as separator....)

This message can be ignored NORMALLY (use a log filter is you like), and the IP addresses most likely are Load Balancer IPs. It means PROBABLY that a user doesn't wait for a web page to be entirely loaded, and navigates away closing abruptly the current socket transfer. The "configured idle timeout" however identifies a special case of "login timeout" kicking in (see below)

Read "Error Logs Say "Warning Socket BEA-000449 Closing socket as no data read" (Doc ID 2051032.1)" oracle document, saying that


"WebLogic Server tries to reuse sockets to improve performance, but sockets which are idle for a specified period are closed. The length of this period is controlled by the weblogic.client.socket.ConnectTimeout parameter, which specifies the amount of time the server waits before closing an inactive HTTP connection. This is set in the WebLogic Server startup script as one of the JAVA_OPTIONS. For example:

-Dweblogic.client.socket.ConnectTimeout=XXX"



Surely, if 5 seconds is too little , you can change it! Probably 5 s comes from the configuration value of login timeout :

"config / turning / login time out : (default is 5000ms)""The login timeout for this server's default regular (non-SSL) listen port. This is the maximum amount of time allowed for a new connection to establish." ServerMBean.LoginTimeoutMillis

It's the future

$
0
0
https://circleci.com/blog/its-the-future/

I am reblogging this fantastic piece of Theater, a sort of "Dialogue Concerning the Two Chief World Systems" where Simplicio at the end proves to be much wiser than Salviati. As for me, I like to be a Sagredo and sit and watch the dispute - only thinking that I can use a product only if it has sound foundations, proper engineering, excellent documentation and a huge amount of testing behind.



I had to disgrace in a distant past to work UNDER a guy who believed that any problem should be solved by at least half a dozen open source products stitched together in a wobbly haphazard and totally undocumented manner. I dedicate to him this post, with great relief that I am no longer UNDER him.

ClientHello and ServerHello

$
0
0
When you enable -Dssl.debug=true -Djavax.net.debug=ssl -Dweblogic.log.StdoutSeverity=Debug you get a lot of cryptic information in the logs
This document http://www.cisco.com/c/en/us/support/docs/security-vpn/secure-socket-layer-ssl/116181-technote-product-00.html explains quite well the SSL exchange protocol.


http://security.stackexchange.com/questions/19473/understanding-2048-bit-ssl-and-256-bit-encryption

this is a sample ClientHello:


*** ClientHello, TLSv1
RandomCookie: GMT: 1454428615 bytes = { 69, 83, 231, 161, 89, 17, 57, 52, 161, 204, 30, 120, 164, 155, 109, 48, 216, 11, 123, 111, 55, 22, 86, 64, 123, 128, 64, 180 }
Session ID: {}
Cipher Suites: [TLS_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_RSA_WITH_AES_256_CBC_SHA, TLS_DHE_DSS_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, TLS_EMPTY_RENEGOTIATION_INFO_SCSV]
Compression Methods: { 0 }
Extension server_name, server_name: [host_name: ldap.pippo.net]
***
[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', WRITE: TLSv1 Handshake, length = 94
[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)', READ: TLSv1 Handshake, length = 3726


this is a sample ServerHello:


*** ServerHello, TLSv1
RandomCookie: GMT: 1454428615 bytes = { 173, 6, 9, 133, 26, 24, 40, 154, 88, 2, 88, 175, 59, 169, 225, 31, 240, 132, 194, 100, 230, 48, 159, 177, 56, 91, 246, 67 }
Session ID: {49, 77, 200, 173, 221, 205, 188, 24, 24, 109, 151, 39, 90, 35, 26, 224, 39, 31, 102, 10, 125, 130, 207, 170, 124, 33, 67, 152, 53, 80, 6, 204}
Cipher Suite: TLS_RSA_WITH_AES_256_CBC_SHA
Compression Method: 0
Extension renegotiation_info, renegotiated_connection:
***
%% Initialized: [Session-1, TLS_RSA_WITH_AES_256_CBC_SHA]
** TLS_RSA_WITH_AES_256_CBC_SHA
*** Certificate chain
chain [0] = [
[
Version: V3

...... details about certificate chain


]
***
*** CertificateRequest
Cert Types: RSA, DSS, ECDSA
Cert Authorities:


*** ServerHelloDone







Tools to simulate network disruptions

Cannot instantiate weblogic.entitlement.data.ldap.EData

$
0
0
We got an interesting failure on WebLogic startup:

Cannot instantiate weblogic.entitlement.data.ldap.EData
null
java.lang.ExceptionInInitializerError
at com.octetstring.vde.util.guid.GuidGenerator.nextGuidInBytes(GuidGenerator.java:125)
at com.octetstring.vde.util.guid.Guid.(Guid.java:84)
at com.octetstring.vde.backend.standard.BackendStandard.add(BackendStandard.java:379)
at com.octetstring.vde.backend.BackendHandler.add(BackendHandler.java:460)
at weblogic.ldap.EmbeddedLDAPConnection.add(EmbeddedLDAPConnection.java:1152)
Truncated. see log file for complete stacktrace

Caused By: java.lang.NullPointerException
at java.lang.System.arraycopy(Native Method)
at com.octetstring.vde.util.guid.GuidParamGenerator.generateNodeID(GuidParamGenerator.java:47)
at com.octetstring.vde.util.guid.GuidStateManager.initializeGUIDParameters(GuidStateManager.java:59)
at com.octetstring.vde.util.guid.GuidStateManager.(GuidStateManager.java:30)
at com.octetstring.vde.util.guid.GuidStateManager.(GuidStateManager.java:23)
Truncated. see log file for complete stacktrace


The getLocalHost test failed:


bash-3.2$ cat TestMe.java
import java.net.InetAddress;
import java.net.UnknownHostException;

public class TestMe {
public static void main(String[] args) throws UnknownHostException
{ System.out.println(InetAddress.getLocalHost()); }
}

javac TestMe.java
java -cp . TestMe

Exception in thread "main" java.net.UnknownHostException: date: date
at java.net.InetAddress.getLocalHost(InetAddress.java:1430)
at TestMe.main(TestMe.java:6)


It turned out that "hostname" prints "date" , instead of the actual hostname
Checking into the usual files /etc/hosts /etc/inet/hosts /etc/hostname.vnet0 /etc/hostname.vnet1 (it's a Solaris box) didn't reveal anything strange.
Up to the OS specialist to fix it.

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

$
0
0
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>



WebLogic cluster: "Failed to deserialize statedump from server "

$
0
0
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.



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

$
0
0


<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

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

$
0
0
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.

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

$
0
0
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)

java.io.EOFException: SSL peer shut down incorrectly

$
0
0
This error:



Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:899)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1218)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1245)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1229)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:476)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1033)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler$1$1.getOutputStream(URLConnectionClientHandler.java:202)
at com.sun.jersey.api.client.CommittingOutputStream.commitWrite(CommittingOutputStream.java:117)
at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:89)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
at java.io.BufferedWriter.flush(BufferedWriter.java:236)
at com.sun.jersey.core.util.ReaderWriter.writeToAsString(ReaderWriter.java:191)
at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeToAsString(AbstractMessageReaderWriterProvider.java:128)
at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:88)
at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:58)
at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:311)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:181)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129)
... 7 more
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:462)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:880)
... 30 more


Unexpected error occured!
com.sun.jersey.api.client.ClientHandlerException: java.net.SocketException: Connection reset
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:131)
at com.csg.cs.batch.launch.client.util.JerseyClientWrapper$1.handle(JerseyClientWrapper.java:67)
at com.sun.jersey.api.client.Client.handle(Client.java:629)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:601)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:507)
at com.csg.cs.batch.launch.client.util.JerseyClientWrapper.postOverHTTPS(JerseyClientWrapper.java:87)
at com.csg.cs.batch.launch.client.JobClient.main(JobClient.java:86)
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:168)
at com.sun.net.ssl.internal.ssl.InputRecord.readFully(InputRecord.java:422)
at com.sun.net.ssl.internal.ssl.InputRecord.read(InputRecord.java:460)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:880)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1218)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1245)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1229)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:476)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1033)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler$1$1.getOutputStream(URLConnectionClientHandler.java:202)
at com.sun.jersey.api.client.CommittingOutputStream.commitWrite(CommittingOutputStream.java:117)
at com.sun.jersey.api.client.CommittingOutputStream.write(CommittingOutputStream.java:89)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
at java.io.BufferedWriter.flush(BufferedWriter.java:236)
at com.sun.jersey.core.util.ReaderWriter.writeToAsString(ReaderWriter.java:191)
at com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider.writeToAsString(AbstractMessageReaderWriterProvider.java:128)
at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:88)
at com.sun.jersey.core.impl.provider.entity.StringProvider.writeTo(StringProvider.java:58)
at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(RequestWriter.java:311)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:181)
at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:129)



according to Oracle Support KB documents:

SSL-Encrypted JDBC Connections Fail With "Remote host closed connection during handshake" (Doc ID 2149709.1)

Getting "javax.net.ssl.SSLHandshakeException: Remote Host Closed Connection During Handshake" Error (Doc ID 1572454.1)

it could be because of unsupported cypher suites (not in our case, this is a WLS to WLS communication, a DB listener is not involved) , or a proxy or a firewall in between that mangles the data transfer or closes the connection (mmmm this also is unsure)

Reflections: advanced queries on Java classpath

$
0
0
We have already explored Reflections here .

Another cool feature is to find programmatically all classes where a given method is invoked; here I search for all references to method oracle.ucp.common.UniversalConnectionPoolBase.registerConnectionAffinityCallback(...):



package com.pierre.typequerylanguage;

import static org.reflections.ReflectionUtils.getAllMethods;
import static org.reflections.ReflectionUtils.withPrefix;

import java.io.File;
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.Collection;
import java.util.Set;

import org.reflections.Reflections;
import org.reflections.scanners.FieldAnnotationsScanner;
import org.reflections.scanners.MemberUsageScanner;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.scanners.MethodParameterNamesScanner;
import org.reflections.scanners.MethodParameterScanner;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;

public class FindClassesInvokingMethod{
public static boolean VERBOSE = true;

public static void main(String[] args) {
if (VERBOSE) {
System.out.println("searching in the following jars:");
System.out.println(System.getProperty("java.class.path").replace(File.pathSeparatorChar, '\n'));
}
FilterBuilder oracleFilter = new FilterBuilder().include("oracle.*");
Collection<URL> asList = ClasspathHelper.forJavaClassPath();
Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(asList).filterInputsBy(oracleFilter).setScanners(new SubTypesScanner(false), new TypeAnnotationsScanner(), new FieldAnnotationsScanner(),
new MethodAnnotationsScanner(), new MethodParameterScanner(), new MethodParameterNamesScanner(), new MemberUsageScanner()));
;
System.out.println("searching now");


Set<Method> myMethods = getAllMethods(oracle.ucp.common.UniversalConnectionPoolBase.class, withPrefix("registerConnectionAffinityCallback"));
System.out.println(myMethods.size());
for (Method method : myMethods) {
System.out.println(method.getDeclaringClass());
Set<Member> usages = reflections.getMethodUsage(method);
for (Member member : usages) {
System.out.println("member.getDeclaringClass() " + member.getDeclaringClass());
}
}


System.out.println("searching done");
}

}





java.net.SocketException: Software caused connection abort: recv failed

$
0
0
if you see crap like this:


Caused by: java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1769)
at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124)
at sun.security.ssl.Handshaker.sendChangeCipherSpec(Handshaker.java:1083)
at sun.security.ssl.ClientHandshaker.sendChangeCipherAndFinish(ClientHandshaker.java:1222)
at sun.security.ssl.ClientHandshaker.serverHelloDone(ClientHandshaker.java:1134)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:348)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:979)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:914)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1062)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1375)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1283)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1258)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:250)


it means that the web service consumer doesn't send the certificate
In reality the client should send a different (more meaningful) error, related to SSL handshake, that in reality it catched and ignores....then he tries to read the data, which never arrive, then he complains that the server closed the socket.
You discover what really happened by setting the debug flags for jsse and you see that the server requests the client certificate, receives nothing and then sends the client to hell - which is the expected behaviour.

Too small initial heap for new size specified

$
0
0
You must provide a max total heap > min new heap.
This is fine:

java -XX:NewSize=256m -Xmx257m -version
java version "1.6.0_20"
OpenJDK Runtime Environment (IcedTea6 1.9.8) (rhel-1.22.1.9.8.el5_6-x86_64)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)


This is not fine, as no space is left for Old generation

java -XX:NewSize=256m -Xmx256m -version
Error occurred during initialization of VM
Too small initial heap for new size specified



See http://www.oracle.com/technetwork/articles/java/vmoptions-jsp-140102.html for more documentation

I know this is trivial, but many people don't know.

oracle.jdbc.driver.OraclePreparedStatement.setupDbaBindBuffers ArrayIndexOutOfBoundsException

$
0
0
We occasionally get this stacktrace in an application processing XA transactions

Caused By: java.lang.ArrayIndexOutOfBoundsException: -1
at oracle.jdbc.driver.OraclePreparedStatement.setupDbaBindBuffers(OraclePreparedStatement.java:3528)
at oracle.jdbc.driver.OraclePreparedStatement.setupBindBuffers(OraclePreparedStatement.java:3046)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:12194)
at oracle.jdbc.driver.OracleStatementWrapper.executeBatch(OracleStatementWrapper.java:246)
at weblogic.jdbc.wrapper.PreparedStatement.executeBatch(PreparedStatement.java:216)
at weblogic.store.io.jdbc.ReservedConnection.executeBatchForStatement(ReservedConnection.java:1204)
at weblogic.store.io.jdbc.JDBCStoreIO.flushInner(JDBCStoreIO.java:2603)
at weblogic.store.io.jdbc.JDBCStoreIO.flushWithRetry(JDBCStoreIO.java:2413)
at weblogic.store.io.jdbc.JDBCStoreIO.flush(JDBCStoreIO.java:1999)
at weblogic.store.io.jdbc.JDBCStoreIO.flush(JDBCStoreIO.java:1955)
at weblogic.store.internal.PersistentStoreImpl.synchronousFlush(PersistentStoreImpl.java:1143)
at weblogic.store.internal.PersistentStoreImpl.run(PersistentStoreImpl.java:1116)
at java.lang.Thread.run(Thread.java:745)



It seems there is a patch for this
"Getting ArrayIndexOutOfBoundsException When Doing ExecuteBatch With Oracle JDBC Driver 12.1.0.2 (Doc ID 1985195.1)"
Patch 19002423

The specified size exceeds the maximum representable size

$
0
0
If you run this:


java -Xms4096m Bla


and you get this:



Invalid initial heap size: -Xms4096m
The specified size exceeds the maximum representable size


it simply means that you are using a 32bit JVM instead of a 64bit JVM.

check "java -d64"

java -d64 -version Error: This Java instance does not support a 64-bit JVM. Please install the desired version.

Btrace: trace all Exceptions

$
0
0
see http://www.javamonamour.org/2013/06/getting-started-with-btrace.html for an introduction to btrace. This product is WONDERFUL.
In this new case, I want to trace where a given exception (java.io.FileNotFoundException) is thrown. I use the OnThrow.java example on the btrace site, slightly customized:


import static com.sun.btrace.BTraceUtils.*;

/**
* This example demonstrates printing stack trace
* of an exception and thread local variables. This
* trace script prints exception stack trace whenever
* java.lang.Throwable's constructor returns. This way
* you can trace all exceptions that may be caught and
* "eaten" silently by the traced program. Note that the
* assumption is that the exceptions are thrown soon after
* creation [like in "throw new FooException();"] rather
* that be stored and thrown later.
*/
@BTrace public class OnThrow {
// store current exception in a thread local
// variable (@TLS annotation). Note that we can't
// store it in a global variable!
@TLS static Throwable currentException;

// introduce probe into every constructor of java.lang.Throwable
// class and store "this" in the thread local variable.
@OnMethod(
clazz="java.io.FileNotFoundException",
method="<init>"
)
public static void onthrow(@Self Throwable self) {
currentException = self;
}

@OnMethod(
clazz="java.io.FileNotFoundException",
method="<init>"
)
public static void onthrow1(@Self Throwable self, String s) {
currentException = self;
}

@OnMethod(
clazz="java.io.FileNotFoundException",
method="<init>"
)
public static void onthrow1(@Self Throwable self, String s, Throwable cause) {
currentException = self;
}

@OnMethod(
clazz="java.io.FileNotFoundException",
method="<init>"
)
public static void onthrow2(@Self Throwable self, Throwable cause) {
currentException = self;
}

// when any constructor of java.lang.Throwable returns
// print the currentException's stack trace.
@OnMethod(
clazz="java.io.FileNotFoundException",
method="<init>",
location=@Location(Kind.RETURN)
)
public static void onthrowreturn() {
if (currentException != null) {
Threads.jstack(currentException);
println("=====================");
currentException = null;
}
}
}



Since we have Java6, I had to download an old version of btrace (1.2.1 or so). I could not run the btracec and btrace scripts for shell compatibility issues, so I run directly the java commands:

/opt/pippo/java/jdk160_115/bin/java -cp /tmp/btrace-bin/build/btrace-client.jar:/opt//pippo/java/jdk160_115/lib/tools.jar com.sun.btrace.compiler.Compiler $*
/tmp/btrace-bin/bin/OnThrow



/opt/pippo/java/jdk160_115/bin/java -Dcom.sun.btrace.probeDescPath=. -Dcom.sun.btrace.dumpClasses=false -Dcom.sun.btrace.debug=false -Dcom.sun.btrace.unsafe=false -cp /tmp/btrace-bin/build/btrace-client.jar:/opt/pippo/java/jdk160_115/lib/tools.jar:/usr/share/lib/java/dtrace.jar com.sun.btrace.client.Main 23262 /tmp/btrace-bin/bin/OnThrow.class

with 23262 being the PID of my WebLogic application server.

Btrace is the best thing after ice cream in life.

Apache POI is a Memory Pig

$
0
0
We get this stacktrace



java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2271)
at java.io.ByteArrayOutputStream.toByteArray(ByteArrayOutputStream.java:191)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource$FakeZipEntry.(ZipInputStreamZipEntrySource.java:132)
at org.apache.poi.openxml4j.util.ZipInputStreamZipEntrySource.(ZipInputStreamZipEntrySource.java:55)
at org.apache.poi.openxml4j.opc.ZipPackage.(ZipPackage.java:88)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:273)



This even processing relatively small (10 MB) Excel files.
It seems that we are not alone on this Planet to experience this problem. And there doesn't seem to be a workaround, apart increasing heap, for lack of a Streaming Interface.
Viewing all 1124 articles
Browse latest View live