Search code examples
javahibernatestruts

Hibernate Mapping new columns causing login failure


I have inherited a struts and hibernate application. We needed to alter a table to include some additional columns. I ran a alter Table script to add the columns manually. I added additional column properties to my model java file as well as to my hibermate hbm file.

However, when I compile and run the application it starts just fine. But I get an error when logging in to my application.

If I remove the property tags from the hbm I can log in with no issue. When the new property tags are present in the hbm it fails at login. What am I missing here? I've tried recompiling the application, but it doesn't appear to have any effect.

EDIT This is the only stack trace that I'm getting, which is output to my screen not in tomcat or any other loggers that are set up for the application.

javax.servlet.jsp.JspException: Define tag cannot set a null value
at org.apache.struts.taglib.bean.DefineTag.doEndTag(DefineTag.java:236)
at org.apache.jsp.pages.v2.Main_jsp._jspService(Main_jsp.java:391)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at controller.LoginServlet.doPost(LoginServlet.java:233)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.bureaueye.beacon.filter.PerformanceLogFilter.doFilter(PerformanceLogFilter.java:119)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:879)
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:600)
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1703)
at java.lang.Thread.run(Thread.java:662)

I've been doing some digging and found that I'm using hibernate 3, and that in my hiberbate.cfg.xml file I did not have this property in my configureation, however, adding it does not seem to have made any difference.

<property name="hibernate.hbm2ddl.auto">validate</property>

I'm also finding a .hibernateSynchronizer3 directory but I'm not sure if that is effecting anything.


Solution

  • Having inherited the project I was attempting to follow conventions that I saw previously established in the project. Comments in the Class that the new properties were being mapped to indicated not to change the file manually since they would be lost due to any changes in the mapping files.
    That warning would make sense if the <property name="hibernate.hbm2ddl.auto">validate</property> was actually configured and working correctly. It would have added those new properties accordingly. However, those automatic changes did not just happen. Therefore I attempted to manually add the getter/setter methods following the conventions that were in that class file. The application would start, albeit it was failing to establish connection to the datapool. Those exceptions were being caught and not exposed to loggers. After placing breakpoints into various files I finally found that the getter and setter methods I wrote were not named in a way that hibernate was expecting them. After changing the method names to match what Hibernate was expecting, I was able to start my application and log in successfully.