I'm using spring ws on the server side with a AxiomSoapmessageFactory:
<bean id="messageFactory" class="org.springframework.ws.soap.axiom.AxiomSoapMessageFactory">
<property name="payloadCaching" value="true"/>
<!-- Need to figure out the appropriate directory -->
<property name="attachmentCacheDir" value="..."/>
</bean>
This works fine when the services are ingesting a message. However, when the services attempt to serve up a large message I get Java out of memory exception. Here is the stack trace:
java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:2786)
at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:94)
at org.apache.axiom.mime.impl.axiom.MultipartWriterImpl$PartOutputStream.write(MultipartWriterImpl.java:42)
at javax.activation.DataHandler.writeTo(DataHandler.java:294)
at org.apache.axiom.mime.impl.axiom.MultipartWriterImpl.writePart(MultipartWriterImpl.java:116)
at org.apache.axiom.om.impl.OMMultipartWriter.writePart(OMMultipartWriter.java:136)
at org.apache.axiom.om.impl.MIMEOutputUtils.writeSOAPWithAttachmentsMessage(MIMEOutputUtils.java:269)
at org.springframework.ws.soap.axiom.AxiomSoapMessage.writeSwAMessage(AxiomSoapMessage.java:298)
at org.springframework.ws.soap.axiom.AxiomSoapMessage.writeTo(AxiomSoapMessage.java:248)
at org.springframework.ws.server.MessageDispatcher.getMessageContent(MessageDispatcher.java:192)
at org.springframework.ws.server.MessageDispatcher.receive(MessageDispatcher.java:174)
at org.springframework.ws.transport.support.WebServiceMessageReceiverObjectSupport.handleConnection(WebServiceMessageReceiverObjectSupport.java:88)
at org.springframework.ws.transport.http.WebServiceMessageReceiverHandlerAdapter.handle(WebServiceMessageReceiverHandlerAdapter.java:57)
at org.springframework.ws.transport.http.ErrorAwareWebServiceMessageReceiverHandlerAdapter.handle(ErrorAwareWebServiceMessageReceiverHandlerAdapter.java:42)
at org.springframework.ws.transport.http.MessageDispatcherServlet2.doService(MessageDispatcherServlet2.java:148)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:571)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:511)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:680)
The problem seems to be that the services are attempting to read the whole attachment into memory prior to writing it out. Is there a way to stream the attachment?
I'm running this in a Tomcat instance on OSX 10.6.7 java --version =
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07-334-10M3326)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02-334, mixed mode)
Have you tried changing the following parameters to allow for more memory?
-Xms512m
-Xmx1024m
-XX:PermSize=256m
I believe you need to set the attachmentCaching property to true. The default is false.
Truns out this was caused by turning message tracing on. When message tracing is on the MessageSender (at least in spring-ws 1.5.9) tries to copy the entire message into a ByteArrayOutputString and then converts the whole thing into a string. The offending functions are MessageSender.recieve and MessageSender.getContent
public void receive(MessageContext messageContext) throws Exception {
// Let's keep a reference to the request content as it came in, it might be changed by interceptors in dispatch()
String requestContent = "";
if (receivedMessageTracingLogger.isTraceEnabled()) {
requestContent = getMessageContent(messageContext.getRequest());
receivedMessageTracingLogger.trace("Received request [" + requestContent + "]");
}
else if (receivedMessageTracingLogger.isDebugEnabled()) {
receivedMessageTracingLogger.debug("Received request [" + messageContext.getRequest() + "]");
}
dispatch(messageContext);
if (messageContext.hasResponse()) {
WebServiceMessage response = messageContext.getResponse();
if (sentMessageTracingLogger.isTraceEnabled()) {
String responseContent = getMessageContent(response);
sentMessageTracingLogger.trace("Sent response [" + responseContent + "] for request [" +
requestContent + "]");
}
else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger.debug("Sent response [" + response + "] for request [" +
messageContext.getRequest() + "]");
}
}
else if (sentMessageTracingLogger.isDebugEnabled()) {
sentMessageTracingLogger
.debug("MessageDispatcher with name '" + beanName + "' sends no response for request [" +
messageContext.getRequest() + "]");
}
private String getMessageContent(WebServiceMessage message) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
message.writeTo(bos);
return bos.toString("UTF-8");
}
Related
I have the following piece of code from where i can get the Admin server name and the port.
InitialContext ctx = new InitialContext();
String serverName = System.getProperty("weblogic.Name");
MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");
ObjectName objName = new ObjectName("com.bea:Name=" + serverName + ",Type=Server");
Integer port = (Integer)server.getAttribute(objName, "ListenPort");
System.out.println("Server Name :" + serverName + " PORT :" + port);
But I also need the weblogic hostname along with the server name. Not sure how to get that.
It sounds like in addition, you want the "listen address":
Via Java/JMX:
String listenAddress=(String)server.getAttribute(objName,"ListenAddress");
Via WLST script:
cd('Servers/' + serverName)
listenAddress=str(get('ListenAddress'))
print "Listen Address is: " , listenAddress
first time i'm using aws api in java to get the cloud watch statistics for my ec2-instance. i googled about this and i found some code snippet. here it is
AmazonCloudWatchClient cloudWatch = new AmazonCloudWatchClient(
new BasicAWSCredentials(AccessKey, SecretKey));
cloudWatch.setEndpoint("ec2-<my-static-ip>.compute-1.amazonaws.com");
long offsetInMilliseconds = 1000 * 60 * 60 * 24;
Dimension instanceDimension = new Dimension();
instanceDimension.setName("Instanceid");
instanceDimension.setValue(InstanceId);
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
.withStartTime(
new Date(new Date().getTime()
- offsetInMilliseconds))
.withNamespace("AWS/EC2")
.withPeriod(60 * 60)
.withDimensions(
new Dimension().withName("InstanceId").withValue(
InstanceId))
.withMetricName("CPUUtilization")
.withStatistics("Average", "Maximum")
.withEndTime(new Date());
GetMetricStatisticsResult getMetricStatisticsResult = cloudWatch
.getMetricStatistics(request);
double avgCPUUtilization = 0;
List dataPoint = getMetricStatisticsResult.getDatapoints();
for (Object aDataPoint : dataPoint) {
Datapoint dp = (Datapoint) aDataPoint;
avgCPUUtilization = dp.getAverage();
System.out.println(InstanceId
+ " instance's average CPU utilization : "
+ dp.getAverage());
}
} catch (AmazonServiceException ase) {
System.out
.println("Caught an AmazonServiceException, which means the request was made "
+ "to Amazon EC2, but was rejected with an error response for some reason.");
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
}
so, using this code i tried to get statistics, but first time it throws error saying
com.amazonaws.AmazonClientException: Unable to execute HTTP request:Connection to https://ec2-<my-static-ip>.compute-1.amazonaws.com refused
then i thought it was sending https requests. so i enabled ssl on my instance and tried, then i'm getting below exception.
com.amazonaws.AmazonClientException: Unable to execute HTTP request: peer not authenticated
i was using OpenJDK in my instance, so i thought that may causing the problem. then i removed openjdk and installed Oracle JDK 1.7. but still same problem.
My questions are,
1) how can i send only HTTP (instead of HTTPS) requests to get statistics?
2)how to get rid of this problem, so that i can get my results?
But please don't ask me to read any docs, because i messed up by searching in net, blogs,forums, docs... etc. then i end up here. so, please just provide me solution or tell me where i'm going wrong.
Can anybody please help me out this issue.
thank you in Advance.
Got Solution.
1) removed setting end point for AmazonCloudWatchClient.
2) problem with the AWS credentials (Access key ID, Secret key).So, i created another set of credentials and gave CloudWatchFullAccess policy for the user.
Now it is working like Charm... :-)
Thanks.
I import more than one hundred data use eclipse in the computer and no problem. But when I deploy on application server it will out of memory, and I copy the local tomcat.
what is this problem?
The date more than millions than this in another function, and just less than few field. it can export normal.
int totalSize = behaviorPortraitService.querySiletUserPortraitCountMonth(sietUserPortraitForm.getParams());
int pageNum = 0;
if (totalSize % 1000000 == 0) {
pageNum = totalSize / 1000000;
}else{
pageNum = totalSize / 1000000 + 1;
}
write.append(" year/month IMSI phone number The date of open card"
+ enter);
outSTr = response.getOutputStream(); // establish
buff = new BufferedOutputStream(outSTr);
// Loop total number of pages,Get the number of pages per page
for (int i = 1; i <= pageNum; i++) {
// According to the number of pages to get PageResult object
list = behaviorPortraitService.exportSiletUserPortraitMonth(sietUserPortraitForm.getParams(),i,100000);
// circulate List collection to write
for (int j = 0; j < list.size(); j++) {
// Recycling collection,Write data to the TXT
write.append(list.get(j).getBegin_endtime());
write.append(" " + list.get(j).getImsi());
write.append(" " + list.get(j).getMsisdn());
write.append(" "+ list.get(j).getSilencedays());
write.append(" " + list.get(j).getStarttime()
+ enter);
}
// After writing a page object,empty List,wipe cache
list.clear();
System.gc();
}
buff.write(write.toString().getBytes("UTF-8"));
Error:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.OutOfMemoryError: Java heap space
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.trajectory.manager.controller.filter.SessionPrivaligeFilter.doFilter(SessionPrivaligeFilter.java:79)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.lang.OutOfMemoryError: Java heap space
java.lang.StringCoding$StringEncoder.encode(StringCoding.java:232)
java.lang.StringCoding.encode(StringCoding.java:272)
java.lang.String.getBytes(String.java:946)
com.trajectory.behaviorportrait.controller.ExportSiletUserPortraitController.writeWeekTxtWeek(ExportSiletUserPortraitController.java:209)
com.trajectory.behaviorportrait.controller.ExportSiletUserPortraitController.handleRequestInternal(ExportSiletUserPortraitController.java:69)
org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
com.trajectory.manager.controller.filter.SessionPrivaligeFilter.doFilter(SessionPrivaligeFilter.java:79)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
You are creating a very large String which you are converting to a very large byte[].
Instead of doing either of these I suggest writing the data progressively to the output stream. i.e. don't use write.append just use buf.write for binary or if you want to write text, use
PrintWriter pw = new PrintWriter(new OutputStreamWriter(
new BufferedOutputStream(socket.getOuptutStream()), "UTF-8"));
pw.print( some text here );
pw.print( some more ext here );
pw.println( the end of the line );
pw.close(); // when finished.
This doesn't use much memory at all.
We use jstack on servers to detect if java apps are getting deadlocked. It's not working on one of our Linux servers. I think O/S version is:
$cat /etc/issue.net
Red Hat Enterprise Linux Server release 5.6 (Tikanga)
Kernel \r on an \m
Java version running on server:
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)
When I try:
jstack 19114
I get:
19114: Unable to open socket file: target process not responding or HotSpot VM not loaded
The -F option can be used when the target process is not responding
When I try:
jstack -F 19114
I get:
Attaching to process ID 19114, please wait...
Debugger attached successfully.
Deadlock Detection:
No deadlocks found.
Thread 19180: (state = BLOCKED)
Error occurred during stack walking:
sun.jvm.hotspot.debugger.DebuggerException: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.execute(LinuxDebuggerLocal.java:152)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet(LinuxDebuggerLocal.java:466)
at sun.jvm.hotspot.debugger.linux.LinuxThread.getContext(LinuxThread.java:65)
at sun.jvm.hotspot.runtime.linux_amd64.LinuxAMD64JavaThreadPDAccess.getCurrentFrameGuess(LinuxAMD64JavaThreadPDAccess.java:92)
at sun.jvm.hotspot.runtime.JavaThread.getCurrentFrameGuess(JavaThread.java:256)
at sun.jvm.hotspot.runtime.JavaThread.getLastJavaVFrameDbg(JavaThread.java:218)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:76)
at sun.jvm.hotspot.tools.StackTrace.run(StackTrace.java:45)
at sun.jvm.hotspot.tools.JStack.run(JStack.java:60)
at sun.jvm.hotspot.tools.Tool.start(Tool.java:221)
at sun.jvm.hotspot.tools.JStack.main(JStack.java:86)
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 sun.tools.jstack.JStack.runJStackTool(JStack.java:118)
at sun.tools.jstack.JStack.main(JStack.java:84)
Caused by: sun.jvm.hotspot.debugger.DebuggerException: get_thread_regs failed for a lwp
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.getThreadIntegerRegisterSet0(Native Method)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal.access$800(LinuxDebuggerLocal.java:51)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$1GetThreadIntegerRegisterSetTask.doit(LinuxDebuggerLocal.java:460)
at sun.jvm.hotspot.debugger.linux.LinuxDebuggerLocal$LinuxDebuggerLocalWorkerThread.run(LinuxDebuggerLocal.java:127)
Anyone know what is causing this?
It is required to run jstack as the same user that started the java process. This resolves the above stacktrace error. See this posting: jstack thread dump error: get_thread_regs failed for a lwp for more detail. As soon as I sudoed the jstack command, the error disappeared.
The syntax is simply:
sudo -u USERID jstack PID
Example:
sudo -u tomcat7 jstack 2498
Try using kill -3 <pid> instead to get the stacktrace of your VM.
Can use a jsp that gives you similar output instead.
Following jsp prints the thread stack info to screen but you could change the output to a file as well or use in a regular POJO class.
<%# page import="java.util.*" %><%
Map<Thread,StackTraceElement[]> map = Thread.getAllStackTraces();
Set tt = map.keySet();
Iterator<Thread> ti = tt.iterator();
Thread thrd = null;
final String br = "<" + "br" + ">";//website does not parse it
try{
int cnt = 1;
StackTraceElement[] st = null;
while(ti.hasNext() ){
thrd = ti.next();
out.print(br + "<" + "hr" + ">" + br + cnt + " \"" + thrd.getName());
out.println("\", priority :" + thrd.getPriority() + ", state :" + thrd.getState());
out.print(", id :" + thrd.getId() + ", hex :" + Long.toHexString(thrd.getId()) );
out.print(" alive :" + thrd.isAlive() + ", daemon :" + thrd.isDaemon() );
out.print(" interrupted :" + thrd.isInterrupted() + ", daemon :" + thrd.isDaemon() );
out.print(".\n" + br);
st = thrd.getStackTrace();
for(int sti = 0; sti < st.length; sti++){
out.println(br + " " + st[sti].getClassName() + "." + st[sti].getMethodName());
out.println("(" + st[sti].getFileName());
if(st[sti].getLineNumber() < 1){
out.print("Native method");
}else{
out.print(":" + st[sti].getLineNumber());
}
out.println(")");
}
out.println("");
cnt++;
}
}catch(Exception e){
out.println(br + "err " + e + br);
}
%>
Sample output:
121 "Thread-40", priority :6, state :WAITING , id :134, hex :86 alive :true, daemon :false interrupted :false, daemon :false.
java.lang.Object.wait (Object.java Native method)
java.lang.Object.wait (Object.java :485)
org.jpos.iso.ISOMUX$Receiver.run (ISOMUX.java :326)
java.lang.Thread.run (Thread.java :662)
122 "Thread-48", priority :5, state :TIMED_WAITING , id :142, hex :8e alive :true, daemon :false interrupted :false, daemon :false.
java.lang.Thread.sleep (Thread.java Native method)
org.jpos.apps.qsp.QSP.monitorConfigFile (QSP.java :301)
org.jpos.apps.qsp.QSP.run (QSP.java :346)
java.lang.Thread.run (Thread.java :662)
I want to read the full stack trace of an exception that I capture.
For example:
org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.ibm.db2.jcc.DB2Driver'
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1136)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.azurian.lce.usuarios.ConnectionManager.getConnection(ConnectionManager.java:65)
at com.azurian.lce.usuarios.db2.UsuarioDAOImpl.autenticar(UsuarioDAOImpl.java:101)
at com.azurian.lce.usuarios.UsuarioServiceImpl.autenticar(UsuarioServiceImpl.java:31)
at com.azurian.lce.web.admin.actions.LoginAction.execute(LoginAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: COM.ibm.db2.jcc.DB2Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1130)
... 23 more
I want to read the "... 23 more" to see where the exception comes from.
BalusC is right. See here: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Throwable.html#printStackTrace()
In particular:
Note the presence of lines containing
the characters "...". These lines
indicate that the remainder of the
stack trace for this exception matches
the indicated number of frames from
the bottom of the stack trace of the
exception that was caused by this
exception (the "enclosing" exception).
This shorthand can greatly reduce the
length of the output in the common
case where a wrapped exception is
thrown from same method as the
"causative exception" is caught.
What this means in your example is that:
BasicDataSource.java line 1136 caught the ClassNotFoundException thrown on line 1130 and reraised it as a SQLNestedException. Hence the remainder of the stacktrace for the ClassNotFoundException matches the SQLNestedException above and the stacktrace is printed in this more concise format.
The answer is simple, those lines are already in the stacktrace :)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880)
at com.azurian.lce.usuarios.ConnectionManager.getConnection(ConnectionManager.java:65)
at com.azurian.lce.usuarios.db2.UsuarioDAOImpl.autenticar(UsuarioDAOImpl.java:101)
at com.azurian.lce.usuarios.UsuarioServiceImpl.autenticar(UsuarioServiceImpl.java:31)
at com.azurian.lce.web.admin.actions.LoginAction.execute(LoginAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Basically, the following is happening in BasicDataSource#createDataSource():
try {
Class.forName(driverClassName); // Line 1130
} catch (ClassNotFoundException e) {
throw new SQLNestedException(e, "Cannot load JDBC driver class '" + driverClassName + "'"); // Line 1136
}
When the outer exception (SQLNestedException) wraps the inner exception (ClassNotFoundError) they are on the same thread, and so share a common base to their stack trace.
The (23 more...) shows where that common stack starts for the inner exception, which is also the place where the outer exception was thrown. So, whenever you see (XX more...), just look to the exception above to see the rest of the stack trace.
If you want to programmatically print out the stacktrace without the ellipsis for common traces, then you can use Throwable.getStackTrace() and print out all the elements yourself.
Try this out. This logic loops through the main exception and all the causes of it, till there is no more cause (cause == null) left to process. This way you can avoid the 23 more... message. I have not yet tested this yet, but i believe this should work out for you.
BTW - logWriter is a buffered writer. You may want to use System.out.print or any other logging API.
public static void debugError(final String message, final Throwable th) {
final String logMessage = "[ERROR] - " + message;
try {
logWriter.write(logMessage);
logWriter.newLine();
// dump exception stack if specified
if (null != th) {
final StackTraceElement[] traces = th.getStackTrace();
if (null != traces && traces.length > 0) {
logWriter.write(th.getClass() + ": " + th.getMessage());
logWriter.newLine();
for (final StackTraceElement trace : traces) {
logWriter.write(" at " + trace.getClassName() + '.' + trace.getMethodName() + '(' + trace.getFileName() + ':' + trace.getLineNumber() + ')');
logWriter.newLine();
}
}
Throwable cause = th.getCause();
while (null != cause) {
final StackTraceElement[] causeTraces = cause.getStackTrace();
if (null != causeTraces && causeTraces.length > 0) {
logWriter.write("Caused By:");
logWriter.newLine();
logWriter.write(cause.getClass() + ": " + cause.getMessage());
logWriter.newLine();
for (final StackTraceElement causeTrace : causeTraces) {
logWriter.write(" at " + causeTrace.getClassName() + '.' + causeTrace.getMethodName() + '(' + causeTrace.getFileName() + ':' + causeTrace.getLineNumber() + ')');
logWriter.newLine();
}
}
// fetch next cause
cause = cause.getCause();
}
}
} catch (final IOException ex) {
System.err.println(logMessage);
if (null != th) {
th.printStackTrace();
}
}
}