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

WebLogic EJB call timeout

$
0
0
If you get often this type of stuck threads:


"[STUCK] ExecuteThread: '170' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00002b4f841f1b20 nid=0x5763 in Object.wait() [0x00002b4f8c842000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x0000000776826778> (a weblogic.rjvm.ResponseImpl)
at weblogic.rjvm.ResponseImpl.waitForData(ResponseImpl.java:90)
- locked <0x0000000776826778> (a weblogic.rjvm.ResponseImpl)
at weblogic.rjvm.ResponseImpl.getTxContext(ResponseImpl.java:130)
at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:110)
at weblogic.rmi.internal.BasicRemoteRef.invoke(BasicRemoteRef.java:222)


you might want to set these 2 parameters (this for WLS 10.3.6 )
-Dweblogic.rmi.clientTimeout=valueInMilliseconds
weblogic.jndi.requestTimeout=valueInMilliseconds

The reason of that WAITING is that there is a synchronized blog followed by an Object.wait(timeout):


private void waitForData()
{
int i = 0;
synchronized (this)
{
long l1 = this.timeout;
while (!isAvailable()) {
try
{
int j = 0;
long l2 = System.currentTimeMillis();
wait(l1);
if (this.timeout > 0)
{
long l3 = System.currentTimeMillis() - l2;
if (l3 >= l1) {
j = 1;
} else {
l1 -= l3;
}
}
if ((!isAvailable()) && (j != 0))
{
this.t = new RequestTimeoutException("RJVM response from '" + this.rjvm + "' for '" + (this.md != null ? this.md.toString() : "null") + "' timed out after: " + this.timeout + "ms.");

i = 1;
}
}
catch (InterruptedException localInterruptedException) {}
}
}
if (i != 0) {
this.rjvm.removePendingResponse(this.id);
}
}

See also:
Oracle Support doc "JNDI Thread Stuck" (Doc ID 1482310.1)
For alternative ways to specify timeouts in WLS 12 , see https://docs.oracle.com/middleware/1212/wls/WLRMI/rmi_api.htm#WLRMI251
In WLS 10, https://docs.oracle.com/cd/E11035_01/wls100/ejb/DDreference-ejb-jar.html#wp1362824 use remote-client-timeout in your weblogic.ejb-jar.xml

Poll result: who finances ISIS?

Cluster down when leasing DB is restarted

$
0
0
if you get often a message
<BEA-310006><Critical subsystem JTAMigratableGroup has failed. Setting server state to FAILED. Reason: JTA migratable target lost a lease>
you might consider tuning these 2 parameters in confix.xml:
database-leasing-basis-connection-retry-count
"The maximum number of times Database Leasing will try to obtain a valid connection from the Data Source. (Interface=weblogic.management.configuration.ClusterMBean Attribute=getDatabaseLeasingBasisConnectionRetryCount)"

Default 1

database-leasing-basis-connection-retry-delay
The length of time, in milliseconds,Database Leasing will wait before attempting to obtain a new connection from the Data Source when a connection has failed. (Interface=weblogic.management.configuration.ClusterMBean Attribute=getDatabaseLeasingBasisConnectionRetryDelay)

Default 1000 (millis)

Always specify xml version in a XML file

$
0
0
<?xml version="1.0" encoding="UTF-8"?>
There was a case where one forgot it in a beans.xml file, and WebLogic tries to open a Socket to retrieve some stuff (no clue what) attempting some alternate way to retrieve the version information. Crazy. It's crazy to use XML in any case.... XML is the biggest failure in IT history.


"[STANDBY] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'" daemon prio=10 tid=0x00007f1a380184b0 nid=0x1f65 runnable [0x00007f1aa47bb000]

java.lang.Thread.State: RUNNABLE

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:344)

- locked <0x00000007f12f65b0> (a java.net.SocksSocketImpl)

at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200)

at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)

at java.net.Socket.connect(Socket.java:579)

at java.net.Socket.connect(Socket.java:528)

at sun.net.NetworkClient.doConnect(NetworkClient.java:180)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)

at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)

