I have just started working on an existing Wicket application that uses Hibernate. I am adding a RESTful interface to the Hibernate data (in the same web app) using JAX-RS. The JAX-RS servlets don’t talk to Wicket at all—they create Hibernate sessions independently.
I have a class, User, that is defined as a Hibernate entity (that is also JAXB marshallable) using classes from net.databinder.auth.data:
@Entity
@Table(name = "user")
@XmlAccessorType(XmlAccessType.PROPERTY)
@XmlRootElement
public class User extends AbstractEntity implements DataUser {
Everything was working fine, until I tried to add setting the password (BasicPassword is an embeddable net.databinder.auth.data type) to my RESTful interface (until now, I was ignoring the password property):
@XmlTransient
public void setPassword(BasicPassword password) {
this.password = password;
}
@XmlElement
public void setPassword(String password) {
setPassword(new BasicPassword(password));
}
Suddenly, when Apache CXF-JAXRS + Jackson + JAXB tries to ummarshall my incoming JSON user object in an HTTP PUT, it calls user.setPassword("...") and I get the following error:
WARN - ApplicationExceptionMapper - WebApplicationException has been caught : There is no application attached to current thread "http-bio-8080"-exec-5 (through reference chain: com.example.entity.User["password"])
Whoa—where did Wicket come in? Apache CXF-JAXRS should be invoking the Jackson provider, which uses the JAXB annotations to unmarshal my incoming user specification, creating an unbound Hibernate User object, right? It tries to set the password with a string, and the convenience method turns the string into a BasicPassword instance. None of this, as far as I can see, has anything to do with Wicket.
Why is Wicket even involved here? I don’t want or need Wicket at this point—I just need to create a new detached Hibernate object.
BasicPasswordrequires access to authorization settings of Wicket application in order to compute password hash. I guess you need to pass these requests throughWicketFilteras well.