UUID.randomUUID -> java.lang.StackOverflowError? - java

The title explains the problem I think, trying to create a random Id for an Object, I'm getting the following exception:
java.lang.StackOverflowError
at sun.security.provider.ByteArrayAccess.b2iBig64(ByteArrayAccess.java:274)
at sun.security.provider.SHA.implCompress(SHA.java:122)
at sun.security.provider.SHA.implDigest(SHA.java:103)
at sun.security.provider.DigestBase.engineDigest(DigestBase.java:186)
at sun.security.provider.DigestBase.engineDigest(DigestBase.java:165)
at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:576)
at java.security.MessageDigest.digest(MessageDigest.java:353)
at sun.security.provider.SecureRandom.engineNextBytes(SecureRandom.java:226)
at java.security.SecureRandom.nextBytes(SecureRandom.java:455)
at java.util.UUID.randomUUID(UUID.java:145)
I don't think that anyone can tell me what is going on since I provide little information -> I know that.
The thing is: I have not any other information, I just create a randomUUID and it crashes.
So I'm just asking for ideas, since I don't find any googling this exception.
Thanks in advance.
EDIT:
Answer provided by
m0skit0 and scotth
Without noticing that the method which lead to an object creating a UUID was called nonstop I - well - did not notice that a huge amount of UUIDs was generated, which lead to the stackoverflow.
Thank you!

Related

Autodesk Forge java tutorial new bucket creation failure

I was following autodesk forge tutorial for java, but using their code examples, new bucket creation fails for me with almost no error information except " com.autodesk.client.ApiException: error". So I was wondering if anyone else already tried to create simple viewer using their tutorial and managed to solve this problem or at least encountered it.
Their sample program in GitHub is sadly incomplete, so I can't exactly check if there are any mistakes regarding servlet mappings.
com.autodesk.client.ApiClient.invokeAPI(ApiClient.java:581),
com.autodesk.client.api.BucketsApi.createBucket(BucketsApi.java:113),
forgesample.oss.doPost(oss.java:141),
javax.servlet.http.HttpServlet.service(HttpServlet.java:661),
javax.servlet.http.HttpServlet.service(HttpServlet.java:742),
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231),
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52),
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193),
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166),
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198),
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96),
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496),
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140),
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81),
org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650),
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87),
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342),
org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803),
org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66),
org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790),
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468),
org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49),
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142),
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617),
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61),
java.lang.Thread.run(Thread.java:745)
EDIT
Apparently using a more unique bucket name I managed to create one, but the given error was plain 400 and stack trace does not give exactly much help.
For the record, here are the requirements for bucket names:
A unique name you assign to a bucket. It must be globally unique
across all applications and regions, otherwise the call will fail.
Possible values: -_.a-z0-9 (between 3-128 characters in length). Note
that you cannot change a bucket key.
And thanks #WidnmaxJ for the feedback, logged for improvements on the tutorial.

JPAAppender blob

I am testing the log4j JPAAppender these days. After hours of work, I encountered just as same problem as others did.(if you search for JPAAppender, you will get that the log4j JPAAppender got a bug which keeps persisting garbage of a column of blob in size is huge for database). After that, I tried to download the source code from its official website and rewrote my own code which has exactly same class name and all the same functions in source code apart from a tiny modify I made to avoid entitymanager persisting garbage into database.
#Transient
private final LogEvent wrappedEvent;
here it is as you can find in log4j 2.7,package
package org.apache.logging.log4j.core.appender.db.jpa;
After doing that with full of hope that I might make it right, I ran my application and I got this error:
2018-01-29 17:18:44,543 main ERROR Entity class [com.log4jtest.demo.logger.JpaLogEntity] does not extend AbstractLogEventWrapperEntity.
So, what can I do? I really wanna use this appender.
maybe you might do the following, I will appriciate it:
1. tell me how to extend my own class without the error ocured
2. maybe you have got some brilliant solution, pls share.
thanks in advance.

Java_Questions: need help in understanding

