~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Updated: Here is a chart which has got almost all the dates nailed down along with the series which would definitely be aired.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Mayoi Neko Overrun sounds something between Let's Meow Meow!
> and Love Hina.

I was expecting it to be more along the lines of Nyan Koi! but oh well, let's see.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A new anime season is just round the corner; preview here.

My favorites would be:

  • Angel Beats (My type -- romance, action, harem)
  • Arakawa Under the Bridge (crazy work by Shaft)
  • Mayoi Neko Overrun (Neko-chan!)
  • Working! (Interesting Slice of life)
  • Ichiban Ushiro No Dai Maou (reminds me of ZNT)

Of course I might end up dropping one of those or picking new ones after evaluating them but the ones mentioned above have high priority.

So, what's on your list? :)

iamthwee commented: booooooooo! Geek. +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMO giving a thread title like "Hijack Attempt #2 -- Do this for me. I can't be bothered" doesn't solve anything. At best, it seems like an attempt to make others laugh by mocking at the OP, certainly not expected of a group of people who are responsible for looking after a community, however good or bad it may be. Closed. :(

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The equality operator compares references.

String str = "hello";
String anotherStr = str;
System.out.println(str == anotherStr); // true

If case you need logical equality check, use the equals method of the String class.

String line = readLine(); // user enters 'mypassword'
String pwd = "mypassword";
System.out.println(line == pwd); // false
System.out.println(pwd.equals(line));  //logical equality; true

If it's still confusing, I'd highly recommend you read the excellent tutorials available at Sun along with the book Head First Java.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster
String[] myarray;
string myarray = new String[20];

`string` is the unknown type here; I think you'd want something like:

String[] myarray = new String[20];

Also, you are missing a closing brace for the `if` statement and an extra brace after the `else` statement. Indenting your code might help you out when it comes to missing/misplaced braces.

I'd recommend reading the Java beginner tutorials and starting off with small programs to get a hang of the language and its syntax.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

When it comes to reference types, == compares references and not the actual objects. If you want a logical comparison (equal check), use the equals method of the String class. Read Javadocs for more details.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Would it be a null?

Yes, it would be a null. In such cases, it helps to think of arrays as just another class containing a list of values rather than a provision built in the language itself.

class ArrayOfInts {
  // for every ArrayOfInts object created, i will be 0 by default
  private int i;
}

class ArrayOfBooleans {
  // for every ArrayOfBooleans object created, i will be false by default
  private boolean i;
}

class ArrayOfPoints {
  // for every ArrayOfPoints object created, i will be null by default
  private Point i;
}

I'd personally work with a fixed size ArrayList of points and if needed, invoke the toArray method to get the underlying array. Much easier and cleaner IMO.

List<Point> points = new ArrayList<Point>(13);
points.add(new Point(12,12));
// and so on
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

When you define an array, the array elements are given their default values which depends on the type of elements the array holds. For booleans it is false, for integers it is 0, for reference types it is... :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The only reason I can think of is that the old Tomcat installation had an Axis jar lying around somewhere and hence wasn't giving any problems. Upgrading Tomcat must have done away with the Axis jar and hence the error. If you are not using Axis, you are better off removing the said part. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

jDom and Dom4j are pretty generic libraries aimed at easing the interaction with DOM. There is a class of libraries called O/X Mappers aimed specifically at object to xml conversion and vice-versa.

Look into libraries like Jaxb, XStream, XMLBeans, JiBX for more details. Of the ones mentioned, JAXB is a Sun initiative and has a pretty good standard acceptance. XStream seems to be pretty easy to use in case you have simple O/X mapping needs. Play around with those you'd surely find something which suits your needs.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

What was the problem? Missing jars?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> btw, how do we view a list of past 'members of the month

You can view the newsletter archive here which also has the member of the month interviews.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I've never messed with ClassLoaders before, so I don't really know how to do it correctly. If I don't instantiate the objects, how am i supposed to access them later?

Classloaders are used for loading classes. Typical scenarios wherein you would require a custom classloader is:

  • When you are writing a framework which hosts managed components written by users and configured in a declarative manner (think servlets)
  • When you want to add pre/post processing operations to the loaded resources. E.g. loading encrypted classes and images, caching frequently loaded images etc.

