Sunday, June 18, 2017

Angular 4.2.3 getting started

https://angular.io/guide/quickstart

How to install and use CLI : https://github.com/angular/angular-cli/blob/master/README.md

#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



Friday, June 16, 2017

funny /etc/hosts behaviour

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

Thursday, June 15, 2017

byte buddy getting started


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!



Wednesday, June 14, 2017

cheap bash script to monitor connections to an IP

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



Tuesday, June 13, 2017

JPA, EclipseLink and Hibernate as a persistence provider

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>





Java: debugging HttpsClient connections

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 !



Saturday, June 10, 2017

WebLogic: avoiding anonymous user calls

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>








Certificate-based authentication (Name Mapper)

UserNameMapper and its sub-interface X509SubjectComponentMapper

These classes are in $oraclehome/wlserver/server/lib/mbeantypes/wls-security-providers.jar





WebLogic 2 Way SSL

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



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

alternative 1:

httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded");


alternative 2:

httpPost.setHeader("Content-Type", "application/json"); 


using application/x-www-form-urlencoded in Content-Type 3mb POST is taking 101 seconds
using json content type 3mb POST is taking 2 seconds
For a discussion on what is what, see here http://stackoverflow.com/questions/9870523/differences-in-application-json-and-application-x-www-form-urlencoded



Maven essential commands cheat sheet

https://maven.apache.org/guides/MavenQuickReferenceCard.pdf
Javabrains tutorial https://www.youtube.com/watch?v=IYRYbPR5Gek&index=1&list=PL92E89440B7BFD0F6
mvn archetype:generate
mvn compile
mvn package
mvn validate
mvn test
mvn install
mvn deploy


Maven sucks!

Oracle Database Certification

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


Jboss EAP and Wildfly tutorials

I need to take an interview covering also JBoss....
https://en.wikipedia.org/wiki/JBoss_Enterprise_Application_Platform

https://en.wikipedia.org/wiki/WildFly

http://undertow.io/

https://en.wikipedia.org/wiki/OpenShift

Excellent extensive tutorial on all aspects of JBoss:
https://www.youtube.com/watch?v=KUXdQd_14fU&list=PL09NkvEHuNCdEEkCwUSlTA9UKlR4jo8rc

Wildfly presentation


Developing Java EE applications with JBoss
https://github.com/javaee-samples/javaee7-samples


Always specify xml version in a XML file

<?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)

               




Friday, May 19, 2017

Cluster down when leasing DB is restarted

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)



Saturday, May 6, 2017

Poll result: who finances ISIS?



Friday, April 28, 2017

WebLogic EJB call timeout

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 block 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
The Timeout event will cause a RequestTimeoutException which is a IOException : http://docs.oracle.com/cd/E57014_01/wls/WLAPI/weblogic/rmi/extensions/RequestTimeoutException.html See also Oracle Support article "How to configure timeout for an EJB Client (Doc ID 943282.1)"

in a nutshell:
-Dweblogic.rmi.clientTimeout=timeoutinmilliseconds sets the timeout on the client (consumer) side
remote-client-timeout in weblogic-ejb-jar.xml sets the timeout on the server (provider) side.


Saturday, April 15, 2017

Oracle certified professional Java SE 8 Programmer exam 1z0-809



I recommend buying this book, the examples are very clear and concepts are clearly exposed
For more resources to prepare the exam, see http://javarevisited.blogspot.ch/2016/10/top-2-books-for-ocpjp8-certification-1Z0-809-810-813.html#axzz4gQG3YVXO

Saturday, April 8, 2017

Support Global Transactions

For a non-XA Datasource, you can choose to "Support Global Transactions" or not:


In the first case you get <global-transactions-protocol>None</global-transactions-protocol>
in the second case <global-transactions-protocol>OnePhaseCommit</global-transactions-protocol>


Friday, April 7, 2017

Happy third world war to everybody

Meanwhile I suggest you to google for:
false flag
Tonkin
USS Maine
Lusitania
Pearl Harbor
just to name a few...


