Andles Jurgen

Ranch Hand
+ Follow
since Mar 18, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Andles Jurgen

Heres my take on all this:

First up, lots of JSTL in a jsp does ont constitue a scriptless page. Its just scripting with a different syntax, a syntax that is not java and requires one more thing for a java developer to learn.

There's no point getting all negative on scripting and then dumping a whole buch of JSTL in the page, its just as bad, if not worse. JSTL only makes sense if the person doing it is a page author or designer that does not know java, or if the person doing is expecting the page to in the future be edited by such a person. Even then I think its a hassle fo rthat page author as it it makes the code seem more HTML'ish and creates a lesser distinction between what is obviusly logic and what is obviuosly mark-up. Any benefit of JSTL here is minimal uless the page author is working closely with the page author and the page author unserstand the ramifications of editing the JSTL.


JSTL has a place I guess, but I personally do not like it at all. My pages have minimal scriping in them anyway, and the few sriptlets I had in a page allowed me all the control I needed in a language I was comfortable with. Now I feel guilty if I add some java to my java based web pages - stupid.
15 years ago
JSP
You guys may or may not know that Coldfusion is now basically a j2ee based scripting layer (CF is all written in java and CF pages compile to java byte-code)

I have been doing CF, along with JSP, for a few years now. Recently, due to what I perceive as a lack of demand for CF, I have begun to think about dropping CF and using PHP as my second language (second to Java/JSP)

My question is, is CF still a valid / viable technology these days? I have seen many threads around the web saying that CF is old hat and on its last legs, is this a common belief? I see many strong reasons to think so given that J2EE and .NET compete and PHP seems to be there for those not needing to standardise on either of these two. Is coldfusion going to become a legacy way of doing web aps?

Any opinions welcome.
15 years ago
JSP
I keep getting the following error when deploying a working JSF app on Tomcat 5.5:

javax.servlet.ServletException: Servlet.init() for servlet Faces Servlet threw exception


The app works just fine in Tomcat 5 and is configured correctly. I develp with JBuilder and run tomcat 5 for testing through JBuilder. Then, when I fire up Tomcat 5.5, it fails. (no port issues, nothing like that) I ma not using shared folder, just the web-inf/lib folder for all the needed api's.

any ideas, I am all out?
15 years ago
JSF
re:
One thing I'd very much recommend is get the Hibernate source for whichever version you are using and step through it in your debugger.

Been there, done that. No luck whatsoever. Seriously, this has gottent o the the point where we should have just went commericial (and will likely still end up doing) as it is just not behaving as we expected it too.

It certainly seems to be a recurring problem and there seems to be quite a few folk out there that have given up and/or have yet to resolve the issue - so I do not believe it is an issue specific to our environment. (we have tried several of those too)


Technical competence is not the issue here either. We have spiked several others, just to see if we could get them going - sure enough, no dramas at all. TopLink was a pest, a good 4 hours to get that happening, and a few others were a little tricky without a visist to the appropriate web site or user community, but they worked within 1 day.


I would love to know how many people just gave up on Hibernate but never bothered to let us all know why. I'd bet this relatively simple task of getting hibernate to use your chosen database access/connection could have had something to do with quite a few of them? We even considered at one point going prod without a JNDI DataSource, how many others just gave up in this fashion too?


The fact remains - I like Hibernate for so many reasons. If somebody could jus tell me why we cant for the life of us get it to work properly with a DataSource or simply say "Hey, it doesn't work with a Tomcat DataSource" - life would be much better!
Here are the 3 key parts to the error we get when trying to use Hibernate with Tomcats JNDI feature:

Cannot create JDBC driver of class '' for connect URL 'null'
Caused by: java.sql.SQLException: No suitable driver
net.sf.hibernate.exception.GenericJDBCException: Cannot open connection



Tomcats read only JNDI conetxt works just fine. The following code satisfied me in this regard:

<%
String success = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/ora");
success = "yayyy";
System.out.println("Success: " + ds.toString());
}
catch (Exception e) {
success = "oh shit - here we go again";
}
%>