In any case, if you need access to your loaded classes, you can use the findClass(String) method of the classloader to do so. E.g.

Class klass = Thread.currentThread().
     getContextClassLoader().findClass("my.game.pkg.Klass");

This would give you the reference to the loaded class based on the class named specified.

Also, you can gain complete control over your instantiated components by using a dependency injection framework like Spring but I guess that would be too enterprisy for a hobby project. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I've always worked on critical financial systems used by banks and top-notch financial organizations which deal with millions/billions so the "user satisfaction" is never an issue.

I'm personally in favour of self-satisfaction, the learning gained and the moolah over user-satisfaction; I'd rather have the employer worry about the latter. And in case you are really interested, join and contribute to an established open source project; much better. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Do we need a new thread every time someone achieves x or y
> amount of post

No, we don't, really. But you chose to post a "yawn" instead of looking at the thread, shaking your head and moving on. There are some things you mustn't do and one of them is punching holes in someone's happiness. :)

> But its not like you see this all the time

Yeah, don't worry about it, we don't mind spammers who contribute in a good way. :P

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Welcome to Daniweb Paul; looking forward to your...

Oh wait, you already have more than 1000 posts! ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

hmm, s.o.s, is there a way to get around that? Or should I just code a specific loader for each group of objects? Because that's starting to look like a cleaner, easier option.

You might want to clarify your requirements here since the original snippet posted is confusing. Why are you instantiating objects inside your classloader? What exactly are you trying to do here and why?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

But this does not really help me. I still dont know hat to register my subclass. Does anyone?

The same way you would register the Spring XML configuration file. In your web.xml along with specifying the context configuration location, also specify your context loader class. Something like:

<context-param>
	<param-name>contextClass</param-name>
	<param-value>net.sos.services.common.MyLoader</param-value>
</context-param>
<context-param>
	<param-name>contextConfigLocation</param-name>
	<param-value>classpath:net/sos/services/config/cxf.xml</param-value>
</context-param>

Here net.sos.services.common.MyLoader is a class which extends the AbstractRefreshableWebApplicationContext class.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The problem here is that instead of having the commons jar file in the WEB-INF/lib folder, you have a commons-lang folder. This doesn't work for the simple reason that it's the jar files in the WEB-INF/lib folder which are on the classpath and not the jar files which are present in any of the sub-directories of the WEB-INF/lib folder. Move just the commons-lang-2.5.jar file directly under the lib folder and it should work out to be fine.

talha06 commented: Thank you so much for your helps and patient. +1
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The screenshot you have attached shows compile time dependencies...

OK, let's tackle this in a different way. Right click on your project -> Export -> Web -> War File and export your project as a WAR file. Browse this WAR file (just like any other archive) and see if you can see your jar files in the WEB-INF/lib directory. If you can't, then there is something wrong with the way you have configured your project.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You should never add any application specific jar to your server's lib folder; add them to the `lib` folder of your WEB-INF folder. And the ClassNotFoundException is a clear indication that specified class is not on your runtime classpath. Also, post the entire stack-trace for reference.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Is it in the lib folder of WEB-INF? It'd be difficult to suggest anything without looking at the actual project structure. Have you tested this out with a standalone application? Are you using an IDE to develop and run this web app?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Instead of using Strings, use enums for your "face" and "suit" types. Create a separate class Card which would contain the card related information like face, suit, representation etc.

Always think about abstractions and layers when creating an application. The "Card" type (Model) can be used for creating a swing application, a web application, an andriod application (different views). With the current program design, you have little scope of re-use. It's leaky abstractions all the way. Read more about the MVC design pattern. When designing OO software, think of ways of how you can push responsibilities.

Of course, all this need not happen immediately. Take your time, understand why this program is not flexible, think of how you can reduce the complexity etc. If you can afford a book, I'd recommend Head First OOAD as a good starting point. Another interesting read might be; never do any work that you can get someone else to do for you.

Good luck :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