- locked <0x00000007f12f6528> (a sun.net.www.http.HttpClient)

at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)

at sun.net.www.http.HttpClient.New(HttpClient.java:308)

at sun.net.www.http.HttpClient.New(HttpClient.java:326)

at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1039)

at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:975)

at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:893)

at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1343)

- locked <0x00000007f12f23e8> (a sun.net.www.protocol.http.HttpURLConnection)

at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:664)

at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)

at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:582)

at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaParsingConfig.parse(SchemaParsingConfig.java:685)

at com.sun.org.apache.xerces.internal.impl.xs.opti.SchemaDOMParser.parse(SchemaDOMParser.java:530)

at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.getSchemaDocument(XSDHandler.java:2173)

at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:569)

at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:613)

at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2446)

at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1766)

at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:740)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(XMLNSDocumentScannerImpl.java:613)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:3132)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:856)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)

at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)

at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:504)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)

at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)

at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)

at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)

at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:642)

at weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:133)

at javax.xml.parsers.SAXParser.parse(SAXParser.java:392)

at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:107)

at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:137)

at org.jboss.weld.bootstrap.WeldBootstrap.parse(WeldBootstrap.java:485)

at org.jboss.weld.bootstrap.WeldBootstrap.parse(WeldBootstrap.java:481)

at com.oracle.injection.provider.weld.BasicBeanDeploymentArchive.getBeansXml(BasicBeanDeploymentArchive.java:87)

at org.jboss.weld.bootstrap.BeanDeployment.loadClasses(BeanDeployment.java:154)

at org.jboss.weld.bootstrap.BeanDeployment.createBeans(BeanDeployment.java:184)

at org.jboss.weld.bootstrap.WeldBootstrap.deployBeans(WeldBootstrap.java:349)

- locked <0x00000007ecfe8cd0> (a org.jboss.weld.bootstrap.WeldBootstrap)

at com.oracle.injection.provider.weld.WeldInjectionContainer.deploy(WeldInjectionContainer.java:103)

at com.oracle.injection.integration.CDIAppDeploymentExtension.initCdi(CDIAppDeploymentExtension.java:74)

at com.oracle.injection.integration.CDIAppDeploymentExtension.activate(CDIAppDeploymentExtension.java:49)

at weblogic.application.internal.flow.AppDeploymentExtensionFlow.activate(AppDeploymentExtensionFlow.java:37)

at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:729)

at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)

at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:258)

at weblogic.application.internal.EarDeployment.activate(EarDeployment.java:61)

at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:165)

at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:80)

at weblogic.deploy.internal.targetserver.BasicDeployment.activate(BasicDeployment.java:226)

at weblogic.deploy.internal.targetserver.BasicDeployment.activateFromServerLifecycle(BasicDeployment.java:418)

at weblogic.management.deploy.internal.DeploymentAdapter$1.doActivate(DeploymentAdapter.java:51)

at weblogic.management.deploy.internal.DeploymentAdapter.activate(DeploymentAdapter.java:200)

at weblogic.management.deploy.internal.AppTransition$2.transitionApp(AppTransition.java:30)

at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)

at weblogic.management.deploy.internal.ConfiguredDeployments.activate(ConfiguredDeployments.java:169)

at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:123)

at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:211)

at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:119)

at weblogic.server.AbstractServerService.postConstruct(AbstractServerService.java:78)

at sun.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.glassfish.hk2.utilities.reflection.ReflectionHelper.invoke(ReflectionHelper.java:1017)

at org.jvnet.hk2.internal.ClazzCreator.postConstructMe(ClazzCreator.java:388)

at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:430)

at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)

at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)

at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)

at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)

at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)

- locked <0x00000007063c7078> (a java.lang.Object)

at org.jvnet.hk2.internal.ServiceLocatorImpl.getService(ServiceLocatorImpl.java:606)

at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:77)

at org.jvnet.hk2.internal.ClazzCreator.resolve(ClazzCreator.java:231)

at org.jvnet.hk2.internal.ClazzCreator.resolveAllDependencies(ClazzCreator.java:254)

