Saturday, December 31, 2016

Oracle Cloud

Awesome presentation by Larry Ellison here:





Friday, December 30, 2016

Poor man's version of FindClasses

We already spoke here on how to find a class in an ocean of JAR files.

Here is a brutally simple utility to write all the JAR contents to a file:


import java.io.BufferedWriter;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class FindClasses {
 static boolean DEBUG = true;
 static String rootFolder = "C:\\Apps\\Pippo\\";
 static List<File> jarFiles = new ArrayList<File>();
 public static void main(String[] args) throws Throwable {
  Path outputFilePath = Paths.get("allfilesPippo.out");
  BufferedWriter writer = Files.newBufferedWriter(outputFilePath);
  File rootFolderDir = new File(rootFolder);
  scan(rootFolderDir);
  System.out.println("END SCAN");
  if (DEBUG) {
   for (File jar : jarFiles) {
    System.out.println(jar.getAbsolutePath());
   }
  }

  for (File jar : jarFiles) {
   writer.write("BEGIN JAR: " + jar.getAbsolutePath() + "\n");
   ZipFile zipFile = new ZipFile(jar);
   Enumeration<? extends ZipEntry> entries = zipFile.entries();
   while (entries.hasMoreElements()) {
    ZipEntry entry = entries.nextElement();
    writer.write(entry.getName() + "\n");
   }

   zipFile.close();
   writer.write("END JAR: " + jar.getAbsolutePath() + "\n\n");
  }
  writer.close();
 }
 private static void scan(File folderToScan) {
  if (DEBUG)
   System.out.println("scanning " + folderToScan.getAbsolutePath());
  for (File file : folderToScan.listFiles()) {
   if (file.isDirectory()) {
    scan(file);
   } else {
    if (file.getName().toLowerCase().endsWith(".jar")) {
     jarFiles.add(file);
    }
   }
  }
 }
} 

 



Thursday, December 29, 2016

Huge surge of audience from Russia

This week visits to this blog:

United States 2089 
Russia 1880 


1) either the Russians are investing into Java, 2) or we have a massive web crawling operation from Russia 3) or someone is massively spoofing Russian IPs, maybe to blame later Putin for something naughty about to happen.

I am more inclined to believe in number 3)

It's curious that the same happened with Ukraine 1-2 years ago, in the period when NATO staged the coup who later reduced Ukraine to utter misery, plundering of resources, killing of journalist and opponents and massive unemployment.

God only knows what's going on. God and CIA.

WebLogic "The managed server could not update the configuration files"

getting this error today, with Admin server up and running, and starting a Managed server member of a cluster.... the .bindings file is part of the MQ Foreign JMS server configuration:


<Dec 29, 2016 4:07:04 PM CET> <Error> <Management> <BEA-141196> <The managed server could not update the configuration files during the registration with the deployment service. The update failed due to an exception:
weblogic.management.DeploymentException: Exception occured while copying files
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.doUpdate(DataUpdate.java:307)
 at weblogic.deploy.internal.targetserver.datamanagement.ConfigDataUpdate.doUpdate(ConfigDataUpdate.java:102)
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.update(DataUpdate.java:72)
 at weblogic.deploy.internal.targetserver.datamanagement.Data.commitDataUpdate(Data.java:118)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.updateFiles(RuntimeAccessDeploymentReceiverService.java:880)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.handleRegistrationResponse(RuntimeAccessDeploymentReceiverService.java:728)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.registerHandler(RuntimeAccessDeploymentReceiverService.java:699)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.start(RuntimeAccessDeploymentReceiverService.java:169)
 at weblogic.t3.srvr.ServerServicesManager.startService(ServerServicesManager.java:462)
 at weblogic.t3.srvr.ServerServicesManager.startInStandbyState(ServerServicesManager.java:167)
 at weblogic.t3.srvr.T3Srvr.initializeStandby(T3Srvr.java:881)
 at weblogic.t3.srvr.T3Srvr.startup(T3Srvr.java:568)
 at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:469)
 at weblogic.Server.main(Server.java:71)