The error is exactly what it says, the classloader was not able to locate your class. Where have you placed the Hibernate jar files?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Look at the source code of the existing collection classes in Java to see how you can implement your own generic collection type. Also, read my reply here.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You seem to be confused as to the way generics work in Java. Here E is a type-parameter which is used during compile time checks; there is no `E' when it comes to your generated .class files. Search for "type erasure" in java generics for clarification.

stephen84s commented: Bingo +5
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> I prefer it when the web behaves deterministically

Wishful thinking methinks :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

THANK YOU VERY MUCH.....
ITS WORKING...... I AM SO HAPPY.....

You are welcome, but please do not to use red/bold text since it hurts the eyes.

I have posted this same issue in YDN they were not able to answer this issue......

Then you should post this solution or at least a link to this thread in your YDN thread to help those who end up facing a similar issue. :)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> However, the "can't find symbol" errors remain, mostly related to the
> FTPCommand(s) in the code below

What exactly is this FTPCommand class here? Is it your class or does it belong to the commons library? If it's your class, is it placed in the same package as that of the UIAgent class? If it's not your class, I don't see any import there...

> "connect(java.lang.String) in csci4311.ftp.UIAgent cannot be applied
> to (java.lang.String,int)"

This is because the compiler infers that you are making a call to the 'connect' method of your UIAgent class which doesn't accept any second int parameter. You should ideally make a call to the *actual* Ftp client's connect method in your connect method, which is like delegating the connection responsibility to the actual class which does all the heavy lifting. Something like this:

public class WrapperClient {

  private FtpClient ftpClient;

  public Status connect(String host, int port) {
    ftpClient = new FtpClient();
    ftpClient.connect(host, port);
  }

}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> My questions is how to convert TIMESTAMP value to a Java Date
> or Calendar Object ?.....

It seems that the Timestamp here refers to the Unix timestamp (which is the number of seconds elapsed since January 1, 1970 (midnight UTC/GMT). This is in contrast with the way Java timestamp works which is considered to be the number of milliseconds elapsed since January 1, 1970 (midnight UTC/GMT). Multiplying the returned value with 1000 should do the trick here.

Also, ensure that you don't fall in the trap of truncation while multiplying those values.

Date d = new Date(1265207400 * 1000); //is different from
Date d = new Date(1265207400 * 1000L); // or
Date d = new Date(1265207400000);

In case you are still wondering why, in the first declaration the integer result of 1265207400 * 1000 which is 1966688416 and not 1265207400000 , is passed to the Date constructor leading to erroneous results.

> Thanks in Advance

HTH

zac_mathews commented: This was very usefull and very helpful... Thanks SOS +0
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

I am a touch typist and my typing speed falls between 60-70 wpm with 100% accuracy (no spelling mistakes) which IMO is pretty decent. My speed/accuracy can be attributed to not using chat/l33t speak even when chatting. ;)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

If you are using the command line to compile your classes, you need to specify the location where the java compiler would be able to find the apache commons classes i.e. the classpath. Look more into the documentation of the javac command, especially the -cp option. In case you are using an IDE, you need to refer to the documentation of that IDE, esp the section which deals with setting the build path.

Also, post your latest code in case you still face problems.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You are declaring your methods inside another method (the public static void main method) which isn't acceptable in Java. I'd recommend reading the "sticky" thread at the top of this forum for getting started with Java.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

| has a special meaning when it comes to regular expressions, it's called the alternation symbol.

If you have something like "##|##|##".split("|") , it's the same as "##|##|##".split("") since a single pipe symbol is the same as saying "alternate between a blank string and another blank string" which is the same as a blank string.

You can either:

  • Escape this pipe character and tell the regex engine to treat is at a literal pipe character. Something like "string".split("\\|")
  • Use character classes, similar to the example posted above (i.e. [|] )
BestJewSinceJC commented: Haha! I knew that | = or, but couldn't recall it at the time. +4
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Would the try...catch work? The only way it will work is if it does synchronizing against all threads. Remember, the problem here is that 2 threads are calling the same check-create code, at the same time and 1's create may change the state in the middle of the other's check-create statement.

When you rely on gobbling exceptions + the correctness of the FTP library you are using, you need not bother with the 'check' phase. The code would be something like:

ftp.connect();
try {
    ftp.createDir("myDir");
} catch(DirAlreadyExistsException e) {
    // dir already exists, use it
}
ftp.changeDir("myDir");
ftp.storeFile("myFile", myFileIoStream);

This *should* work; if it doesn't, something is seriously broken.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You can try out the following things:

  • Place the folder creation code in the try...catch block and catch the specific FolderExistsException exception. When this exception is caught you know for sure that the target folder exists so you need not create it. You can just ignore this exception and continue with your work.
  • You can try the directory name to object mapping approach for locking as already suggested by James
  • You can have a workflow class as mentioned in one of my previous posts, but this time for your FXPThread classes. This way you can explicitly handle the dependencies.
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

A list of Infrequently asked questions (IAQ) by Peter Norvig. A good read for experienced Java developers IMO though a bit heavy for newcomers.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

folder is created then entered by one, then attempted to be created a 2nd time by the other, throwing a "already exists" error

If this is the case, then I think you are over-engineering the problem. A simple existence check for the directory is much more logical and simpler than trying to synchronize `n' FTP instances. Have you tried that out yet?

