Russell Bateman

Ranch Hand
+ Follow
since Feb 26, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Russell Bateman

(Sorry right, in my actual code, I'm not doing that. Thanks.)
11 years ago
After cracking Eckel's Thinking in Java, I am reminded that all I was looking for was

Sorry about wasting everyone's time.

Thanks.
11 years ago
I know this is a pretty beginning Java question and if I knew what to call it, I could simply Google for the answer. If I have a class A that's going to be a "subset" of other classes B, C and probably others...

How do I code class B (and C, etc.) such that...

(Please answer the question in the comment above.)

Profuse thanks for taking pity on an old C programmer still too often struggling with the concepts.

Russ
11 years ago
Profuse thanks. Both these responses were useful to me and it all makes complete sense now. I had only direct experience in using Hibernate atop MySQL, apparently an easier thing to do. Thanks again, friends!
Folks, I have just switched the underlying database from MySQL to PostgreSQL (corporate requirement) and now my reads work fine, but my writes do not. In other words:
...throws

org.hibernate.exception.SQLGrammarException: could not get next sequence value


In the Eclipse debugger, examining HibernateException, I see:

(exception) SQLGrammarException
(cause) PSQLException
(detailMessage) "could not get next sequence value"
(sql) "select nextval( 'hibernate_sequence' )"


Now, I am able to throw anything I try into the database by hand (via psql). There is no problem of privilege. And, as I say, I can read out (via Hibernate Criteria) anything I like and do same using psql. I will confess I have no experience so far in switching Hibernate dialects and this is the first time I've used PostgreSQL.

I have created a very minimal table, Fun, to see if I'm using some columns wrong in the eyes of PostgreSQL, but no matter if I reduce the object to just a single, integer field, I still get this, so it's not about using some bizarre thing like DATE, TIMESTAMP or even some OneToOne, OneToMany, etc. construct incorrectly.

(FYI) hibernate.cfg.xml:

(used to be)

I thought there wouldn't be too much to do beyond this configuration switcheroo. I'd be grateful if anyone could point me somewhere to go.

Much thanks,

Russ Bateman
Hmmm... JavaRanch doesn't seem to be a heavily Mockito-inspired place. I ended up posting to stackoverflow and then to mockito@googlegroups.com. I asked the latter to post his answer to the former forum for better visibility. Here's the answer I got:

http://stackoverflow.com/questions/7584518/mockito-when-problem

Thanks anyway. (JavaRanch is a great forum notwithstanding!) I thought it would be nice to post this for the next guy.

Best,

Russ
13 years ago
I'm struggling trying to teach myself Mockito.

Consider the following method, hasInventory(), which should not really run in my way of thinking, but get set up to return true or false as I squirrel-cage my test. Class Warehouse is my "mocked-dependency".


In the JUnit test code, the first when() throws an exception because it literally interprets the method call (executing it) and, inventory being nil (see above), InventoryDoesNotExistException is thrown. There are other methods in the mocked-dependency class too, like add() and remove().

As I understand it, by the when() method, I'm asking Mockito precisely not to call hasInventory(), but just to return true instead whenever it's called as I test the class ("systemUnderTest"). Can anyone help me get past this point (or get some sense into my brain)?

I'm linking mockito-all-1.8.5.jar and JUnit 4.

Copious thanks to all who read this.

Russ
13 years ago
Ah, okay. That's right. I know about the names, but I didn't even notice it--only the question.
13 years ago
JSF
I can offer some work I've been doing lately in order to overcome Facelets difficulties I've had. Peruse if you wish Simple JSF Facelets Project and two other articles it refers to.

Best of luck,

Russ
13 years ago
JSF
Not certain why no one has replied. I had what I think is the same problem. Here's what I ended up adding to faces-config.xml that solved the problem for me. Of course, this depends on the library(ies) you're using too.

I'm working on an article about this at Simple JSF Facelets Project. See what you think.
13 years ago
JSF
Yes, I completely hear you. I started Facelets nearly 3 years ago and couldn't ever get anything to work, so I gave up too. However, now I need them for work, so I'm starting again. And, I've succeeded in getting my first example to work which is a great relief.

Of late, I have been working hard on defining JAR sets for JSF and Facelet work--another problem you point out. I've bettered the set of JARs I've long been using for JSF work (where I've only been doing .jsp stuff). Now, however, I need Facelets, hence beating my head against the wall (and I can't give up).

I'm not the sharpest pencil in the box, so when I am able to knock down a brick wall, I write about it. You can see what I'm doing right now if you like at http://www.javahotchocolate.com/tutorials/rf-facelets.html. I'll be cleaning this document up, making a proper tutorial of it (since, as you point out, no one else's tutorial actually works). But first, I've got to master the whole templating thing and some other stuff.

Thanks for your suggestions and help.

Best regards,

Russ
13 years ago
JSF
Thanks,

Yes, I'm using Eclipse Java for JEE (so, Eclipse WTP). And, yes, my Dynamic Web Project is configured for JSF 1.2--nothing else relevant is possible.

Sadly, examples of <h:head> ... </h:head> abound all over throughout many tutorials I've played with. In fact, the reason I have these elements in there is precisely because I copied and pasted them from a tutorial. This mixing of JARs is a big problem since tutorials use MyFaces or SunRI or RichFaces (and MyFaces), or PrimeFaces, or... lots of chaos.

Anyway, I excised the jstl libraries. I read somewhere that their contents were in JSF 2.0 or something like that, so they're not needed (but in the past, not having them has given me grief, maybe because I was working with pre-JSF 2.0?).

Now it's crashing more properly as it attempts to find a resource I've got (or not, as it appears).

Can you tell me...

If I have a reference

where, in fact, is this GIF really supposed to go?

I'm missing some permutations, but you probably understand where I'm going with this question. It's one of best practice as well as where it will work--where should it really go?
13 years ago
JSF
This represents some progress beyond a "why doesn't it render" question I asked some time ago.

My attempted Facelets project uses these libraries that I've been using very successfully to do .jsp sorts of JSF applications:

commons-beanutils-1.8.3.jar
commons-codec-1.4.jar
commons-collections-3.2.1.jar
commons-digester-2.1.jar
commons-discovery-0.4.jar
commons-logging-1.1.1.jar
jsf-facelets-1.1.15.B1.jar
jstl-api-1.2.jar
jstl-impl-1.2.jar
myfaces-api-2.0.3.jar
myfaces-impl-2.0.3.jar
richfaces-api-3.3.3.Final.jar
richfaces-impl-3.3.3.Final.jar
richfaces-ui-3.3.3.Final.jar



I have added...

...to faces-config.xml, which I had not been doing and my .xhtml files were not being rendered, but showing the page sources always resulted in nothing (blank pages). After adding this element to faces-config.xml, I began to get a crash instead of no rendering. (I think this is an improvement?) The exception is

com.sun.facelets.tag.TagException: /guessnumber.xhtml @11,9 <h:head> Tag Library supports namespace: http://java.sun.com/jsf/html, but no tag was defined for name: head



I'm guessing I'm missing a (tag) library? I'm also concerned about mixing the wrong libraries together. (The example I'm sort of following is using Sun RI whereas I'm using MyFaces/RealFaces.

I'm trying to make the leap to using .xhtml and Facelets. I need some guidance here and would greatly appreciate any help anyone can offer.

Much thanks for any help,

Russ Bateman
13 years ago
JSF
White space in properties files up to the first non-white character of the value is immaterial and I've always been anal-retentive about the appearance cum readability of my own, however the important thing to me isn't to debate white space, but to get this working.

I've written working JSF web apps, but I've used Eclipse WTP with ant and not Maven, which I must learn for my job. Maven wants to restore the rather annoyingly deep and tedious Java project directory structure that Eclipse has blessedly conflated over the years. But, the advantages of Maven, especially in a large environment as I'm in, are undeniable. I've been going off a number of Maven/JSF tutorials, all wildly unsuccessful in this very way. The closest I've got so far as been nothing or unrendered output in the result.

Which merely points out that I am not yet master of this whole thing, but have been doing my successful JSF work only off the template of a successful JSF tutorial I used way back and I'm somehow unable to move that success into Maven.

So, I was hoping to coax some understanding out of this experience such that I completely grok what you're pointing out here and which is the real problem.

You're saying that:

PersonBean.java
pages/inputname.jsp (with content)
pages/inputname.jsf (basically zero-length--forestalls a 404)
web.xml (as presently constituted)



—and I've played with an index.jsp forwarding to pages/inputname.jsf or pages/inputname.jsp—isn't going to work no matter what?

That's okay; I'm not partial to what I'm doing here, it's just something I got out of a tutorial that purported to show Maven building a JSF webapp. I just thought, no brainer, I'll use what this guy uses.

Actually, I need to move on to Facelet coverage (built by Maven) after slaying this dragon, something I was reserving as a next step in difficulty.

Sheesh. This seems a little too hard still.

At this point, unless you've got some real concrete suggestions (which I would kill for), I guess it's back to the drawing board to create a new example.

Profuse thanks for this and any other comments (including cat-calls if applicable).

Russ
13 years ago
JSF
Thanks for responding, Cesar.

I've edited my original post to reflect the changes you suggested and rerun several times. There is no change in the result, however. Is there more information I can provide?

Russ
13 years ago
JSF