<%= success %>


Here is the relevant portion of sever.xml. To rule out a whole catagory of post responses, we have tried having the location of this file in both the web application's own context.xml and in the global server.xml.

<resource name="jdbc/ora" auth="container" type="javax.sql.DataSource">
<resourceParams>
<paramter>
<name>driverClassName</name>
<value>oracle.jdbc.OracleDriver</value>
</paramter>
<paramter>
<name>url</name>
<value>jdbc racle:thin:@localhost:1521 RCL</value>
</paramter>
<paramter>
<name>username</name>
<value>store</value>
</paramter>
<paramter>
<name>password</name>
<value>store_password</value>
</paramter>
<paramter>
<name>maxActive</name>
<value>20</value>
</paramter>
<paramter>
<name>maxIdle</name>
<value>30000</value>
</paramter>
<paramter>
<name>maxWait</name>
<value>100</value>
</paramter>
</resourceParams>
</resource>

As you would expect, the relevant section of web.xml ammended with a few variations of the following (With and without 'sharable' etc):

<resource-ref>
<res-ref-name>jdbc/ora</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

Here is the hibernate.cfg. This has been tried with the session-factory name attribute removed and with various other combinations of elements - this should be all that is needed however.:

<session-factory name="java:comp/env/hibernate/SessionFactory">
<!-- properties java:/comp/env/-->
<property name="connection.datasource">java:/comp/env/jdbc/ora</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle</property>
<property name="show_sql">false</property>

<!-- mapping files -->
<mapping resource="hiberTest/persisted/assessment.hbm.xml"/>
<mapping resource="hiberTest/persisted/testtaker.hbm.xml"/>
<mapping resource="hiberTest/persisted/testtakerAssessment.hbm.xml"/>

</session-factory>


There are no conflicts, typos, or clashing .properties files on the classpath, or anything in the world that should prevent Hibernate using our JNDI wired DataSource. I fully expect any and every response to reiterate something we have already tried, and tried with at tleast 2 tomcat versions on more than 4 different occasions in isolation and in combination with other suggestions. Pessimistic, I know. We said we would give the issue a month and then drop Hibernate for something that will work as we need it too - that gives us appox 3 days to sort it out. Its not looking good.
Been there, done that. No luck whatsoever.

re: umbrage

Not sure what 'umbrage' actually means. But I guess you took offense (umbrage?) to my 'real apps' comment. I didn't mean that quite the way it sounded - though I must confess, I have very little idea about Hibernates popularity or how widespread it is - I guess I am influenced a little by some commercial ORM tools we have used. Certainly didn't mean to umbrage you.

At the end of the day though, when a product takes near a month to get it working, and it still doesn't work the way you were told it would - yes, its more than just a little frustrating. Yes, it is open source, but it has certainly cost us in very real austrlain dollars so far. And got us practically nowhere that we needed to be.
Yes, just a typo in my post - the file iteslf is correct.

I am still having no luck getting Hibernate to see the Tomcat configured JNDI resource. Yet, the DataSource works as expected using straight JDBC in code.

You are right, the username and passowrd stuf should all be irrelavant as this is part of the DataSource config - I added it and un-added it and did god knows what else in an attempt to get it to work - NO LUCK AT ALL!

I have reverted back to using a configured Driver instead of a Datasource, but this is just not good enough. Its been a few weeks now since we have been evaluating Hibernate and nobody here is happy with this issue or the lack of a solution - so we will very likely end up using TopLink via JDeveloper in production.

Perhaps Hibernate is just not ready for real apps just yet - I see so many posts from people who simply cannot get the thing to even work!
Is it best to model all many-to-many relationships using 2 one-to-many relationships either side? (which I like, very simple to set up)

I am reading 'Hibernate In Action' and I am struggling to make much sense of the more 'exotic' many-to-many mapping options - the book seems to suggest avoiding these more 'exotic' options. Just wondering, what is the point of the other alternatives to 2 one-to-many mappings? What do you gain with them?

TIA
When to do bi-directional associations? For example, an auction Item/Bid one-to-many relationship, why would the Bid need to know about the Item?
Could I not just manage the bid via the Item class?