The only thing I can think of is to use a static object global to all FTPs to lock on, or to pass the same object to all of them, not per FXP, but for each FTP in general

Then you are basically making all your FTP actions/calls execute in sequence or only one FTP action at a given time. Your FXPing class uses FTP classes to do the real work. If you sync on a global static object and that too in your FTP class, it's as good as not using threading approach, at all.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

IMO, the operations(mkdir & chdir) should be part of the same thread of execution. Also, creating a thread-aware Ftp class doesn't seem like a good idea unless of course you provide a provision to schedule multiple FTP actions synchronously.

I would have to create a generic static object and synchronize (the object), so only 1 thread is able to lock it at any time.

*Don't* use static variables for synchronization, at least not in your case. They seriously limit the way in which a class can be used and usually turn out to be scalability killers.

In your case, you need to ensure that both the FTP thread classes need to synchronize on a logical instance (and not a static variable). You can for e.g. create a FtpWorkflow class which would be passed to your Ftp thread class during creation. This workflow class can be used to share information between two Ftp operations along with providing a common ground for synchronizing the FTP operations involved in the workflow.

You can take this concept a bit ahead and expand on it by making FtpWorkFlow implement Runnable. This workflow class would now support scheduling of Ftp commands and make sure they are executed synchronously thereby hiding all the boiler-plate scheduling code.

You can of course use any XXX class for the same with a functionality of your choice though the basic idea remains the same.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Given text as posted above, what is the easiest way to parse the pieces
> inside parens?

You can split the given string on spaces which would yield tokens like 60 , Sor29/RDD10/Pal1] , TJ's , Radiant Sorcerer . The way you would interpret these tokens depends on you.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

> Yes, but performance degradation due to remote call is a concern so
> this one is ruled out

You sure? Assuming your EJB's are deployed on an App server like Jboss, you can publish this Decryptor service to JNDI on the same server instance which makes the EJB -> Decryptor almost as efficient as local. Anyways, I wouldn't actually believe the degradation of performance without concrete tests. Even if lookups are expensive, you can cache the service reference. Some application servers come with the setting of passing objects by reference rather than marshalling/unmarshalling them if remote calls are made over the same VM.

But then again it depends on the kind of extensibility required or the kind of design the client is OK with, so yeah, whatever floats your boat. :-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

substring approach won't work given that the length of entire string along with the player names and the attack rating is not constant or known in advance. Go with the regex approach IMO.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Write String data to your DataOutputStream using the writeUTF method and read the same at the server using the readUTF method of the DataInputStream. Another option would be to write to the OutputStream by wrapping it in a PrintWriter and then at the client using the BufferedReader to read the same. Then:

  • Initialize a Map of String to Integer
  • Loop over the characters present in the String
  • For each character, check if it's a letter using the utility methods of the Character class
  • Check the presence of the character in the Map, if isn't not present, place the character in the Map with the value as 1 otherwise increment the value for the given character in the Map (you can apply the same logic using arrays if you need performance but I don't think you should concern yourself with these things right now)