For those who understand German or Italian, Daniele Ganser explains why NATO helps Terrorists in Syria (it's about gas and oil as usual)


But of course there is no need to worry about reality, the magic virtual World of IT will provide refuge to all geeks.



Saturday, April 1, 2017

Brilliant Java8 tutorial by mkyong

https://www.mkyong.com/tutorials/java-8-tutorials/
I will recap here the salient points.
mkyong analyzes the use of a Functional Interface https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html In a nutshell:
Collections have a sort method using a comparator, which can be a lambda expression (list of named parameters in (params), -> and the method implementation:
List<Developer> listDevs;
listDevs.sort((Developer o1, Developer o2)->o1.getAge()-o2.getAge());


collections have a forEach method, using also a lambda (a Map has a special forEach)
List<Developer> listDevs;
listDevs.forEach((developer)->System.out.println(developer));
listDevs.forEach(System.out::println);

Map<String, Integer> items;
items.forEach((k,v)->System.out.println("Item : " + k + " Count : " + v));


actually it's not even necessary to declare the type of the parameters, the compiler can infer them from the List type:

listDevs.sort((o1, o2)->o1.getAge()-o2.getAge());


and of course you can assign the Comparator lambda to a variable:
Comparator<Developer> salaryComparator = (o1, o2)->o1.getSalary().compareTo(o2.getSalary());

A Collection can be turned into a stream and filtered
List<String> items;
items.stream().filter(s->s.contains("B")).forEach(System.out::println);


and of course you can turn the result of "stream().filter()" into a Collection using collect():


List<String> result = lines.stream().filter(line -> !"mkyong". equals (line)).collect(Collectors.toList()); 


To return the first match in a filter (and null if not found) there is a compact way:

Person result = persons.stream().filter(x -> "michael".equals(x.getName())).findAny().orElse(null);


You can map on the fly each collection element into a String, using "map()":

String name = persons.stream().filter(x -> "michael".equals(x.getName())).map(Person::getName).findAny().orElse("");


One can also perform "group by" on a Stream, just like in SQL (the syntax is a bit obscure, honestly):

Map<String, Long> result = items.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));


this is well documented here https://docs.oracle.com/javase/8/docs/api/java/util/stream/Collectors.html

You can create a stream directly, then convert it to a List:
Stream<String> language = Stream.of("java", "python");
List<String> myList = language.collect(Collectors.toList())


same with an array:
Stream<String> stream1 = Arrays.stream(array);




well, in the long run it becomes quite tedious, all this collection manipulation...

Very cool is the java.util.Optional



Saturday, March 25, 2017

Poll results: I believe Obama's allegations about Russian hackers



So the absolute majority of voters believe it's nonsense.

Friday, March 24, 2017

WebLogic : Controlling Multi Data Source Failover with a Callback

Here the schema http://xmlns.oracle.com/weblogic/jdbc-data-source/1.5/jdbc-data-source.xsd

and here the documentation : https://docs.oracle.com/cd/E24329_01/web.1211/e24367/jdbc_multidatasources.htm#JDBCA209

"The name of the application class to handle the callback sent when a multi data source is ready to failover or fail back connection requests to another data source within the multi data source. The name must be the absolute name of an application class that implements the weblogic.jdbc.extensions.ConnectionPoolFailoverCallback interface."



Monday, March 20, 2017

Book review: The rise of the Robots

https://www.amazon.com/Rise-Robots-Technology-Threat-Jobless/dp/0465097537



The book is excellent. Read it. Then you will be really scared about the future, and I mean the next 10-20 years. Because it's going to be a very quick process the one putt us all out of work. Unless you belong to a very selected elite of super-engineers dedicated to AI processes. Or someone like a surgeon or medical doctor who HAS to be present to a process to give some accountability.

I have read the book and felt really frightened. No matter how hard one studies, s/he will never be able to compete with a machine.

Nevertheless life goes on and I keep studying. More for personal pride and curiosity. Anyway in 9 years I will be 65 inshallah and hope to retire...



LoggingLastResource

If you use a LoggingLastResource Datasource, you must specify a table with the tag jdbcllr-table-name in config.xml.

We did that and we got

"javax.transaction.SystemException: Failed to call registerLoggingResourceTransactions() weblogic.transaction.loggingresource.LoggingResourceException: weblogic.transaction.loggingresource.LoggingResourceException: java.sql.SQLException: JDBC LLR, table verify failed for table 'WL_LLR_PIPPO_7436', failed to create table"

I have enabled the flags

-Dweblogic.debug.DebugJDBCSQL=true -Dweblogic.log.StdoutSeverity=Debug -Dweblogic.StdoutDebugEnabled=true

and discovered this