at org.jvnet.hk2.internal.ClazzCreator.create(ClazzCreator.java:413)

at org.jvnet.hk2.internal.SystemDescriptor.create(SystemDescriptor.java:456)

at org.glassfish.hk2.runlevel.internal.AsyncRunLevelContext.findOrCreate(AsyncRunLevelContext.java:225)

at org.glassfish.hk2.runlevel.RunLevelContext.findOrCreate(RunLevelContext.java:82)

at org.jvnet.hk2.internal.Utilities.createService(Utilities.java:2488)

at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:98)

- locked <0x00000007ffe69e58> (a java.lang.Object)

at org.jvnet.hk2.internal.ServiceHandleImpl.getService(ServiceHandleImpl.java:87)

at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.oneJob(CurrentTaskFuture.java:1162)

at org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$QueueRunner.run(CurrentTaskFuture.java:1147)

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)




Jboss EAP tutorials

Oracle Database Certification

$
0
0
OCA Associate (1Z0-061 and 1Z0-052)
OCP Professional
OCM Master
RAC Real Application Clusters
Database Control process
Oracle Enterprise Manager Grid Control
OCI (Oracle Call Interface)


Data Definition Language (DDL)
Data Control Language (DCL)
Transaction Control Language (TCL)

database = physical files on disk
instance = background processes
shared memory segments = system global area, or SGA . Contains: database buffer cache, log buffer, shared pool.
nonshareable memory = program global area, or PGA, private to the session
database buffer cache : to execute SQL.
log buffer (circular buffer) : contains change vectors before they are written to redo log
log writer background process, the LGWR, writes log buffer to disk (commit).
data dictionary cache = tables descriptions etc
library cache = executed parsed code
PL/SQL Area = part of the shared pool, in data dictionary
SQL Query and PL/SQL Function Result Cache
to retrieve tables definitions:
SELECT table_name FROM user_tables;
change vector, redo log
data guard: physical standby and logical standby
is part of RAC DB?
select parallel from v$instance;
has standby DB?
select protection_level from v$database;

Streams configured?
select * from dba_streams_administrator;
display memory settings for different areas (shared pool, large pool, java pool):
select COMPONENT,CURRENT_SIZE,MIN_SIZE,MAX_SIZE from v$sga_dynamic_components;
display PGA memory allocation:
select name,value from v$pgastat;

Notable processes:
System Monitor (SMON), Process Monitor (PMON), Database Writer (DBWn), Log Writer (LGWR), Checkpoint Process (CKPT), Manageability Monitor (MMON), Memory Manager (MMAN), Archiver (ARCn), Recoverer (RECO)
SMON mounts a DB
DBWn writes Database Buffer Cache to DB files
LGWR writes Log Buffers to disk
CKPT flushes dirty buffers
MMON monitors performance and statistics, launches the ADDM Automatic Database Diagnostic Monitor
MMAN Memory Manager
ARCn Archiver
to show all processes: select * from v$process;
Files:
controlfile (pointers to DB files, integrity checksums ),
the online redo log files,
and the datafiles

datafiles consist in blocks, segments, extents (=group of blocks)
SYSTEM and SYSAUX are 2 default tablespaces, they contain the METADATA (data dictionary)

USER_TABLES ALL_TABLES DBA_TABLES
dba_extents :
select DISTINCT TABLESPACE_NAME from dba_extents; -> SYSAUX UNDOTBS1 USERS SYSTEM
v$datafile : select * from v$datafile; gives you all the DBF files who make the DB
select * from dba_tablespaces; TABLESPACE_NAME are SYSTEM SYSAUX UNDOTBS1 TEMP USERS DEV_IAS_TEMP DEV_STB

Maven essential commands cheat sheet

performance issues in application/json vs application/x-www-form-urlencoded


WebLogic 2 Way SSL

$
0
0
on the server tab, enable SSL

on the SSL tab, enable "client certificate requested and enforced"

then enter https url in Firefox:

https://192.168.56.1:7002/SnoopServlet/SnoopServlet.jsp


Your connection is not secure

The owner of 192.168.56.1 has configured their website improperly. To protect your information from being stolen, Firefox has not connected to this website.