Caused By: java.io.FileNotFoundException: /path/to/mydomain/config/jms/.bindings (Permission denied)
 at java.io.FileOutputStream.open(Native Method)
 at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
 at java.io.FileOutputStream.<init>(FileOutputStream.java:145)
 at weblogic.utils.FileUtils.writeToFile(FileUtils.java:115)
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.copy(DataUpdate.java:265)
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.copyOrExtractTo(DataUpdate.java:202)
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.updateLocalData(DataUpdate.java:168)
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.doUpdate(DataUpdate.java:299)
 at weblogic.deploy.internal.targetserver.datamanagement.ConfigDataUpdate.doUpdate(ConfigDataUpdate.java:102)
 at weblogic.deploy.internal.targetserver.datamanagement.DataUpdate.update(DataUpdate.java:72)
 at weblogic.deploy.internal.targetserver.datamanagement.Data.commitDataUpdate(Data.java:118)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.updateFiles(RuntimeAccessDeploymentReceiverService.java:880)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.handleRegistrationResponse(RuntimeAccessDeploymentReceiverService.java:728)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.registerHandler(RuntimeAccessDeploymentReceiverService.java:699)
 at weblogic.management.provider.internal.RuntimeAccessDeploymentReceiverService.start(RuntimeAccessDeploymentReceiverService.java:169)
 at weblogic.t3.srvr.ServerServicesManager.startService(ServerServicesManager.java:462)
 at weblogic.t3.srvr.ServerServicesManager.startInStandbyState(ServerServicesManager.java:167)
 at weblogic.t3.srvr.T3Srvr.initializeStandby(T3Srvr.java:881)
 at weblogic.t3.srvr.T3Srvr.startup(T3Srvr.java:568)
 at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:469)
 at weblogic.Server.main(Server.java:71)
> 



The issue is that a MS tried to get the latest configuration files from the Admin at startup. See "Error Starting WebLogic Server: BEA-141196: The managed server could not update the configuration files during the registration with the deployment service (Doc ID 1461960.1)". in My Oracle Support.

You can either make that configuration file WRITEABLE, or shut down the Admin and make sure that the MS has already the latest configuration.

Thursday, December 22, 2016

Lebara: true story

I used to have a Lebara CH mobile phone, with a hefty balance of more than 100 CHF (they used to give a huge discount when you top-up 100 CHF at a time). Their service works, but they didn't offer a flat monthly rate for unlimited internet, so I got a Yallo number.
For 6 months I haven't made any call with Lebara, and Lebara, without any warning, have deactivated my SIM and took all my money.
They could have sent me an email, since I am registered on their account. They chose not to give me a warning. I actually wonder if all this is LEGAL in a country like Switzerland.
I have sent them an inquiry about my balance, all they say is:
Thanks for getting in contact with us.
Because of un using the SIM Card for longer than six month the SIM Card is deactivated and cannot be use anymore. We can not see also how much money was on it.
If you have further question please do not hesitate to call or write us.
Kind regards,


I am sure you can take your own decisions - without me trying to influence you - about the quality of Lebara service.

For instance, Skype send me regularly (every 6 month) a reminder saying "your account will be suspended if you don't make a call".... but a) they warn me b) even when suspended, the balance is still available and you can recover it. Lebara no, they just don't care to tell you and there is no way to revert their action. And I have also lost all SMS messages that meanwhile might have been sent to my number.





Wednesday, December 21, 2016

Monday, December 19, 2016

WebLogic 12 shared libraries

https://docs.oracle.com/cd/E24329_01/web.1211/e24368/libraries.htm#WLPRG325

Excellent presentation here:



it's always recommended to set Specification Version and Implementation Version in the MANIFEST.MF