[weblogic.jdbc.wrapper.Statement_oracle_jdbc_driver_OracleStatementWrapper@4] 
executeUpdate(CREATE TABLE WL_LLR_PIPPO_7436 (XIDSTR VARCHAR(40) NOT NULL PRIMARY KEY, POOLNAMESTR VARCHAR(64), RECORDSTR VARCHAR(1000))) 
throws java.sql.SQLSyntaxErrorException: ORA-01031: insufficient privileges

        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059)
        at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522)
        at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257)
        at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:210)
        at oracle.jdbc.driver.T4CStatement.doOall8(T4CStatement.java:30)
        at oracle.jdbc.driver.T4CStatement.executeForRows(T4CStatement.java:931)
        at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1150)
        at oracle.jdbc.driver.OracleStatement.executeUpdateInternal(OracleStatement.java:1707)
        at oracle.jdbc.driver.OracleStatement.executeUpdate(OracleStatement.java:1670)
        at oracle.jdbc.driver.OracleStatementWrapper.executeUpdate(OracleStatementWrapper.java:310)
        at weblogic.jdbc.wrapper.Statement.executeUpdate(Statement.java:535)
        at weblogic.jdbc.wrapper.JTSLoggableResourceTable.createTable(JTSLoggableResourceTable.java:234)
        at weblogic.jdbc.wrapper.JTSLoggableResourceTable.findOrCreateTable(JTSLoggableResourceTable.java:287)
        at weblogic.jdbc.wrapper.JTSLoggableResourceImpl.findOrCreateBackingTable(JTSLoggableResourceImpl.java:530)




so you can simply ask the DBA to create the table, or grant you CREATE TABLE privileges.

Sunday, March 19, 2017

Suspending a MDB

It's easy to suspend consumption of JMS messages from a MDB with WLST (this code is from an Oracle Support document):
connect("username", "password", "t3://host:port")
domainRuntime()
cd("/ServerRuntimes/TargetServerName/ApplicationRuntimes/ApplicationDeploymentName/ComponentRuntimes/ApplicationDeploymentName/EJBRuntimes/MDBName_JNDINameoftheQueue")
cmo.suspend()


The Java JMX version is horrendously more complicated.

Here http://middlewaremagic.com/weblogic/?p=5099 they say:

“NOTE:Suspending One individual MDB from an EAR file is not possible so if your EAR application Contains multiple MDBs then you will have to suspend all the MDBs present in that EAR like above.”

but I am not really sure this is true, since there is a JMX method for this:

http://docs.oracle.com/cd/E23943_01/apirefs.1111/e13945/weblogic/management/runtime/MessageDrivenEJBRuntimeMBean.html#suspend()

However if you restart WLS, the MDB will resume consumption.

If you use native WLS JMS, you can disable consumption on the JMS queue itself. This feature doesn't seem to be available for foreign JMS destinations (like MQ). In this case, you can simply comment out the destination in the JMS WLS configuration XML.... the MDB at startup will complain that it can't connect to the destination, but the application will still deploy. It's a horrible hack but it works



Learning React - books and tutorials

https://www.youtube.com/watch?v=-AbaV3nrw6E&list=PL6gx4Cwl9DGBuKtLgPR_zWYnrwv-JllpA this is a cool simple tutorial showing you the basics of React programming.

You can also go through the examples here https://facebook.github.io/react/docs/installation.html using Codepen.

I had a look at these 2 books: https://leanpub.com/the-road-to-learn-react and http://www.apress.com/us/book/9781484212462 but I found the first is just a bunch of notes put quickly together without much explanation and conceptualization, the second on the opposite too complex and verbose and not straight to the point.

I am increasingly turning to videos to learn new "technologies", especially videos which show real-time coded examples accompanied by explanation - they are definitely more expressive than traditional static written information with code snippets.

Incidentally this site http://todomvc.com/ is quite cool, it showcases a huge collection of frameworks to implement the same application.... it's scary that there are so many products out there.... my impression is that IT is becoming more and more a titanic mess without standards.

Thursday, March 16, 2017

WebLogic ClusterMessaging

We occasionally see these messages in an instance of a WLS cluster:

####<Mar 8, 2017 10:21:43 AM CET> <Info> <WorkManager> <myhost> <myserver> <[ACTIVE] ExecuteThread: '13' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1488964903589> <BEA-002939> <The maximum thread constraint ClusterMessaging has been reached 2 times for the last 237 seconds.>

What is that constraint ClusterMessaging ? It's set internally by WLS on a WorkManager, it allows max 8 threads to handle the internal cluster messaging and this parameter can't be changed.

If you want to detect what is wrong, take a few thread dumps at interval of 3-5 seconds. Most likely you have some huge object in the JNDI tree being serialized/deserialized. Another possibility is that you have a non serializable object in the JNDI tree. If this is not the case, try analyzing your network traffic (the procedure could be very differend depending if you are using Multicast of Unicast)

In our case, we had this message which could be a hint that serialization is wrong:

<Mar 14, 2017 10:30:19 AM CET> <Error> <Cluster> <BEA-000123> <Conflict start: You tried to bind an object under the name jdbc.workflow.HibernateSessionFactory in the JNDI tree. The object from -2132852355821393490S:169.56.179.213:[-1,-1,32275,32275,-1,-1,-1]:mydomain:myserver01 is non-clusterable, and you have tried to bind more than once from two or more servers. Such objects can only be deployed from one server.>



