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.
Showing posts with label jsp. Show all posts
Showing posts with label jsp. Show all posts
Tuesday, December 6, 2016
Saturday, November 23, 2013
JSP error page
<%@page isErrorPage="true" %>
<html>
<body>
<h1>Error page</h1>
<pre>
<% if (exception != null) {
out.write("exception message=" + exception.toString());
}
else {
out.write("no exception available");
}
%>
</pre>
</body>
</html>
Labels:
jsp
Friday, May 31, 2013
Nice little JSP to generate threads on demand
<%
final String threads = request.getParameter("threads");
final String period = request.getParameter("period");
try {
for (int t = 0; t < Integer.parseInt(threads); t++ ) {
System.out.println("starting thread " + t + " of " + threads);
Thread thread = new Thread(new Runnable() {
public void run() {
try {
System.out.println("started with period " + period);
Thread.sleep(Integer.parseInt(period) * 1000);
}
catch (Throwable t) {
t.printStackTrace();
}
}
});
thread.start();
};
}
catch (Throwable t) {
t.printStackTrace();
}
%>
and you invoke it as
http://acme.com:10001/wlstuck/index.jsp?threads=30&period=40
and you redeploy with
import os
theapplication=str(sys.argv[1])
print "redeploying", theapplication
os.system("rm -rf /opt/oracle/domains/osbts1do/servers/osbts1as/tmp/_WL_user/" + theapplication + "/")
connect('Pierluigi', 'weblogic1', 't3://acme.com:9001')
redeploy(theapplication)
exit()
problem is that these threads will not be part of the WebLogic thread pool, and as such they will not be monitored.
A better option is a shell script:
for i in {1..30}
do
wget http://acme.com:10001//wlstuck &
done
and the index.jst is simply:
Thread.sleep(390 * 1000);
Labels:
jsp,
stuckthread
Thursday, March 28, 2013
JSP compiler, difference between Tomcat and WebLogic
In Tomcat I had some rather nasty EL code to get a BLOB value from a table:
In Tomcat this was working, in WebLogic it was giving:
Syntax error in expression. Encountered "(". Expected one of : "}", ".", "[", ">", "gt", "<", "lt", ">=", "ge", "<=", "le", "==", "eq", "!=", "ne", "&&", "and", "||", "or", "*", "+", "-", "?", "/", "div", "%", "mod",
It turns out that in WebLogic you must change the syntax to:
<c:set var="DATA_VALUE" value="${msgguidDataResult.rowsByIndex[0][0]}" scope="request"/>
It's just one of those things...
<c:set var="sqlStatement2" value="select DATA_VALUE
from ${datatable} where MSG_GUID = '${theMSGGUIDvalue}' "/>
<sql:query var="msgguidDataResult" dataSource="${domainds}">
${sqlStatement2}
</sql:query>
<c:set var="DATA_VALUE" value="${msgguidDataResult.rowsByIndex[0][0]}"
scope="request"/>
In Tomcat this was working, in WebLogic it was giving:
Syntax error in expression. Encountered "(". Expected one of : "}", ".", "[", ">", "gt", "<", "lt", ">=", "ge", "<=", "le", "==", "eq", "!=", "ne", "&&", "and", "||", "or", "*", "+", "-", "?", "/", "div", "%", "mod",
It turns out that in WebLogic you must change the syntax to:
<c:set var="DATA_VALUE" value="${msgguidDataResult.rowsByIndex[0][0]}" scope="request"/>
It's just one of those things...
Saturday, February 23, 2013
JSP download file
<%
response.setContentType("application/xml");
response.setHeader("Content-Disposition", "attachment;filename=myxmlfile.xml");
File file = new File("myxmlfile.xml");
FileInputStream fileIn = new FileInputStream(file);
ServletOutputStream outstream = response.getOutputStream();
byte[] outputByte = new byte[4096];
//copy binary contect to output stream
int byteRead;
while( ( byteRead = fileIn.read(outputByte, 0, 4096)) != -1)
{
outstream.write(outputByte, 0, byteRead);
}
fileIn.close();
outstream.flush();
outstream.close();
%>
For binary files, use:
response.setContentType("application/x-download");
rather than
response.setContentType("application/xml");
Labels:
jsp
Friday, October 5, 2012
Multiple actions/buttons form in HTML
create a form like this:
form name="myform" onsubmit="return onsubmitform();" method="post"
The onsubmitform is something like:
each "active" control should be like :
<input type="submit" name="operation" onclick = "document.pressed=this.value" value="Purge Messages Selected" title="purgeallmsg" />
the above is a button, but the onclick can apply to anything (radio button...).... actually any event can trigger the submission.
form name="myform" onsubmit="return onsubmitform();" method="post"
The onsubmitform is something like:
<script type="text/javascript">
function onsubmitform() {
if (document.pressed == "Purge Messages Selected") {
document.myform.action = "purgemessages.jsp";
}
else {
alert("unknown action");
}
return true;
}
</script>
each "active" control should be like :
<input type="submit" name="operation" onclick = "document.pressed=this.value" value="Purge Messages Selected" title="purgeallmsg" />
the above is a button, but the onclick can apply to anything (radio button...).... actually any event can trigger the submission.
Monday, July 2, 2012
Small JSP to display the content of a file
pass the filename as ?file=/path/to/myfile.txt
<%@page import="java.io.*"%>
<%
<%@page import="java.io.*"%>
<%
String filename = request.getParameter("file");
FileReader fr = new FileReader(filename);
BufferedReader br = new BufferedReader(fr);
String line;
while ( (line = br.readLine() ) != null ) {
out.write(line);
out.write("\n");
}
br.close();
fr.close();
%>
Labels:
jsp
Subscribe to:
Posts (Atom)