I guess what I am asking is "Which types of cases require a bidirectional relationship and why?"

While I am at it - could anybody put a plain english spin on what the 'inverse' attribute is all about? More interestingly, what would be the ramifications of not using the 'inverse' attribute in a case that shoud really use it - my understanding is that Hibernate would simply worl less efficiently asit would do 2, instead of 1, SQL query?
Yeah, all working now. I did not know you needed to start a transaction - used to the auto-commit being switched off.

I was using flush() because the "Professional Hibernate" book told me to.

Had I been using MySql I do not think I would have had this issue - all the examples I have read and seen use Hibernate - but Oracle had auto commit switched off and that kinda threw me.

When I saw the ? in the hibernate generated SQL I thought only half the job was being done and that I had done something wrong in my mapping file(because I didn't see where the 'PreparedStatement' class substitutions were being done.) By the way, why do I not see these setXXX() calls? Because it's not relavant, not efficient???

Thanks for the help guys.
That seemed to be it. Not sure why I have to be in a transaction to get it to work, the docs and all examples I have seen say nothing about this as being a requirement.

Probarbly because Oracle auto-comitt is switched off - does that make sense?
Generated sql:
Hibernate: select hibernate_sequence.nextval from dual
Hibernate: insert into PERSON (name, address, id) values (?, ?, ?)

Everything seems to be working - no errors at all. But my class is not being saved to the database! I get the session, do the save, the flush etc - but no action in the database itself.

Should I not be seeing the actual SQL and not the ? ? ? business? My class is folowing all the right rules (private members, no arg constructor etc

CODE:

Person person1 = new Person();
person1.setName("Basil Fawlty");
person1.setAddress("Fawlty Towers, UK");


try {
Session session = HibernateUtil.currentSession();
session.save(person1);
session.flush();
HibernateUtil.closeSession();

} catch (Exception ex) {
System.out.println("Problem with servlet code: " + ex.getMessage());
}


help appreciated.
Talking to myself a bit now, I know:

I have managed to get Hibernate working, but only using the driver class property. I want it to work with my tomcat defined JNDI datasource and I am expecting something like the following to work:

hibernate.connection.datasource = java:comp/env/jdbc/webApps
hibernate.connection.username = fedup
hibernate.connection.password = *****

My JNDI is set up correctly, I can connect using other hibernate options (non jndi), I have tried many configurations over the last 2 days, and I can only afford to plod on one more day before switching over to toplink (with our jdeveloper/oracle license) as I have had success withing ten minutes with using this product.
Just an update:
I can get it going now using a Driver_class property, but NOT with a datasource property. I want to use my datasource set up though.

I have to say. the documentation for this stuff is very misleading and not at all clear. Even reading 'professional Hibernate" is very weak on set up. (Actually that whole book is a bit of a joke -there isn't an ounce of source code in there that would comiple and th etypos and grammar is the worst I have ever seen - and I have read a LOT of tech books!)

Anyway, I am starting to see a few places I may be going wrong - for example having a driver_class AND a datasource property was likely not a clever thing to do!

Getting closer....
Sorry - heres my resource declareation in server.xml and the relavant web.xml

SERVER.XML

<resource name="jdbc/webApps" auth="container" type="javax.sql.DataSource">
<resourceParams>

<paramter>
<name>driverClassName</name>
<value>oracle.jdbc.OracleDriver</value>
</paramter>

<paramter>
<name>url</name>
<value>jdbc racle:thin:@localhost:1521 RCL</value>
</paramter>

<paramter>
<name>store</name>
<value></value>
</paramter>

<paramter>
<name>store_password</name>
<value></value>
</paramter>

<paramter>
<name>maxActive</name>
<value>20</value>
</paramter>

<paramter>
<name>maxIdle</name>
<value>30000</value>
</paramter>

<paramter>
<name>maxWait</name>
<value>100</value>
</paramter>

</resourceParams>

</resource>


WEB.XML


<res-ref-name>jdbc/webApps</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>