Wednesday, March 15, 2017

Birbal story

If you don't know Birbal, please google it and try to read some of his stories. Birbal is one of the best memories I have brought back from India.

I am reblogging here this story because it's too precious to go lost. In fact I have found it on another blog.



Once Akbar asked Birbal “Which is the most precious thing in the world? Is it diamonds, rubies or gold?” Birbal thought for a minute and replied with a smile “The most precious thing is not diamonds, rubies or gold but the relief of shitting”. Akbar was outraged! He started storming around his court screaming at Birbal and his insolence. “You fool! Have you finally lost it? You see my kingdom? It’s the richest and the most powerful empire. I own every precious thing conceivable. And you make a joke on my treasures? Get out of my sight or else I will have you beheaded.” But Birbal had far too much pride to quit. After a couple of days, Akbar was supposed to leave on a boat trip to a far away part of his empire. In the morning breakfast, Birbal mixed some Croton seeds, jamalgota, in Akbar’s food. So when Akbar was almost half way through the water journey, he got a very pressing call of nature. And when it did not subside and kept on increasing, he asked the men to turn back and head for shore. They barely made it in time to the shore and Akbar ran into the bushes with a pail of water. When he came back, he was smiling with beads of perspiration on his forehead. And there Birbal was, giving Akbar a knowing smile. Akbar conceded “Yeah, now I know you were right as always Birbal...”


References:

https://en.wikipedia.org/wiki/Croton_tiglium

https://en.wikipedia.org/wiki/Birbal

Tuesday, March 7, 2017

Warning: org.apache.xerces.parsers.SAXParser: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized

We often see in the logs

Warning: org.apache.xerces.parsers.SAXParser: Feature 'http://javax.xml.XMLConstants/feature/secure-processing' is not recognized.
Warning: org.apache.xerces.parsers.SAXParser: Property http://javax.xml.XMLConstants/property/accessExternalDTD' is not recognized.
Warning org.apache.xerces.parsers.SAXParser: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized


See https://access.redhat.com/solutions/1124603 and https://issues.apache.org/jira/browse/XERCESJ-1654

see also Oracle Support:

Warning: org.apache.xerces.parsers.SAXParser After Upgrade to JDK 1.6.0_75 or Higher (Doc ID 1951255.1)

These messages are "logged" by com.sun.org.apache.xml.internal.utils.XMLReaderManager

public synchronized XMLReader getXMLReader()
    throws SAXException
  {
    if (this.m_readers == null) {
      this.m_readers = new ThreadLocal();
    }
    if (this.m_inUse == null) {
      this.m_inUse = new HashMap();
    }
    XMLReader reader = (XMLReader)this.m_readers.get();
    boolean threadHasReader = reader != null;
    String factory = SecuritySupport.getSystemProperty("org.xml.sax.driver");
    if ((threadHasReader) && (this.m_inUse.get(reader) != Boolean.TRUE) && ((factory == null) || (reader.getClass().getName().equals(factory))))
    {
      this.m_inUse.put(reader, Boolean.TRUE);
    }
    else
    {
      try
      {
        try
        {
          reader = XMLReaderFactory.createXMLReader();
          try
          {
            reader.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", this._secureProcessing);
          }
          catch (SAXNotRecognizedException e)
          {
            System.err.println("Warning:  " + reader.getClass().getName() + ": " + e.getMessage());
          }
        }
        catch (Exception e)




so even if you add a Log Filter in WebLogic you won't prevent them from appearing in the stdout/stderr
Try updating to latest Xerces implementation http://xerces.apache.org/mirrors.cgi (prepend xercesImpl.jar and xml-apis.jar to your system classpath, or deploy in your EAR using prefer-application-packages)


Monday, March 6, 2017

Itinerary to visit Istanbul

You have to visit below places (ordered by importance/ must do)
1) There are many types of Bosphorus Ferry tours. http://www.turkeytravelplanner.com/go/Istanbul/Sights/Bosphorus/BosphorusCruise.html

2) These places are close to each other

Kapali Çarşisi (Covered or Grand Bazaar) http://kapalicarsi.com.tr/

Misir Çarşisi (Egyptian or Spice Market) http://www.istanbul-travel.net/egyptian-spice-bazaar.html

3) These places are close to each other

Haghia Sophia http://www.istanbul-travel.net/hagia-sophia-church.html
Topkapi Palace http://www.360tr.com/topkapi/index.htm
Sultanahmet Camii (Blue Mosque) http://www.istanbul-travel.net/the-blue-mosque.html
Yerebatan Sarayi (Basilica Cistern) http://www.istanbul-travel.net/basilica-cistern.html
Mevlevi Monastery http://www.istanbul-travel.net/mevlevi-monastery.html