click on "advanced"


192.168.56.1:7002 uses an invalid security certificate. The certificate is not trusted because the issuer certificate is unknown. The server might not be sending the appropriate intermediate certificates. An additional root certificate may need to be imported. The certificate is not valid for the name 192.168.56.1. Error code: SEC_ERROR_UNKNOWN_ISSUER






Secure Connection Failed

An error occurred during a connection to 192.168.56.1:7002. SSL peer cannot verify your certificate. Error code: SSL_ERROR_BAD_CERT_ALERT

The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
Please contact the website owners to inform them of this problem.


See https://support.mozilla.org/en-US/kb/what-does-your-connection-is-not-secure-mean

In Firefox: Tools / Options / Advanced / Certificates / View certificates / Your Certificates

Run keystore explorer (it needs unlimited cryptography strength), create new pkcs12 keystore, Tools/generate key pair, rsa 2048 key length, sha-256 with RSA,

please enter the password that was used to encrypt this certificate backup

In Chrome:

This site can’t provide a secure connection

192.168.56.1 didn’t accept your login certificate, or one may not have been provided.
Try contacting the system admin.


I add set JAVA_OPTIONS="-Djavax.net.debug=all" to startWebLogic.cmd

javax.net.ssl.SSLHandshakeException: null cert chain

Certificate-based authentication (Name Mapper)

WebLogic: avoiding anonymous user calls

$
0
0

Servlet or JSP initialization


weblogic.xml


<servlet-descriptor>
<servlet-name>MyServletName</servlet-name>
<init-as-principal-name>MySERVLET.INIT.USER</init-as-principal-name>
</servlet-descriptor>


Where MyServletName needs to be replaced with the name of your Servlet, as declared in the web.xml file.

ServletContextListener


config.xml

<app-deployment>
<name>myapp</name>
<target>webInitServer</target>
<source-path>./deploy/presear</source-path>
<deployment-principal-name>MY.DEPLOYMENT.PRINCIPAL</deployment-principal-name>
<security-dd-model>Advanced</security-dd-model>
<staging-mode>nostage</staging-mode>
</app-deployment>



EJB create method


weblogic-ejb-jar.xml

<?xml version="1.0" encoding="UTF-8"?>
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/910/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>MyEJB</ejb-name>
<stateless-session-descriptor>
<business-interface-jndi-name-map>
<business-remote>acme.ejb.test.MyEJB</business-remote>
<jndi-name>pippo</jndi-name>
</business-interface-jndi-name-map>
<pool>
<max-beans-in-free-pool>5</max-beans-in-free-pool>
<initial-beans-in-free-pool>1</initial-beans-in-free-pool>
</pool>
<stateless-bean-is-clusterable>True</stateless-bean-is-clusterable>
</stateless-clustering>
</stateless-session-descriptor>
<create-as-principal-name>MY.EJB.CREATE.PRINCIPAL</create-as-principal-name>
</weblogic-ejb-jar>



EJB timer


ejb-jar.xml


<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar id="ejb-jar"
xmlns="http://java.sun.com/xml/ns/javaee" version="3.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd">
<enterprise-beans>
<session>
<ejb-name>CDRTimer</ejb-name>
<ejb-class>acme.ejb.timer.test.CDRTimerBean</ejb-class>
<session-type>Stateless</session-type>
<security-identity>
<run-as>
<role-name>TimerExecutor</role-name>
</run-as>
</security-identity>
</session>
</enterprise-beans>
<assembly-descriptor>
<security-role>
<description></description>
<role-name>TimerExecutor</role-name>
</security-role>
</assembly-descriptor>
<ejb-client-jar>CDRTimerEJBclientjar.jar</ejb-client-jar>
</ejb-jar>



weblogic-ejb-jar.xml


<run-as-role-assignment>
<role-name>TimerExecutor</role-name>
<run-as-principal-name>CDRTIMER.RUN.PRINCIPAL.NAME</run-as-principal-name>
</run-as-role-assignment>






Java: debugging HttpsClient connections

$
0
0
Recently we had this case:



