I’m trying a very simple program to learn vaading. It works with tomcat 7 but fails with jboss wildfly.
I have created this entity:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Entity @Table(name="employee")
public class Employee {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id")
private int id;
@NotNull
@Size(min=3, max=50)
private String name;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}
The class I request:
import javax.servlet.annotation.WebServlet;
import com.vaadin.addon.jpacontainer.JPAContainer;
import com.vaadin.addon.jpacontainer.JPAContainerFactory;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.Label;
import com.vaadin.ui.Table;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
@SuppressWarnings("serial")
@Theme("jpacontainerexercise1")
public class Jpacontainerexercise1UI extends UI {
@WebServlet(value = "/*", asyncSupported = true)
@VaadinServletConfiguration(productionMode = false, ui = Jpacontainerexercise1UI.class)
public static class Servlet extends VaadinServlet {
}
@Override
protected void init(VaadinRequest request) {
JPAContainer<Employee> jpac = JPAContainerFactory.make(Employee.class, "exercice1");
Employee em = new Employee();
em.setName("ThisIsMyName");
int id = (Integer) jpac.addEntity(em);
final VerticalLayout layout = new VerticalLayout();
layout.setMargin(true);
setContent(layout);
layout.addComponent(new Label("Name: " + em.getName()));
layout.addComponent(new Label("ID: " + id));
Table personTable = new Table("The Persistent People", jpac);
personTable.setVisibleColumns(new Object[]{"id","name"});
layout.addComponent(personTable);
}
}
Than added this to ivy.xml
<dependency org="com.vaadin.addon" name="jpacontainer" rev="3.1.1"/>
<dependency org="org.eclipse.persistence" name="eclipselink" rev="2.4.2"/>
<dependency org="org.eclipse.persistence" name="javax.persistence" rev="2.1.0"/>
<dependency org="javax.validation" name="validation-api" rev="1.1.0.Final"/>
<dependency org="org.hibernate" name="hibernate-validator" rev="5.1.0.Final"/>
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.6"/>
<dependency org="mysql" name="mysql-connector-java" rev="5.1.30"/>
The persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="exercice1">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="eclipselink.jdbc.platform" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
<property name="eclipselink.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="eclipselink.jdbc.url" value="jdbc:mysql://localhost/exercise1" />
<property name="eclipselink.jdbc.user" value="root" />
<property name="eclipselink.jdbc.password" value="pwd" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.ddl-generation" value="drop-and-create-tables" />
<property name="eclipselink.ddl-generation.output-mode" value="database" />
</properties>
</persistence-unit>
</persistence
Everything else is the default created by Eclipse vaadin plug-in.
It runs fine with tomcat, showing lables and table (db table is correctely populated). With jboss I get this error:
Context Path: jpacontainerexercise1
Servlet Path:
Path Info: /
Query String:
v-browserDetails=1&theme=jpacontainerexercise1&v-sh=1200&v-sw=1920&v-cw=947&v-ch=629&v-curdate=1397043691201&v-tzo=-120&v-dstd=60&v-rtzo=-60&v-dston=true&v-vw=947&v-vh=0&v-loc=http%3A%2F%2Flocalhost%3A8080%2Fjpacontainerexercise1%2F&v-wn=jpacontainerexercise1-863496467-0.9144240031028977&v-1397043691202
Stack Trace
javax.servlet.ServletException: com.vaadin.server.ServiceException: java.lang.IllegalArgumentException: Object: ThisIsMyName is not a known entity type.
com.vaadin.server.VaadinServlet.service(VaadinServlet.java:240)
javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:61)
io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:61)
io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:70)
io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:76)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:240)
io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:227)
io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:73)
io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:146)
io.undertow.server.Connectors.executeRootHandler(Connectors.java:168)
io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:687)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:744)
Any hint on what is wrong?