I appeared for an interview few days back. Some of the questions asked in interview of those i don't know the answer. Can anyone please help me understanding those.
Q1 : Can we catch Errors ? Here answer is Yes we can catch errors. Anything under Throwable class can be caught. but as per the book standard we should the errors but as per the interviewer point of view we should catch so that in any case my application won't show any blank page or Java error to user. So i am able take the gist like whether we need to catch error or not
Q2 : What is the DIALECT property in hibernate configuration file ? I didn't get any significance of this property anywhere.
You have posted two entirely unrelated questions. I shall answer the first one.
Normal business code should never catch Errors, but framework code, which controls the entire request processing lifecycle, definitely should catch Error exactly as your interviewer explained. You don't want your entire application to go offline due to a single StackOverflowError or OutOfMemoryError, most of which are fully recoverable from.
Q1: I don't understand this question.
Q2: Different databases understand a different SQL. So Oracle's 11g needs different SQL than Microsoft SQL Server 2012.etc

Java Netbeans error

I've been following the 'Netbeans E-Commerce tutorial', and have am currently on this step:
http://netbeans.org/kb/docs/javaee/ecommerce/entity-session.html
I have fully configured my Window 7 account as per that page, with NetBeans 6.9.1, Glassfish server and MySQL.
I'm getting an error 500 when executing 'Category' page (log extract below). The error manifests itself when I complete step 3 in the 'selected category' sub-section of the 'Accessing Data with EJBs' this page. The line in question is:
// get selected category
selectedCategory = categoryFacade.find(Short.parseShort(categoryId));
If I comment this line out, the bug goes away.
The log file snippet is here:
[#|2010-09-29T18:32:32.570+0100|WARNING|glassfish3.0.1|javax.enterprise.system.container.web.com.sun.enterprise.web|_ThreadID=30;_ThreadName=http-thread-pool-8080-(2);|StandardWrapperValve[Controller]: PWC1406: Servlet.service() for servlet Controller threw exception
javax.ejb.EJBException
at com.sun.ejb.containers.BaseContainer.processSystemException(BaseContainer.java:5119)
at com.sun.ejb.containers.BaseContainer.completeNewTx(BaseContainer.java:5017)
at com.sun.ejb.containers.BaseContainer.postInvokeTx(BaseContainer.java:4805)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:2004)
at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:1955)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandler.invoke(EJBLocalObjectInvocationHandler.java:198)
at com.sun.ejb.containers.EJBLocalObjectInvocationHandlerDelegate.invoke(EJBLocalObjectInvocationHandlerDelegate.java:84)
at $Proxy355.find(Unknown Source)
at session.__EJB31_Generated__CategoryFacade__Intf____Bean__.find(Unknown Source)
at controller.ControllerServlet.doGet(ControllerServlet.java:68)
Line 68 in the ControllerServlet code is the one identified above.
My experience with both Java and Netbeans is sufficiently light that I'm not even sure how to go about starting to debug this. I've followed the tutorial pretty closely, so it should not be something I've missed - but mistakes do happen.
I understand an outright solution based on the information contained would be difficult. If there is any further information required, please ask. Failing that, if anyone has any suggestions on how I can further investigate this on my own, I'd be very grateful.
I always think cracking problems is the best way to learn, but it is pretty frustrating as well.
Update:
I've been running through the NetBeans debugger. It appears that the problem is with the cast code (Short.parseShort(categoryId)). When I replace this with a simple numeral it works.
e.g. this code works
// get selected category
selectedCategory = categoryFacade.find(1);
Does anyone have any ideas why the cast is failing? categoryId is confirmed as a string with a value of "1" in the debugger...
Okay, I've cracked this. It was obviously my fault...
The table identity should have been set up as a short, instead I set it up as an integer. Therefore by casting the 'categoryId' string to short and passing it into the find method, I was passing in the wrong data type.
Replacing the 'Short.parseShort(categoryId)' argument with a 'Integer.parseInt(categoryId)' fixed the problem.
For those that took the time to read this; thank you.

Java XML Tool using method chaining/builder pattern

I remember that a while ago I found a truly great utility here on StackOverflow for manipulating XML documents with an interface like:
new XMLTool(document)
.goTo("xpath")
.addNode("name")
.addChild()
.addContent("xxx")
.parent()
.remove("oldNode);
Could anybody tell me what tool that was?
Maybe the java-xmlbuilder at Google code? It's indeed great in use.
You've got to be kidding me. It's actually called XMLTool.
I must've had a brainfart while searching for it!
This is the URL: http://code.google.com/p/xmltool/
At least the next time someone searches for method chaining XML tool he'll find this post ...

Categories

Resources