java.io.EOFException: SSL peer shut down incorrectly 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:925)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1323)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1350)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1334)
at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:569)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1075)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
at com.sun.xml.ws.transport.http.client.HttpClientTransport.getOutput(HttpClientTransport.java:129)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:187)
at com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:124)
at com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:118)
at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866)
at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815)
at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778)
at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680)
at com.sun.xml.ws.client.Stub.process(Stub.java:272)
at com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:153)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:115)
at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:95)
at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:136)
at com.sun.proxy.$Proxy225.getInstruments30(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.wsee.jaxws.spi.ClientInstanceInvocationHandler.invoke(ClientInstanceInvocationHandler.java:84)
at com.sun.proxy.$Proxy227.getInstruments30(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)



Problem is, there is no way to trace the host, port, proxy parameters, protocols being used etc.

The classes involved are in jsse.jar and rt.jar (this is java 6!).

The other issue is that most attributes in those classes (HttpsClient, HttpClient...) have protected attributes, so you can't even access them easily with btrace or the like.

I ended up decompiling sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection from jsse.jar and changing the code to:


public void connect()
throws IOException
{
if (this.connected) {
return;
}
plainConnect();
if (this.cachedResponse != null) {
return;
}
if ((!this.http.isCachedConnection()) && (this.http.needsTunneling())) {
doTunneling();
}
try {
java.lang.reflect.Field phost = HttpClient.class.getDeclaredField("host");
phost.setAccessible(true);
java.lang.reflect.Field pport = HttpClient.class.getDeclaredField("port");
pport.setAccessible(true);
System.out.println("PV host = " + phost.get(this.http) + " port = " + pport.get(this.http) + " usingProxy=" + this.http.usingProxy + " getProxyHostUsed=" + this.http.getProxyHostUsed() + " getProxyPortUsed=" + this.http.getProxyPortUsed());
}
catch (Throwable t) {
System.out.println("PV an error occurred in AbstractDelegateHttpsURLConnection : ");
t.printStackTrace();
}
((HttpsClient)this.http).afterConnect();
}

packaging the compiled class in pvjsse.jar and adding -Xbootclasspath/p:pvjsse.jar to the JVM parameters. It works !

JPA, EclipseLink and Hibernate as a persistence provider

$
0
0
a customer was getting

weblogic.management.DeploymentException:

java.lang.ClassCastException: org.eclipse.persistence.jpa.jpql.parser.NullExpression
cannot be cast to org.eclipse.persistence.jpa.jpql.parser.IdentificationVariable
at org.eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.java:626)
at org.eclipse.persistence.jpa.jpql.parser.RangeVariableDeclaration.accept(RangeVariableDeclaration.java:98)
at org.eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.java:577)
at org.eclipse.persistence.jpa.jpql.parser.IdentificationVariableDeclaration.accept(IdentificationVariableDeclaration.java:71)
at org.eclipse.persistence.internal.jpa.jpql.DeclarationResolver$DeclarationVisitor.visit(DeclarationResolver.java:566)


using eclipselink.jar version 2.5.2 as part of the WLS distribution.
he finally made it work by using
weblogic-application.xml :


<prefer-application-packages>
<package-name>com.google.collections</package-name>
<package-name>com.google.common</package-name>
<package-name>org.hibernate.*</package-name>
<package-name>javax.validation</package-name>
</prefer-application-packages>



change the pom.xml to get extra dependency

<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.3.5.Final</version>
</dependency>




and in persistence.xml

<provider>org.hibernate.ejb.HibernatePersistence</provider>



cheap bash script to monitor connections to an IP

$
0
0
this will trace only connections in the SYN_SENT status ... if you get a SocketTimeoutException, the connection will never transition in the ESTABLISHED state, it will only wait in the SYS_SENT state until it times out...


cat monitornet.sh

while true
do
lines=`netstat -an | grep YOURDESTINATIONIP | grep SYN`
sleep 0.1
if [ "$lines" ]; then
echo `date` $lines
echo ""
fi
done




Maybe running netstat 10 times a second will kill your server, so you better sleep a bit more