same is true with Applications : Weblogic-Application-Version should be set in MANIFEST.MF (see https://docs.oracle.com/cd/E24329_01/web.1211/e24368/versioning.htm#WLPRG250 )



Sunday, December 18, 2016

WebLogic Server Request Performance View



On how to configure the deployment to add a "Context ID" using the wldf-resource/wldf-instrumentation-monitor tag: http://docs.oracle.com/cd/E24329_01/web.1211/e24426/config_context.htm#WLDFC253





Saturday, December 17, 2016

Java Mission Control jmc WebLogic plugin

funnily, the plugin installs, but whenever I run it, it says "event type BLA is not enabled in this recording" and I can't figure out how to enable the event recording...

https://docs.oracle.com/javacomponents/jmc-5-5/jmc-user-guide/experimental.htm#JMCCI131
https://blogs.oracle.com/WebLogicServer/entry/weblogic_tip
this video is about the JRockit version:

To install: run jmc.exe, Help, Install new Software


If you see this when activating Commercial Features via JMC:

[jfr][WARN ][3932.289] Unable to register PDH query for "\Process(java#0)\% Processor Tim"
[jfr][WARN ][3932.290] Please check the registry if this performance object/counter is disabled
[jfr][WARN ][3932.290] Unable to register PDH query for "\Process(java#0)\% Privileged Tim"
[jfr][WARN ][3932.290] Please check the registry if this performance object/counter is disabled
[jfr][WARN ][3932.290] Unable to register PDH query for "\Process(java#1)\% Processor Tim"
[jfr][WARN ][3932.290] Please check the registry if this performance object/counter is disabled
[jfr][WARN ][3932.290] Unable to register PDH query for "\Process(java#1)\% Privileged Tim"
[jfr][WARN ][3932.290] Please check the registry if this performance object/counter is disabled
[jfr][WARN ][3932.293] Unable to register PDH query for "\System\Context Switches/se"
[jfr][WARN ][3932.293] Please check the registry if this performance object/counter is disabled


it seems to be a known bug (Windows only)



XA transactions explained : TLOG, prepare, recover, determiner

https://blogs.oracle.com/WebLogicServer/entry/exiting_new_jta_12_1

about the "removal of TX logging feature"



and more in detail



great explanation by Monica Riccelli!

in WLS 12.2.1, check in Cluster/JTA the properties "Write recovery logs when determiners configured" and "determiner".

Use: -Dweblogic.debug.DebugJTAXA=true -Dweblogic.debug.DebugJTA2PC=true -Dweblogic.debug.DebugJTARecovery=true (see https://blogs.oracle.com/vijaya/entry/weblogic_server_debug_flags_jta )

Plus: Cluster Transaction Affinity explained here http://docs.oracle.com/middleware/1213/wls/WLJTA/trxcon.htm#WLJTA386



Thursday, December 15, 2016

Saturday, December 10, 2016

WebLogic Elastic cluster

very interesting demos on how to scale up/down (with console, with WLST or via policies) the number of managed servers in a cluster









Friday, December 9, 2016

EntityManager and statement timeout

We spoke here about Statement Timeout to set on a Datasource http://www.javamonamour.org/2013/04/statement-timeout-on-datasource.html

If you use an EntityManager, you don't have access to the javax.sql.Statement object. This is the beauty of abstraction (sarcasm here): it prevents you from using the full power of the underlying technology, and it forces you to awkward acrobatics.

I would give a try to javax.persistence.query.timeout

http://stackoverflow.com/questions/24244621/set-timeout-on-entitymanager-query

https://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html_single/


query.setHint("javax.persistence.query.timeout", 2000);



see https://docs.oracle.com/javaee/6/api/javax/persistence/Query.html

but it works (actually, they told me it doesn't work AT ALL with WebLogic 12 and Eclipse JPA) only if you use Queries with EntityManager....



Tuesday, December 6, 2016

WebLogic JSP generation and compilation

Doc ID 1306579.1 : "Since the 10.3.2 timeframe, we have been gradually moving away from using javac. In both the JSP engine and the EJB engines, we are now using a repackaged version of the JDT compiler to generate class files. This was done as a performance optimization. In 10.3.3 we have gone a step further and all but the EJB 2.1 entity beans are being generated dynamically using ASM. There are options for directly interpreting JSP (OJSPNext for example)."



To compile your JSPs: java weblogic.appc -verbose -compiler jdt YOUR.EAR (YOUR:EAR can also be a directory in exploded format)

https://docs.oracle.com/middleware/1212/wls/ADMRF/utils.htm#i1219183

In some cases, using WebLogic 12.1.3 you get

"weblogic.utils.compiler.ToolFailureException: jspc failed with errors :weblogic.servlet.jsp.CompilationException: bla.jsp:8:2: The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit"

while the same works in WLS 10.3.2

There is a patch available for WLS 12.2.1 WLS-The Code of Method _jspService(HttpServletRequest, HttpServletResponse) Is Exceeding The 65535 Bytes Limit (Doc ID 1919706.1)... see bug 17968606

Be aware that WLS 10.3.2 generated Java 5 .class files (see WebLogic Server Compiles JSP Using JDK 1.5 Even When JVM is Running with JDK 1.6 (Doc ID 1501536.1) ). it's by design! "compiled Java class data, version 49.0 (Java 1.5)"

You can make WLS use a different compiler for instance with -Dweblogic.jsp.javacompiler.javac=true , or using the option javacompiler in jsp-descriptor in weblogic.xml. Check also the flags -Dweblogic.jsp.javacompiler.javac.target=1.7 -Dweblogic.jsp.javacompiler.javac.source=1.7

You should also use the option jsp-descriptor precompile true in the weblogic.xml, and keepgenerated = true (and also precompile-continue )

References:

http://blog.kifaru.be/2011/08/how-to-precompile-jsps-with-the-weblogic-wlappc-ant-task/

Classes involved: com.bea.core.repackaged.jdt.internal.compiler.* (in com.bea.core.repackaged.jdt_3.4.1.0.jar in WLS 10.3.2, and in weblogic.server.merged.jar for WLS 12.1.3 ) and weblogic.utils.compiler.* (com.bea.core.utils.compiler_1.1.0.1.jar for WLS 10.3.2 , weblogic.server.merged.jar for WLS 12.1.3 ). Also weblogic.servlet.jsp.JspCLLManager, weblogic.jsp.internal.Javelin, weblogic.jsp.compiler.DiagnosticList

See also "Bug 23076699 : WLS 12.1.2- DEPLOY - THE CODE OF METHOD _JSPSERVICE, IS EXCEEDING THE 65535 BYTE" , patch 21984577 , patch 17968606 )

The value of the code_length item must be less than 65536 http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.9.1

Using javap -verbose you can print all info about a .class, such as Major Version and code_length

Use also java weblogic.appc -compiler javac -source 1.7 -target 1.7 JspCompilerProblem.war to determine which Version of bytecode to generate.

CDI context dependency injection

CDI is a powerful concept, but as usual implementation is pathetic (Spring, Java EE, whatever).
Annotations make code less readable, they leak concern, are extremely hard to debug (ever tried to find out why one of your references if not getting injected?). Read this excellent article https://www.javacodegeeks.com/2016/11/java-annotations-big-mistake.html
XML is easily broken, has to be mostly manually maintained, quickly becomes unmanageable and unstructured.
I still prefer a pure coded approach, where dependencies and injected by an "injector" bean, but in a Java EE container this would not retain the specific features of the bean. So it's not a choice available for now (maybe yes, I should investigate)

This is a quite decent introduction on CDI in a Java EE (CDI) container:









Saturday, December 3, 2016

WebLogic Java EE tutorials

(or J2EE as someone still says)
putting together a lost of documentation and training material to become a WebLogic and Java Enterprise Edition GURU:

https://docs.oracle.com/javaee/7/JEETT.pdf

https://docs.oracle.com/middleware/12212/wls/WLPRG/WLPRG.pdf "Developing Applications for Oracle WebLogic Server"

https://docs.oracle.com/middleware/1221/wls/EJBAD.pdf Developing Enterprise JavaBeans for Oracle WebLogic Server

Install latest JDK from here http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html

You can download "Oracle Enterprise Pack for Eclipse" from here http://www.oracle.com/technetwork/developer-tools/eclipse/downloads/index.html and the WLS 12 installer here http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-main-097127.html

Security https://docs.oracle.com/middleware/1221/wls/SCOVR.pdf

Web Services https://docs.oracle.com/middleware/1221/wls/WSOVR.pdf and https://docs.oracle.com/middleware/12212/wls/WSGET/WSGET.pdf

WebService security https://docs.oracle.com/middleware/1221/wls/WSSOV.pdf

Restful WebServices https://docs.oracle.com/middleware/1221/wls/RESTF.pdf

Securing WebServices with Policies https://docs.oracle.com/middleware/1221/owsm/OWSMS.pdf

Developing Web Applications https://docs.oracle.com/middleware/12212/wls/WBAPP/WBAPP.pdf

Of course, don't expect to find anything readable in the Oracle documents, they are made 90% of "if you want to know something about this, follow this link" , or just a dry list of standards, all in a completely unemotional language that puts you immediately to sleep. But their JEE7 Tutorial is quite decent, however it's only meant for Glasshfish development.

Here also plenty of short tutorials https://apexapps.oracle.com/pls/apex/f?p=44785:OLL_SEARCH:116956567220019:::2:P2_SEARCH_TEXT:Weblogic

And of course all the OracleWeblogic youtube videos https://www.youtube.com/user/OracleWebLogic/videos