|
Working on a Java web project with servlets, and getting some really strange behavior. A bit of sample code works when run from a main() method, regardless of whether it's in a servlet class or a back-end class. When the same code is actually called in a servlet from the webpage, it fails. What this code does is connect to a secure webservice using client/server certificates for authentication, sends a query, and returns the result. In the case where this fails, I'm pretty sure it's because the client certificate isn't being sent properly (though the error message is vague, and it's possibly something else) - javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure Is there any reason why identical code could behave differently in these two contexts?
|
# ¿ Aug 22, 2008 22:05 |
|
|
# ¿ Apr 27, 2024 07:01 |
|
Lazlo posted:I'm trying to create an arrayList of an object. The object is composed of three strings, and some simple methods. You need a toString() method in your Calc class, then when you print it out it should be: System.out.println("This is the Calc Object: " + al.get(arrayCount).toString()); // Don't actually need the .toString() part - it's automatically called. Something vaguely like this: code:
|
# ¿ Oct 27, 2008 23:45 |
|
^^ I thought that what the question was referring to was something more like this: public boolean substring(String sub) - Determines whether the given substring can be found in this string. Or perhaps: public int substring(String sub) - returns the starting index where the substring can be found in this string, or else -1; Thus, this would return true or 8, depending on which function existed: code:
|
# ¿ Dec 17, 2008 00:48 |
|
I have a problem, and absolutely no idea what the cause could be. Code is essentially like this:code:
Is there any possible explanation for such behavior? I could try to give some more specific details, but I don't know if they'd really be helpful.
|
# ¿ Nov 2, 2009 22:01 |
|
Jethro posted:Can you step through it in a debugger? Not easily (this is a part of a big application that depends on third-party jar files and communication with multiple external servers to produce the error). I'll certainly try to set all this up locally and see if I can get it to work. quote:Alternatively, pepper in some more log statements to narrow down the problem. I know exactly which line of my code that's the last one to be executed. Beyond that, it goes into a third-party jar to do some axis communication. That still leaves me questioning exactly how this can cause my problem. It's as if the entire callstack is being obliterated and the program is silently continuing on its merry way. Any kind of problem should either be caught (by catch(Throwable t)) or cause a program crash, right?
|
# ¿ Nov 2, 2009 22:47 |
|
Jethro posted:Unless he did a fantastically bad job of explaining his problem, I think he was saying that the program was dieing, but even once he added in the try...catch no exceptions were being caught. You are correct. If there's an exception thrown in doThing1(), I'm not expecing doThing2() to be executed. I'm expecting the exception to be caught where it should be caught, and for execution of the main method to continue. The problem is that even with catch(Throwable t), there's nothing being caught. The execution simply stops. Furthermore, anything in the main method AFTER the try/catch block is also not getting executed. As I said, it makes no sense whatsoever, which is why I'm asking if anyone has ever seen anything like it, or has any ideas of what I can try. (I haven't had a chance to seriously try the debugger yet, been working on on-site interop testing all week :puke:)
|
# ¿ Nov 3, 2009 22:42 |
|
It doesn't stop or exit, it just continues running (after skipping whatever code it skips) as if nothing ever happened.
|
# ¿ Nov 4, 2009 05:33 |
|
Publius_Maximus posted:4. (10 pts) Write a static method named ex1() that returns a BinaryTree object representing the expression (2 + 4) * 8" Do you know what the binary tree for that expression should look like? If you know that, it should be trivial.
|
# ¿ Nov 19, 2009 07:46 |
|
UberJumper posted:3. The system does some work with threads, i know nothing about java threads, anyways i looked at the credited example that was used as the basis for distribution of data between threads: It's kind of bad, but I don't think (though I'm definitely no expert here) that this code will cause any problems. All the threads will wake up, but the synchronized nature of the method will prevent multiple threads from actually obtaining the lock. You might want to look into the SynchronousQueue class though (or any of the other java.util.concurrent structures), since it seems to do about the same thing the code you pasted is doing. quote:Does anyone have any good recommendations for links about threading for java? I found some but alot of them are about java.util. concurrent, which seems alot more intelligent for doing this stuff. Since it gives better control. You may have already read this, but it's decent as an introduction: http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/essential/concurrency/index.html Searching for 'java concurrency' provides several other tutorials.(http://tutorials.jenkov.com/java-concurrency/index.html has some pretty good stuff near the end, at least)
|
# ¿ Jul 9, 2010 07:51 |
|
Two Percent posted:I'm really sorry for barging into a subforum I never participated in just to ask for help. I've been trying to work around this for days and Google isn't helping. I'm a complete newbie to Java who barely got started and I'm having trouble with what I feel is a trivial issue but it has stumped. Those aren't unicode escape characters, they're octal escape characters. You convert them by finding the base10 representation and looking in the ASCII table, basically. This seems to do what you want, though it will require some modification to fit in with your stuff (since I couldn't really figure out what some of that code was doing). code:
code:
Kilson fucked around with this message at 09:15 on Jul 21, 2010 |
# ¿ Jul 21, 2010 09:10 |
|
Two Percent posted:Told you I'm a newbie... To be honest, I had to look that up as well. It's not a terribly common construction. quote:Yeah, I was trying to mean exactly what you said, I wanted them parsed to ASCII. I think you can do replaceAll("\\\\\\\\", "\\") and it works the same way (yeah, it's stupid - gently caress you Java for not having a non-escaped regex syntax). I can't be 100% sure here, because this Linux machine I'm using seems to handle these characters strangely and outputs only characters that look like empty boxes, and won't allow me to copy/paste them here.
|
# ¿ Jul 21, 2010 22:28 |
|
Cukel posted:I'm trying to have a Vector array with four Vectors containing four different types of objects that are all subclasses to the same superclass, so that I could refer to the Vectors with index numbers. This is how I'm trying to do it: You can't create generic arrays in Java. The warning isn't something to be terribly worried about, as long as you're sure you're putting correctly subclassed vectors into the array. More specifically, you probably should do something like: code:
However, if you do this: code:
Kilson fucked around with this message at 16:26 on Aug 26, 2010 |
# ¿ Aug 26, 2010 16:09 |
|
Cukel posted:Why is it a generic array? Just because I'm using Vectors? Because this gives the exact same warning: See my longer response above. A generic array would be something like code:
|
# ¿ Aug 26, 2010 16:28 |
|
Kaltag posted:I am only researching the feasibility of this idea. We did something like this recently, using RXTX (new version/info here). It uses JNI internally, but it's pretty easy for the programmer. We used it for both direct serial connections and serial/USB adapters, and it worked fine for both. We probably used an older version too, but I don't remember for sure. I can't say it has exactly what you want, because it seems like you want something possibly even more low level. Kilson fucked around with this message at 21:33 on Aug 30, 2010 |
# ¿ Aug 30, 2010 21:30 |
|
That error code seems to have something to do with Java not always being able to properly determine when a running process exits (or something along those lines) on Windows. It seems to be fairly common, but I've also seen claims that it doesn't happen anymore. What version of Java are you running?
|
# ¿ Oct 1, 2010 20:34 |
|
MariusMcG posted:I'm building a project in Eclipse that uses some third-party libraries. I've placed those libraries in my GlassFish domain/lib directory so that they're getting auto-loaded when the server starts. Is there a way to configure my Eclipse project so that it will expect to use the libraries on the server instead of bundling the libraries inside of the WAR file? Don't tell Eclipse to bundle them into the WAR. Or just do what you're doing, it doesn't matter. By default, Glassfish searches for jars in this order: main library (glassfish/lib), domain library (domain/lib), and then application library (j2ee-applications/modules/<app>/WEB-INF/lib (or something like this)).
|
# ¿ Oct 9, 2010 07:03 |
|
Paolomania posted:As with other languages ... C# has no fallthrough, and requires an explicit break, even for the default case. However, you can goto another case.
|
# ¿ Nov 1, 2010 05:16 |
|
Shavnir posted:Its this way in Ada as well, except the compiler just about comes out and kicks you in the balls if you use a goto. That's probably good. Everyone knows COME FROM is way better than silly goto anyway.
|
# ¿ Nov 1, 2010 06:40 |
|
Jewbert Jewstein posted:I had finally finished this program that I was writing for work, but my boss wanted me to upload it under a different name than what I had called it originally (ie- adding an "_2"). Ever since doing that this red exclamation mark won't go away and any changes that I make to the code don't get made whenever I compile and test it. I'm working in Eclipse on a Vaadin project titled "AddressSearch_2". I have the same problem occasionally in Netbeans. The way to fix it there is to delete the cache folder where it stores all the information about source files and restart. When it restarts, it will have to rebuild the cache, and the issue should go away. I would guess there's a similar procedure you can follow for Eclipse.
|
# ¿ Nov 19, 2010 19:49 |
|
UltraPenguinX posted:Hi thread! I had a question regarding threading in Java. What I'm doing is rather simple: I have a method in which I am creating a network-listener object, which runs in its own thread, and stands ready and waits to receive an incoming packet, then does stuff with it, then goes back to being ready to receive. What I would like to be able to do is have the listener object let the method (or by extension the "main" thread, as right now I only have 2) know that it is waiting to, or very readily about to receive a connection. I read up on wait() and notify(), as I had a feeling that is what I should be using, but I'm afraid after much experimenting it was all for naught. Can someone point me in the right direction? You might try a BlockingQueue. Put packets in the queue and have the handler .take() them from it. quote:DOUBLE EDIT: I'm also having an issue with the DatagramPacket class. I can implement it fine and it works wonderfully, except when I put it into another thread, like so: I don't think you can just say new Thread(<some object>).start() and have it do what you want. You have to create some subclass of thread that handles the type of data you want. If PacketHandler already does extend Thread, then you'd just say new PacketHandler(p).start().
|
# ¿ Dec 20, 2010 00:34 |
|
Using basic string manipulation shouldn't be too much harder. substring, indexOf, etc.
|
# ¿ Dec 21, 2010 02:59 |
|
Rohaq posted:I wrote a semi-retarded HTML tag stripper, it doesn't recognise <script> tags though: Instead of <char> == "<char>".toCharArray()[0], you can just do == '<char>'.
|
# ¿ Dec 21, 2010 04:26 |
|
Thermopyle posted:I'm really new to the Java language, but it's my understanding that ArrayLists aren't thread-safe. I think you can wrap an ArrayList with Collections.synchronizedList to make it thread-safe. Not sure what the performance characteristics are, or even the exact behavior.
|
# ¿ Jan 13, 2011 20:19 |
|
I'm trying to write an application that uses TCAP network transport. The problem is that TCAP seems to be inextricably linked to SS7, whereas we're supposed to be using IP. Are there any libraries that allow me to use TCAP over IP?
|
# ¿ Feb 22, 2011 22:02 |
|
FamDav posted:I want to use a ThreadPoolExecutor to maintain processes sent to the server. However, I would like the logging output to show which thread in the pool performed which actions. Log4j (and I assume other logging frameworks?) can tell you which thread in a pool is logging which output. If you have a pool named 'foo', the output could look something like this: code:
|
# ¿ Feb 23, 2011 23:04 |
|
Seafea posted:So, I'm dealing with a String that could be in one of two formats. Either ABC or BC, where A/C are a positive integer, and B is the letter S. So you want to return the ones that are <number>S<number> in a list, and not the ones that are S<number>? Or you want to return only the first number from the instances that have an S in the middle? (I'm a little confused about your change in lettering, from ABC/BC to AX to 'the A instances of the String "BC"') Why not just just use .startsWith("S") to determine which case you're in, then you can do .substring(0, .firstInstance("S")) or whatever to get the first number (if that's what you're looking for??)?
|
# ¿ Mar 3, 2011 05:48 |
|
I'm trying to extract a bodypart from a MIME Multipart message. I get the correct bodypart and everything, but this code isn't working as I understand it should.code:
java.lang.ClassCastException: javax.mail.internet.MimeBodyPart cannot be cast to java.lang.String I don't understand why bp.getContent() would give me back a MimeBodyPart. Setting the DataHandler as text/plain is supposed to give me back a String. Also, I'm pretty sure this code used to work. Is there a proper way to do this?
|
# ¿ Mar 4, 2011 21:05 |
|
Also, don't use the default Stack, because it extends from Vector, and is retarded. (Unless you need a stack with random access, which means you really should be using some other structure anyway)
|
# ¿ Apr 28, 2011 14:31 |
|
Or in Netbeans, you add the res folder as a source folder in the project properties, then you don't have to have it under source, but it still gets copied into the jar properly, and you can run from within the IDE.
|
# ¿ Jun 28, 2011 04:25 |
|
I've used the RXTX library a bunch, but I'd say the same thing as Contra Duck. Just synchronize the method doing the writing, or acquire a lock, or put writes in a shared queue to be written serially, or something.
|
# ¿ Aug 17, 2011 03:13 |
|
Having a really stupid problem that I can't figure out. I'm hoping it's completely dumb and that I'm dumb. I have a TreeSet, and I insert 10 objects into it. When I then print the contents, there are only 4 items in the set. This is basically the class I'm using. code:
code:
|
# ¿ Aug 23, 2011 20:33 |
|
Lysidas posted:You should read up on the Comparable interface. Your defined natural ordering is not consistent with equals. *sigh* I read that earlier, but I kind of stopped after the part where it said: Comparable posted:It is strongly recommended (though not required) that natural orderings be consistent with equals. I thought it was just recommended for some sort of ivory-tower reason, not because the difference would have real effects. Thanks for pointing out my failure to RTFM.
|
# ¿ Aug 23, 2011 21:03 |
|
Aleksei Vasiliev posted:why are you using ternaries inside if statements Those were methods generated by the IDE.
|
# ¿ Aug 24, 2011 16:11 |
|
I find XOM 1000 times easier than JDOM.
|
# ¿ Sep 9, 2011 20:18 |
|
GodIsInTheTrees posted:*Edit - I actually think it's Hibernate causing the initial problem, but all Googling turns up is that I need to update j2ee.jar, which is fine and all, but I can't seem to get an updated version anywhere without grabbing the version WAS provides, which is NOT current enough. gently caress you, company who likes to use frameworks from 2004 and app servers not much more recent. Can't you just download a new Tomcat/Glassfish/Jboss/??? and get the j2ee.jar from that? There's a WAS v8 you can download a trial for - it probably contains some sort of j2ee jar as well. I don't know if any of these things will work, but it's worth a shot I guess.
|
# ¿ Sep 27, 2011 03:21 |
|
Newf posted:I'm getting an 'incompatible types' error on the last return statement, even though qSort seems to me to consistently return ArrayList<Integer> objects. addAll() doesn't return what you think it returns.
|
# ¿ Dec 9, 2011 17:37 |
|
The only time I've run into permgen space problems is when using a lot of Spring/CGLib stuff in a web container. Redeploy the application(s) several times, and the JVM starts puking, because it has some problems cleaning up after proxy classes or something.
|
# ¿ Jan 23, 2012 03:25 |
|
If you really want to work with xml, I recommend using a library like XOM (my favorite) or JDOM (the most well-known). It will make your life a billion times easier.
|
# ¿ Jan 27, 2012 16:27 |
|
DholmbladRU posted:
Your class is called 'homeObj', and your last line is 'homeObj.<method>', which looks like a static call. The last line should say 'homeObject.setLocation...' instead. Also, class names should start with an upper-case letter in Java. It helps avoid things like this.
|
# ¿ Jan 28, 2012 22:26 |
|
|
# ¿ Apr 27, 2024 07:01 |
|
When you use "<@ page import", you're not importing a file, you're importing a java class. If you open the .java file, it will say "package x.y.z" at the top somewhere. Your import should look like 'import="x.y.z.<classname>"'.
|
# ¿ Jan 31, 2012 18:50 |