byte buddy getting started

$
0
0

I use this pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pierre</groupId>
<artifactId>bytebuddytest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
</project>



and I run this Java code, as from the homepage http://bytebuddy.net/#/

import net.bytebuddy.ByteBuddy;
import net.bytebuddy.implementation.FixedValue;
import net.bytebuddy.matcher.ElementMatchers;

public class HelloWorld {
public static void main(String[] args) throws InstantiationException, IllegalAccessException {
HelloWorld helloWorld = new HelloWorld();
helloWorld.testHello();

}

public void testHello() throws InstantiationException, IllegalAccessException {
Class dynamicType = new ByteBuddy().subclass(Object.class).method(ElementMatchers.named("toString"))
.intercept(FixedValue.value("Hello World!")).make().load(getClass().getClassLoader()).getLoaded();

System.out.println(dynamicType.newInstance().toString());
}
}



It works! Exciting!


funny /etc/hosts behaviour

$
0
0
Someone entered 2 lines in /etc/hosts, specifying the same host and 2 different IPs


cat /etc/hosts | grep myvp.pippo.net

116.8.194.82 myvp.pippo.net
119.57.52.83 myvp.pippo.net



the funny thing is that:


nslookup myvp.pippo.net
Name: myvp.pippo.net
Address: 119.57.52.83


but


telnet myvp.pippo.net 443
Trying 116.8.194.82...



so nslookup and telnet don't follow the same strategy to pick up the IP...

At least on Linux 2.6.18-417.el5 RHAT 5.11 Tikanga

Weird that Linux doesn't report the issue...

Angular 4.2.3 getting started

$
0
0
https://angular.io/guide/quickstart


#make sure you have latest version of node and npm
node -v
npm -v

#clean up previous angular-cli installations
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm uninstall -g @angular/cli
npm cache clean

#install latest angular-cli
npm install -g @angular/cli@latest
ng new my-app
cd my-app
ng serve --open



Tour of Heroes https://angular.io/tutorial

System property jdk.tls.namedGroups(null) contains no supported elliptic curves

$
0
0
We get this using java version "1.6.0_141" Java(TM) SE Runtime Environment (build 1.6.0_141-b12) Java HotSpot(TM) 64-Bit Server VM (build 20.141-b12, mixed mode) :



java.lang.IllegalArgumentException: System property jdk.tls.namedGroups(null) contains no supported elliptic curves
at com.sun.net.ssl.internal.ssl.SupportedEllipticCurvesExtension.<clinit>(HelloExtensions.java:567)

<Jun 29, 2017 11:16:07 AM CEST> <Error> <Socket> <BEA-000421> <Uncaught Throwable in processSockets
java.lang.ExceptionInInitializerError.
java.lang.ExceptionInInitializerError
at com.sun.net.ssl.internal.ssl.HelloExtensions.<init>(HelloExtensions.java:73)
at com.sun.net.ssl.internal.ssl.HandshakeMessage$ClientHello.<init>(HandshakeMessage.java:223)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:204)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:945)
at com.sun.net.ssl.internal.ssl.Handshaker$1.run(Handshaker.java:885)
Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalArgumentException: System property jdk.tls.namedGroups(null) contains no supported elliptic curves
at com.sun.net.ssl.internal.ssl.SupportedEllipticCurvesExtension.<clinit>(HelloExtensions.java:567)
at com.sun.net.ssl.internal.ssl.HelloExtensions.<init>(HelloExtensions.java:73)
at com.sun.net.ssl.internal.ssl.HandshakeMessage$ClientHello.<init>(HandshakeMessage.java:223)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:204)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:945)
Truncated. see log file for complete stacktrace
>
<Jun 29, 2017 11:16:07 AM CEST> <Error> <Socket> <BEA-000421> <Uncaught Throwable in processSockets
java.lang.NoClassDefFoundError: Could not initialize class com.sun.net.ssl.internal.ssl.SupportedEllipticCurvesExtension.
java.lang.NoClassDefFoundError: Could not initialize class com.sun.net.ssl.internal.ssl.SupportedEllipticCurvesExtension
at com.sun.net.ssl.internal.ssl.HelloExtensions.<init>(HelloExtensions.java:73)
at com.sun.net.ssl.internal.ssl.HandshakeMessage$ClientHello.<init>(HandshakeMessage.java:223)
at com.sun.net.ssl.internal.ssl.ServerHandshaker.processMessage(ServerHandshaker.java:204)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:945)
at com.sun.net.ssl.internal.ssl.Handshaker$1.run(Handshaker.java:885)
Truncated. see log file for complete stacktrace