Also, are you planning to use this code for a single client given that your TCPServer is stateful (since it remembers the previous string passed in)?

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Whoa! dhanyavad!

You are welcome :)

No comprende.... If the page changes, I thought the cache would be overridden.

*Only* if the the server sends proper headers saying that the file XXX has changed; without that the browser has no way of knowing that something has changed. This is the very reason why Dani sometimes requests members to manually clear their caches after she rolls in a new version of library or images...

Database The page istelf was still the same. It was just the database contents that does not get stored in the cache that changed. Ja?

No, nothing related to database as such. From the looks of the screen-caps you posted, it seemed like a case of missing CSS(stylesheet) files.

As a rule of thumb, always CTRL + F5 when you see something unexpected; if it still persists, time to create a new thread. ;-)

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Try pressing CTRL + F5

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Never start off with your regular expression with greedy quantifiers unless you know what you are doing. The .* at the start of your expression gobbles up your entire line. Then it realizes that there are other patterns/characters to be matched i.e. the \\]\\s+(.+) and so the regex engine starts backtracking which is expensive.

> has anyone been able to figure out why my original regex is not
> matching?

Your regex is exhausted just before the "Threat" word i.e. your entire regex matches till the character 'T' of 'Threat'. Your use of $ at the end kills off the entire match and hence the engine doesn't report a match.

Also, your use of non-capturing parentheses (?:) confuses me; why use them? I've removed the non-capturing parentheses and added the .* at the end to get something like:

public class ScrapRegexTests {

    public static void main(final String[] args) {
        String hitInput = "[CHAT WINDOW TEXT] [Sun Nov 29 11:34:13] Guardian of Water attacks Kyton's Rebuke [BH] : *hit* : (20 + 108 = 128 : Threat Roll: 3 + 108 = 111)";
        String hitRegex = "^.*\\]\\s+(.+)\\s+attacks\\s+(.+)\\s+:\\s\\*([a-z][a-z]+)\\*\\s+:\\s.*\\+\\s(\\d+)\\s.+\\s+:\\s(.*)";
        
        Pattern pat = Pattern.compile(hitRegex);
        Matcher matcher = pat.matcher(hitInput);
        if(matcher.matches()) {
            System.out.println("Regex matched  : #" + matcher.group(1) + "#");
            System.out.println("Regex matched  : #" + matcher.group(2) + "#");
            System.out.println("Regex matched  : #" + matcher.group(3) + "#");
            System.out.println("Regex matched  : #" + matcher.group(4) + "#");
            System.out.println("Unprocessed String  : #" + matcher.group(5) + "#");
        } else {
            System.out.println("No match found!");
        }
    }

}
~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

"Almost refuses to start up" is not so good a description. Have you analyzed your logs? Any stack traces/warnings? Are you deploying your application from eclipse or by firing off the shell script? <listener> is a standard tag and so ideally shouldn't any problems. Is the JAR with the class AxisHTTPSessionListener present in your WEB-INF/lib directory?

The only time I've seen applications break after updates is when they relied on libraries placed in the Tomcat lib directory rather than the WEB-INF/lib directory.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

Also make sure that you override the hashCode method for your custom class to satisfy the hash code contract.

~s.o.s~ 2,560 Failure as a human Team Colleague Featured Poster

You could certainly make the JAR path configurable and then load the class by dynamically creating a class and invoking the method using reflection but it has a few disadvantages:
- Reflection is slow, at least slower than normal method calls.
- Too many assumptions, assuming the name of class, the name of method. Again this can be configured but still a brittle solution.

The way we normally do this is by coding to an interface e.g. creating an interface called Decryptor which has multiple implementations. Then based on the requirement, we can switch implementations by changing the XML config file (if you are using something like Spring, Guice) or by changing the code which creates a new Decryptor instance.

Another way would be expose this *decryption* implementation using JNDI or bind this implementation bean to JNDI and access the decryption class the same way you access datasources etc. You'd have to probably do the binding stuff when the application initializes; I'll leave the specifics to you though.

HTH