4) Istiklal Street - Taxim http://www.istanbul-travel.net/istiklal-street.html

5) DolmaBahce Palace http://www.istanbul-travel.net/dolmabahce-palace.html

6) Istanbul islands (Princes' Islands) http://www.turkeytravelplanner.com/go/Istanbul/Sights/adalar/

Another list, you may find a few extra places in it.
If you go to Ortaköy, you have to eat “Kumpir” there. It is very popular.
There you can also have a tea(and eat simit http://en.wikipedia.org/wiki/Simit ) next to bosphorous and buy things from small shops.
If you like sweets, I would suggest buying baklava and other things from Gulluoglu, or MADO.
more:
Beyoglu (Pera): Istanbul's real centre now is the Grand Rue de Pera (Istiklal Caddesi). Nice restaurants and shops. Crowded.

• In the Sultanahmet Square :

• Istanbul Archaeology Museums

• Grand Bazar

• Spice Bazar

• Galata Tower: cross the Golden Horn Bridge and give a coffee break at Karaköy before heading to Tünel and going up the Galata Tower to watch the splendid view of Istanbul.

• Dolmabahce Palace

• OrtaKöy

• Bagdat Caddesi (Bagdat Street): the Anatolian side.

• • Istanbul hamams

The Museum Pass Istanbul is a museum entrance card that allows entrance to Istanbul’s twelve must-see museums, without having to endure the long queues. The 85 TL Museum Pass is valid for 72 hours (3 days) and the 115 TL Museum Pass for 120 hours (5 days) from the first museum visit.

The Museum Pass Istanbul gives easy access to:
Hagia Sophia Museum
Topkapi Palace Museum and Harem Apartments
Istanbul Archaeological Museums
The Museum of Turkish and Islamic Arts
Museum for the History of Science and Technology in Islam
Istanbul Mosaic Museum
Hagia Irene Museum
Chora Museum
Rumeli Hisar Museum
Yildiz Palace Museum
Galata Mevlevi House Museum
Istanbul Fethiye Museum (Pammakaristos)
You can save quite a bit of money with the Museum Pass compared to buying separate tickets for each museum. Recently the individual ticket prices have increased, so the Museum Pass is more beneficial than ever. The card is also crucial to anyone trying to save time. In the busy season for museums, the queues can be up to two hours long. Museum Pass Istanbul allows you to enter each of the twelve museums in only 30 seconds.
Museum Pass Istanbul gives additional discounts from 10% to 30% at elite private museums, more than twenty arts and entertainment venues, museum shops and GES Shops. You can purchase Museum Pass Istanbul from the ticket gates at Topkapi Palace Museum, Hagia Sophia Museum, Chora Museum, Istanbul Archaeological Museums, http://www.muze.gov.tr and Mobile Sales Stations. The two types of Museum Pass are also available at the concierge desk of the many hotels around the city, listed here. However, the sale of the Museum Pass at hotels is under discretion of the hotel concierge and reception.





Java: no more boilerplate, use Lombok

https://projectlombok.org/ the video tells it all. The problem with boilerplate code is not much that you have to write it (it's mostly autogenerated by Eclipse anyway) and maintain it, but is that it's VISUALLY disturbing and indistinguishable from business code. So the less boilerplate code, the more readable your code.

Saturday, March 4, 2017

Spring Boot starter web app

(courtesy of the excellent javabrains.io )
Install Spring Tool Suite https://spring.io/tools/sts/all

Run STS.exe
Adjust your Maven setting.xml (Window, Preferences, Maven, User Settings)

new / Maven Project

edit the 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>io.javabrains.springbootquickstart</groupId>
  <artifactId>course-api</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>Java Brains Course API</name>
  <parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.5.0.RELEASE</version>
  </parent>
  
  <dependencies>
  <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  </dependency>
  
  </dependencies>
  
  <properties>
   <java.version>1.8</java.version>
  </properties>
</project>



Create this main App class

package io.javabrains.springbootstarter;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CourseApiApp {

 public static void main(String[] args) {
  SpringApplication.run(CourseApiApp.class, args);

 }

}


and these 2 controller classes

package io.javabrains.springbootstarter.hello;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {
 @RequestMapping("/hello")
 public String sayHi() {
  return "Hi";
 }
 
 

}



package io.javabrains.springbootstarter.topic;

import java.util.Arrays;
import java.util.List;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TopicController {
 @RequestMapping("/topics")
 public List getAllTopics() {
  return Arrays.asList(
    new Topic("a", "aa", "aaa"),
    new Topic("b", "bb", "bbb")
    );
 } 

}




where Topic is



package io.javabrains.springbootstarter.topic;

public class Topic {
 private String id;
 private String name;
 private String description;
 public String getId() {
  return id;
 }
 public void setId(String id) {
  this.id = id;
 }
 public String getName() {
  return name;
 }
 public void setName(String name) {
  this.name = name;
 }
 public String getDescription() {
  return description;
 }
 public void setDescription(String description) {
  this.description = description;
 }
 public Topic(String id, String name, String description) {
  super();
  this.id = id;
  this.name = name;
  this.description = description;
 }
 
 public Topic() {
  
 }
 

}




Run the main App (this will start the embedded tomcat), enter in the browser this

http://localhost:8080/topics

and you get a great JSON response....

[{"id":"a","name":"aa","description":"aaa"},{"id":"b","name":"bb","description":"bbb"}]



Thursday, March 2, 2017

bad class file, bad signature

We had an interesting case of an invalid class failing with version 12.1.3 of WebLogic (it was working with previous release)
 
 
####<Feb 27, 2017 7:46:40 AM CET> <Error> <Deployer> <myserver.pippo.com> <pippodomain> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1488178000430> <BEA-149205> <Failed to initialize the application "PIPPO" due to error weblogic.application.ModuleException: String index out of range: -1
String index out of range: -1
weblogic.application.ModuleException: String index out of range: -1
String index out of range: -1
        at weblogic.servlet.internal.WebAppModule.createModuleException(WebAppModule.java:1824)
        at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:270)
        at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:682)
        at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
        at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
        at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
        at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:288)
        at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:301)
        at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:329)
        at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
        at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
        at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
        at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:155)
        at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
        at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:191)
        at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
        at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
        at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
        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.GeneratedMethodAccessor8.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)
        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)
        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 org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpOneLevel.run(CurrentTaskFuture.java:753)
        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)