The issue can be solved by removing -Dweblogic.ssl.JSSEEnabled=true

According to the Oracle website this issue was introduced with 141-b12 - http://www.oracle.com/technetwork/java/javase/overview-156328.html#R160_141 and is fixed in JDK 141-b32

OverOps "The Complete Guide to Solving Java Application Errors in Production"

$
0
0
http://land.overops.com/java-application-errors/

I have downloaded the interesting free PDF. In a nutshell:

NullPointerException are the most common type of exception - followed by NumberFormatException (IMHO both can be avoided by better checks of input data/parameters and configuration: the external world is your enemy, never trust it)

Pareto Law: 97% of error logs are caused by just 3% unique errors

Read Joshua Bloch "Effective Java 2nd Edition" on how to handle exceptions

Logging errors is expensive in term of disk space... it's cheaper to fix them than to ignore them!

Operational noise is a killer: make sure your logs are clean, and your exception contain all the context information necessary to troubleshoot them

Venkat Subramanian, Java 8 hidden treasures

$
0
0


Lot of examples on Collectors here https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html


import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class CSV {
public static void main(String[] args) {

List<String> names = Arrays.asList("a", "b", "c");
System.out.println(names.stream().map(String::toUpperCase).collect(Collectors.toList()));
System.out.println(names.stream().map(String::toUpperCase).collect(Collectors.joining(",")));

}
}





interface Util {
public static int numberOfCores() {
return Runtime.getRuntime().availableProcessors();
}
}

public class IFWithStaticMethod {
public static void main(String[] args) {
System.out.println(Util.numberOfCores());

}
}



interface Fly {
default void takeoff() {
System.out.println("Fly:takeoff");
getState();
}

void getState();
}

public class IFDefault implements Fly {
public static void main(String[] args) {
IFDefault default1 = new IFDefault();
default1.takeoff();
}

@Override
public void getState() {
System.out.println("IFDefault:getState");

}

}






import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.Comparator;

enum GENDER {
MALE, FEMALE
}

class Person {
@Override
public String toString() {
return "Person [name=" + name + ", gender=" + gender + ", age=" + age + "]";
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public GENDER getGender() {
return gender;
}

public void setGender(GENDER gender) {
this.gender = gender;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

String name;
GENDER gender;
int age;

public Person(String name, GENDER gender, int age) {
super();
this.name = name;
this.gender = gender;
this.age = age;
}

}

public class Sorting {
public static List getPersons() {
return Arrays.asList(new Person("Sara", GENDER.FEMALE, 20), new Person("Sara", GENDER.FEMALE, 22),
new Person("Bob", GENDER.MALE, 20), new Person("Paula", GENDER.FEMALE, 32),
new Person("Paul", GENDER.MALE, 32), new Person("Jack", GENDER.MALE, 2),
new Person("Jack", GENDER.MALE, 72), new Person("Jill", GENDER.FEMALE, 12));
}

public static void main(String[] args) {
System.out.println(getPersons().stream().sorted(Comparator.comparing(Person::getName)).collect(Collectors.toList()));
}

}






import java.util.function.Predicate;

public class TestPredicate {
public static void main(String[] args) {
Predicate isOdd = (param) -> param % 2 == 0;
Predicate isOddAndGreaterThan5 = isOdd.and((param) -> param.intValue() > 5);

System.out.println(isOdd.test(2));
System.out.println(isOdd.test(3));
System.out.println(isOddAndGreaterThan5.test(3));
System.out.println(isOdd.test(6));
}
}



Viewing all 1124 articles
Browse latest View live