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