Caused By: java.lang.StringIndexOutOfBoundsException: String index out of range: -1
        at java.lang.String.substring(String.java:1911)
        at weblogic.application.utils.annotation.ClassInfoImpl$MethodVisitorImpl.visitAnnotation(ClassInfoImpl.java:472)
        at com.bea.objectweb.asm.ClassReader.b(Unknown Source)
        at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
        at com.bea.objectweb.asm.ClassReader.accept(Unknown Source)
        at weblogic.application.utils.annotation.ClassInfoImpl.<init>(ClassInfoImpl.java:86)
        at weblogic.application.utils.annotation.ClassInfoImpl.<init>(ClassInfoImpl.java:79)
        at weblogic.application.utils.annotation.ClassfinderClassInfos.getClassInfoFromSource(ClassfinderClassInfos.java:325)
        at weblogic.application.utils.annotation.ClassfinderClassInfos.populateClassInfos(ClassfinderClassInfos.java:278)
        at weblogic.application.utils.annotation.ClassfinderClassInfos.<init>(ClassfinderClassInfos.java:72)
        at weblogic.servlet.internal.War.initializeClassInfosIfNecessary(War.java:446)
        at weblogic.servlet.internal.War.getAnnotatedClasses(War.java:376)
        at weblogic.servlet.utils.WarUtils.isJsfApplication(WarUtils.java:260)
        at weblogic.servlet.internal.WebAppModule.detectJsfApplication(WebAppModule.java:277)
        at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:262)
        at weblogic.servlet.internal.WebAppModule.init(WebAppModule.java:682)
        at weblogic.application.internal.flow.ScopedModuleDriver.init(ScopedModuleDriver.java:162)
        at weblogic.application.internal.ExtensibleModuleWrapper.init(ExtensibleModuleWrapper.java:98)
        at weblogic.application.internal.flow.ModuleListenerInvoker.init(ModuleListenerInvoker.java:84)
        at weblogic.application.internal.flow.InitModulesFlow.initModule(InitModulesFlow.java:288)
        at weblogic.application.internal.flow.InitModulesFlow.initModules(InitModulesFlow.java:301)
        at weblogic.application.internal.flow.InitModulesFlow.prepare(InitModulesFlow.java:329)
        at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:706)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
        at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:237)
        at weblogic.application.internal.EarDeployment.prepare(EarDeployment.java:61)
        at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:158)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:61)
        at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:155)
        at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
        at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:191)
        at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
        at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:240)
        at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
        at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
        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.GeneratedMethodAccessor8.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)
        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)
        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 org.glassfish.hk2.runlevel.internal.CurrentTaskFuture$UpOneLevel.run(CurrentTaskFuture.java:753)
        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)
>
 


See also this previous post http://www.javamonamour.org/2016/01/weblogic-deployment-fails.html

