Hello, After a very frustrating day I still haven't got Amber to work as it should on Resin 3.1.5. I have managed to get my examples to read things out of the databases and update objects from data (and vice-versa) already in the databases and this works beautifully. However, whenever I try to write a new object into the databases, I get an NPE:
====== java.lang.NullPointerException at com.caucho.sql.UserPreparedStatement.<init>(UserPreparedStatement.java:66) at com.caucho.sql.UserPreparedStatement.<init>(UserPreparedStatement.java:72) at com.caucho.sql.UserConnection.prepareStatement(UserConnection.java:319) at com.caucho.amber.manager.AmberConnection.prepareInsertStatement(AmberConnection.java:2109) at tests.TestObject.__caucho_create(TestObject.java) at tests.TestObject.__caucho_flush(TestObject.java) at com.caucho.amber.manager.AmberConnection.flushInternal(AmberConnection.java:2959) at com.caucho.amber.manager.AmberConnection.beforeCommit(AmberConnection.java:1788) at com.caucho.amber.manager.AmberConnection$EntityTransactionImpl.commit(AmberConnection.java:3457) at example.TestServlet.service(TestServlet.java:64) at javax.servlet.http.HttpServlet.service(HttpServlet.java:91) at com.caucho.server.dispatch.ServletFilterChain.doFilter(ServletFilterChain.java:103) at com.caucho.server.webapp.WebAppFilterChain.doFilter(WebAppFilterChain.java:181) at com.caucho.server.dispatch.ServletInvocation.service(ServletInvocation.java:266) at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:269) at com.caucho.server.port.TcpConnection.run(TcpConnection.java:603) at com.caucho.util.ThreadPool$Item.runTasks(ThreadPool.java:721) at com.caucho.util.ThreadPool$Item.run(ThreadPool.java:643) at java.lang.Thread.run(Thread.java:619) ====== This is what I'm doing in a Servlet's service method: ====== _entityManager.getTransaction().begin(); TestObject to = new TestObject(); to.setPrimaryHostname("test.myserver.com"); to.setPrimaryIP("192.168.0.10"); _entityManager.persist(to); // this is the problem line _entityManager.getTransaction().commit(); ====== and if I comment out the penultimate line I have no problem, so it is just the _entityManager.persist(to) invocation that causing the problem. If I persist() any object already in the database that works without exception (though granted it is not necessary to do this since it happens automatically at commit). My TestObject class is quite simple: ====== package tests; import java.util.Collection; import javax.persistence.*; @Entity @Table(name="servers") public class TestObject { @Id private int id; private String primaryHostname; private String primaryIP; // and then just setters/getters for those properties } ====== I'm quite perplexed... everything I try doesn't seem to work. The examples delivered on the Caucho website also fail in this respect, any time they invoke persist(). [As a side note, the examples in the Amber section on the Caucho site are wrong in many places too, like inconsistent database names, wrong files for the demos etc. though that's an entirely separate matter]. So, is there something obviously wrong with what I'm doing or is this a bug? If the latter, any idea when there will be a fix? Time permitting, I can look into a fix myself. It looks like it might be something to do with the UserPreparedStatement constructor meeting an unexpectedly null database Connection, but that's just a guess from a brief look at the source. Thanks for your consideration, Charles. _______________________________________________ resin-interest mailing list resin-interest@caucho.com http://maillist.caucho.com/mailman/listinfo/resin-interest