Problem is that WebLogic doesn't tell us which class is failing, so I had to patch this class

package weblogic.utils.classloaders;
 
import java.io.IOException;
import java.security.cert.Certificate;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.jar.Manifest;
 
public class JarSource
  extends ZipSource
{
  private final JarFile jarFile;
  private final JarEntry jarEntry;
 
  public JarSource(JarFile jf, JarEntry je)
  {
    super(jf, je);
    this.jarFile = jf;
    this.jarEntry = je;
    System.out.println("JarSource, jf=" + jf.getName() + " je=" + je);
  }
 
  public Manifest getManifest()
    throws IOException
  {
    return this.jarFile.getManifest();
  }
 
  public Certificate[] getCertificates()
  {
    return this.jarEntry.getCertificates();
  }
}


adding a System.out.println(it's horrible but it works)


To check if the class is REALLY invalid I use this tester (bad class is com.pippo.web.util.Properties ):
import com.pippo.web.util.Properties;
import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
 
public class TestAnnotations {
       public static void main(String[] args) throws Exception {
             Class propertiesClass = com.pippo.web.util.Properties.class;
             Annotation annos[] = propertiesClass.getAnnotations();
             for (Annotation a : annos)
                    System.out.println(a);
            
             for (Method m : propertiesClass.getMethods()) {
                    System.out.println("parsing method " + m.getName());
                    annos = m.getAnnotations();
 
                    System.out.println("All annotations for method " + m.getName());
                    for (Annotation a : annos) System.out.println(a);
                   
             }
       }
 
}


With Java 8 I get this:

parsing method setProperty All annotations for method setProperty parsing method getProperty All annotations for method getProperty parsing method getProperty All annotations for method getProperty parsing method load All annotations for method load parsing method load All annotations for method load parsing method save Exception in thread "main" java.lang.reflect.GenericSignatureFormatError: Signature Parse error: Expected Field Type Signature Remaining input: = at sun.reflect.generics.parser.SignatureParser.error(SignatureParser.java:124) at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:297) at sun.reflect.generics.parser.SignatureParser.parseFieldTypeSignature(SignatureParser.java:283) at sun.reflect.generics.parser.SignatureParser.parseTypeSignature(SignatureParser.java:485) at sun.reflect.generics.parser.SignatureParser.parseTypeSig(SignatureParser.java:188) at sun.reflect.annotation.AnnotationParser.parseSig(AnnotationParser.java:436) at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:241) at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120) at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72) at java.lang.reflect.Executable.declaredAnnotations(Executable.java:599) at java.lang.reflect.Executable.declaredAnnotations(Executable.java:597) at java.lang.reflect.Executable.getDeclaredAnnotations(Executable.java:588) at java.lang.reflect.Method.getDeclaredAnnotations(Method.java:630) at java.lang.reflect.AccessibleObject.getAnnotations(AccessibleObject.java:207) at TestAnnotations.main(TestAnnotations.java:16)

With Java 7 and 6 I get this when compiling:

TestAnnotations.java:1: cannot access com.pippo.web.util.Properties bad class file: com/pippo/web/util/Properties.class(com/pippo/web/util:Properties.class) bad signature: = ¿I ^ Please remove or make sure it appears in the correct subdirectory of the classpath. import com.pippo.web.util.Properties; ^

As a workaround, to avoid all this class scanning, you can try using -Dweblogic.servlet.DIDisabled=true or setting the metadata-complete attribute to true in the web.xml :

https://docs.oracle.com/cd/E24329_01/web.1211/e21049/annotateservlet.htm#WBAPP225



Wednesday, March 1, 2017

java.net.ProtocolException: EOF after reading only BLA of MUMBLE promised bytes

java.net.ProtocolException: EOF after reading only: '1343374' of: '17674381' promised bytes, 
               out of which at least: '0' were already buffered
        at weblogic.servlet.internal.PostInputStream.complain(PostInputStream.java:97)
        at weblogic.servlet.internal.PostInputStream.read(PostInputStream.java:198)
        at weblogic.servlet.internal.ServletInputStreamImpl.read(ServletInputStreamImpl.java:228)
        at java.io.FilterInputStream.read(FilterInputStream.java:116)
        at org.apache.commons.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:134)
        at org.apache.commons.fileupload.MultipartStream$ItemInputStream.makeAvailable(MultipartStream.java:999)
        at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:903)
        at java.io.FilterInputStream.read(FilterInputStream.java:116)
        at org.apache.commons.fileupload.util.LimitedInputStream.read(LimitedInputStream.java:134)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at org.apache.commons.fileupload.util.Streams.copy(Streams.java:100)
        at org.apache.commons.fileupload.util.Streams.copy(Streams.java:70)
        at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:347)



Several things can be attempted:
1) increase max post size and post timeout
2) restart server
3) change browser

https://blogs.oracle.com/vijaya/entry/java_net_protocolexception_eof_after

https://docs.oracle.com/cd/E13222_01/wls/docs81/ConsoleHelp/domain_server_protocols_http.html



Sunday, February 26, 2017

greg turnquist "learning spring boot"

http://greglturnquist.com/learning-spring-boot



on Safari Books online I have watched the entire course by Greg Turnquist, the material is really well done, hands on and practical.... Spring Boot is the best product I have seen since a long time, it has a learning curve but it allows you to write formidably compact applications.





Saturday, February 25, 2017

Lambda basics Java 8 tutorial by Koushik

https://www.youtube.com/playlist?list=PLqq-6Pq4lTTa9YGfyhyW2CqdtW9RtY-I3

I love the hands-on, fresh and immediate way by which Koushik explains these concepts... I wish I had half of his talents...

https://javabrains.io/





Saturday, February 18, 2017

Chrome NET::ERR_CERT_REVOKED for a revoked certificate

connecting Chrome to a local development WebLogic that was using a WebServer certificate that was revoked in the CRL list, I got this message:

Your connection is not private Attackers might be trying to steal your information from localhost (for example, passwords, messages, or credit cards). NET::ERR_CERT_REVOKED Automatically report details of possible security incidents to Google. Privacy policy ReloadHide advanced localhost normally uses encryption to protect your information. When Google Chrome tried to connect to localhost this time, the website sent back unusual and incorrect credentials. This may happen when an attacker is trying to pretend to be localhost, or a Wi-Fi sign-in screen has interrupted the connection. Your information is still secure because Google Chrome stopped the connection before any data was exchanged. You cannot visit localhost right now because this certificate has been revoked. Network errors and attacks are usually temporary, so this page will probably work later.

Once I started Chrome with "chrome.exe --ignore-certificate-errors" the connection is accepted, I just get a warning "you are using an unsupported command-line flag: --ignore-certificate-errors. Stability and security will suffer "



JDB is your friend

We had recently an issue with an XML parser failing to parse a temporary file that was immediately deleted after.
How to stop execution before the file gets deleted?
I am using jdb http://docs.oracle.com/javase/7/docs/technotes/tools/windows/jdb.html and I have created a simple test case

Start WebLogic with
set JAVA_OPTIONS=-agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n %JAVA_OPTIONS%

I deploy a small webapp with:

class com.pierre.MyCounter

package com.pierre;
public class MyCounter {
       static int count = 0;
       public static String getCountAsString() {
             return String.valueOf(count++);
       }
}

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="com.pierre.*"  %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here bla</title>
</head>
<body>
The count is:
<%
       out.write(MyCounter.getCountAsString());
%>
 
<br/>
I hope you are happy.
 
</body>
</html>
 


web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<display-name>testjdb</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
</web-app>


Then run from a command line :
jdb -attach jdbconn


run your case once to make sure the MyCounter class has already been loaded, then run

classes

to check if the MyCounter is there, then run this to set a breakpoint:

stop at com.pierre.MyCounter:6

next time you run the jsp, the breakpoint is hit and execution stops


Sunday, February 12, 2017

Spring JDBC tutorial by JavaBrains


















Spring AOP videos by JavaBrains















Saturday, February 11, 2017

Great Spring basic introduction part 2

part 10

part 11


part 12

part 13

part 14

part 15

part 16

part 17

part 18

part 19

part 20

part 21

part 22

part 23

part 24


make logger.debug() obsolete

IMHO logging is the weakest point in application development, the Cinderella of IT.
Most people don't log enough information to enable effective troubleshooting, the context is lost, changing logging level in PROD is hell, if you enable debug level you end up being flooded with unwanted info, most of the time operators don't even have instructions on how to do it.
Besides one is interested in knowing what happened immediately before an error occurred, so one should always have like a Flight Recorder with some history preceding the error and ready to be dumped when this happens.
Also, frameworks like ByteBuddy or Btrace or AOP products allows you to dynamically define loggers... logging is a cross-cutting concern, it should not be interspersed in the business code cluttering it. Just define what to log in a separate module - configuration and convention over code.
Here at OverOps they seem to bring some value:

https://www.overops.com/java-monitoring

watch the short video:




Friday, February 10, 2017

Great Spring basic introduction (part 1)

part 1

part 2

part 3

part 4

code for part 4 is here https://github.com/vernetto/JavaMonAmour/tree/master/SpringDemo
part 5

part 6

part 7

part 8
part 9