いくつかのコードをクリーンアップしてリファクタリングするために、私は新しいワークスペースと新しいプロジェクトを作成しました。プロジェクトの設定は、コアプロジェクト(依存関係管理にMavenを使用するJavaproject)と、コアプロジェクトのコードを共用する2つの動的Webプロジェクト(JSF)(同様の設定はthis SO-Post)です。私は、HibernateとPrimefaceでWildfly 10を使用しています。 私がこれまで行ってきたことは、古い不器用なプロジェクトから新しいコアプロジェクトに不可欠なクラスをコピーして、アプリケーションを起動して実行することです。コードには触れられていないし、私の古い設定でうまくいきました。アプリケーションは、罰金起動し、ログイン・ページに移動しますが、私は、ログインボタンを打つたびに、私は、例外以下の受信:org.hibernate.AnnotationException:不明Id.generator:increment
Caused by: org.hibernate.AnnotationException: Unknown Id.generator: increment
at org.hibernate.cfg.BinderHelper.makeIdGenerator(BinderHelper.java:641)
at org.hibernate.cfg.AnnotationBinder.processId(AnnotationBinder.java:2346)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:2251)
at org.hibernate.cfg.AnnotationBinder.processIdPropertiesIfNotAlready(AnnotationBinder.java:911)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:738)
at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.processEntityHierarchies(AnnotationMetadataSourceProcessorImpl.java:245)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.processEntityHierarchies(MetadataBuildingProcess.java:222)
at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:265)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.metadata(EntityManagerFactoryBuilderImpl.java:847)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:874)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
... 68 more
すべてが細かい注釈されていると正常に動作しているのでorg.hibernate.AnnotationException: Unknown Id.generator: increment
が実際にoccureべきではありません。興味深いことに、DBテーブルは実際には自動的に作成されません。最初は、JPAなどの依存関係の衝突が原因であると思っていました.WebプロジェクトのWEB-INF\lib
フォルダにjboss *やhibernate *などの不必要なjarファイルがあるため、この問題を解決できませんでした。
例のモデルクラス:
@Entity
@Table(name = "user")
@NamedQuery(name = "User.findUserByEmail", query = "select u from User u where u.email = :email")
public class User implements Serializable
{
public static final String FIND_BY_EMAIL = "User.findUserByEmail";
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name = "increment", strategy = "increment")
@Column(name = "PK_user_id")
private int id;
@OneToMany
@JoinColumn(name = "FK_user_id")
private List<ArticleList> articleLists;
@Column(name = "user_email")
private String email;
@Column(name = "user_first_name")
private String firstName;
@Column(name = "user_hashed_password")
private byte[] hashedPassword;
@Column(name = "user_last_name")
private String lastName;
@Enumerated(EnumType.STRING)
@Column(name = "user_role")
private Role role;
@Column(name = "user_salt")
private byte[] salt;
//getters and setters
}
マイpersistence.xmlの
これがなぜ起こるかどれ手がかり?おかげで、すでに事前に
編集:私は@Rohit Gaikwadが述べたように試みたが、今、このエラーを取得:
10:47:36,006 INFO [stdout] (default task-35) Error while running query: org.hibernate.type.SerializationException: could not deserialize
10:47:36,007 ERROR [stderr] (default task-35) javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not deserialize
10:47:36,008 ERROR [stderr] (default task-35) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1692)
10:47:36,008 ERROR [stderr] (default task-35) at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1602)
10:47:36,009 ERROR [stderr] (default task-35) at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:560)
10:47:36,009 ERROR [stderr] (default task-35) at de.jb.toyjo.dao.GenericDAO.findOneResult(GenericDAO.java:130)
10:47:36,010 ERROR [stderr] (default task-35) at de.jb.toyjo.dao.UserDAO.findUserByEmail(UserDAO.java:23)
10:47:36,010 ERROR [stderr] (default task-35) at de.jb.toyjo.facade.UserFacade.isValidLogin(UserFacade.java:14)
10:47:36,011 ERROR [stderr] (default task-35) at de.jb.toyjo.bean.LoginBean.login(LoginBean.java:24)
10:47:36,011 ERROR [stderr] (default task-35) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
10:47:36,011 ERROR [stderr] (default task-35) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
10:47:36,012 ERROR [stderr] (default task-35) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
10:47:36,012 ERROR [stderr] (default task-35) at java.lang.reflect.Method.invoke(Method.java:498)
10:47:36,013 ERROR [stderr] (default task-35) at com.sun.el.util.ReflectionUtil.invokeMethod(ReflectionUtil.java:181)
10:47:36,013 ERROR [stderr] (default task-35) at com.sun.el.parser.AstValue.invoke(AstValue.java:289)
10:47:36,014 ERROR [stderr] (default task-35) at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:304)
10:47:36,014 ERROR [stderr] (default task-35) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
10:47:36,015 ERROR [stderr] (default task-35) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
10:47:36,015 ERROR [stderr] (default task-35) at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:40)
10:47:36,015 ERROR [stderr] (default task-35) at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:50)
10:47:36,016 ERROR [stderr] (default task-35) at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
10:47:36,016 ERROR [stderr] (default task-35) at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:87)
10:47:36,017 ERROR [stderr] (default task-35) at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
10:47:36,017 ERROR [stderr] (default task-35) at javax.faces.component.UICommand.broadcast(UICommand.java:315)
10:47:36,017 ERROR [stderr] (default task-35) at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:790)
10:47:36,018 ERROR [stderr] (default task-35) at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1282)
10:47:36,018 ERROR [stderr] (default task-35) at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
10:47:36,019 ERROR [stderr] (default task-35) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
10:47:36,019 ERROR [stderr] (default task-35) at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
10:47:36,019 ERROR [stderr] (default task-35) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
10:47:36,020 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:85)
10:47:36,020 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
10:47:36,020 ERROR [stderr] (default task-35) at de.jb.toyjo.filter.LoginCheckFilter.doFilter(LoginCheckFilter.java:84)
10:47:36,021 ERROR [stderr] (default task-35) at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
10:47:36,021 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
10:47:36,021 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
10:47:36,022 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
10:47:36,022 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
10:47:36,023 ERROR [stderr] (default task-35) at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
10:47:36,023 ERROR [stderr] (default task-35) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:47:36,023 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:131)
10:47:36,024 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
10:47:36,024 ERROR [stderr] (default task-35) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:47:36,025 ERROR [stderr] (default task-35) at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
10:47:36,025 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
10:47:36,026 ERROR [stderr] (default task-35) at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
10:47:36,026 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
10:47:36,026 ERROR [stderr] (default task-35) at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
10:47:36,027 ERROR [stderr] (default task-35) at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
10:47:36,027 ERROR [stderr] (default task-35) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:47:36,028 ERROR [stderr] (default task-35) at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
10:47:36,028 ERROR [stderr] (default task-35) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:47:36,029 ERROR [stderr] (default task-35) at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
10:47:36,029 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
10:47:36,029 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
10:47:36,030 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
10:47:36,030 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
10:47:36,031 ERROR [stderr] (default task-35) at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
10:47:36,031 ERROR [stderr] (default task-35) at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
10:47:36,032 ERROR [stderr] (default task-35) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:47:36,032 ERROR [stderr] (default task-35) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:47:36,033 ERROR [stderr] (default task-35) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:47:36,033 ERROR [stderr] (default task-35) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:47:36,034 ERROR [stderr] (default task-35) at io.undertow.servlet.api.LegacyThreadSetupActionWrapper$1.call(LegacyThreadSetupActionWrapper.java:44)
10:47:36,034 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
10:47:36,034 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
10:47:36,035 ERROR [stderr] (default task-35) at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
10:47:36,035 ERROR [stderr] (default task-35) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:202)
10:47:36,036 ERROR [stderr] (default task-35) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:805)
10:47:36,036 ERROR [stderr] (default task-35) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
10:47:36,036 ERROR [stderr] (default task-35) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
10:47:36,037 ERROR [stderr] (default task-35) at java.lang.Thread.run(Thread.java:745)
10:47:36,038 ERROR [stderr] (default task-35) Caused by: org.hibernate.type.SerializationException: could not deserialize
10:47:36,038 ERROR [stderr] (default task-35) at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:243)
10:47:36,039 ERROR [stderr] (default task-35) at org.hibernate.internal.util.SerializationHelper.deserialize(SerializationHelper.java:287)
10:47:36,039 ERROR [stderr] (default task-35) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.fromBytes(SerializableTypeDescriptor.java:138)
10:47:36,040 ERROR [stderr] (default task-35) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:113)
10:47:36,040 ERROR [stderr] (default task-35) at org.hibernate.type.descriptor.java.SerializableTypeDescriptor.wrap(SerializableTypeDescriptor.java:27)
10:47:36,040 ERROR [stderr] (default task-35) at org.hibernate.type.descriptor.sql.VarbinaryTypeDescriptor$2.doExtract(VarbinaryTypeDescriptor.java:60)
10:47:36,041 ERROR [stderr] (default task-35) at org.hibernate.type.descriptor.sql.BasicExtractor.extract(BasicExtractor.java:47)
10:47:36,041 ERROR [stderr] (default task-35) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:238)
10:47:36,041 ERROR [stderr] (default task-35) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:234)
10:47:36,042 ERROR [stderr] (default task-35) at org.hibernate.type.AbstractStandardBasicType.nullSafeGet(AbstractStandardBasicType.java:224)
10:47:36,042 ERROR [stderr] (default task-35) at org.hibernate.type.AbstractStandardBasicType.hydrate(AbstractStandardBasicType.java:300)
10:47:36,043 ERROR [stderr] (default task-35) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2738)
10:47:36,043 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1729)
10:47:36,044 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1655)
10:47:36,045 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.getRow(Loader.java:1544)
10:47:36,045 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:727)
10:47:36,046 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.processResultSet(Loader.java:972)
10:47:36,046 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.doQuery(Loader.java:930)
10:47:36,047 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:336)
10:47:36,047 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.doList(Loader.java:2617)
10:47:36,048 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.doList(Loader.java:2600)
10:47:36,049 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2429)
10:47:36,049 ERROR [stderr] (default task-35) at org.hibernate.loader.Loader.list(Loader.java:2424)
10:47:36,050 ERROR [stderr] (default task-35) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:501)
10:47:36,050 ERROR [stderr] (default task-35) at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:371)
10:47:36,051 ERROR [stderr] (default task-35) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:216)
10:47:36,051 ERROR [stderr] (default task-35) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1326)
10:47:36,052 ERROR [stderr] (default task-35) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:87)
10:47:36,052 ERROR [stderr] (default task-35) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:606)
10:47:36,052 ERROR [stderr] (default task-35) at org.hibernate.jpa.internal.QueryImpl.getSingleResult(QueryImpl.java:529)
10:47:36,053 ERROR [stderr] (default task-35) ... 67 more
10:47:36,054 ERROR [stderr] (default task-35) Caused by: java.io.StreamCorruptedException: invalid stream header: 41444D49
10:47:36,055 ERROR [stderr] (default task-35) at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:808)
10:47:36,055 ERROR [stderr] (default task-35) at java.io.ObjectInputStream.<init>(ObjectInputStream.java:301)
10:47:36,055 ERROR [stderr] (default task-35) at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:309)
10:47:36,056 ERROR [stderr] (default task-35) at org.hibernate.internal.util.SerializationHelper$CustomObjectInputStream.<init>(SerializationHelper.java:299)
10:47:36,056 ERROR [stderr] (default task-35) at org.hibernate.internal.util.SerializationHelper.doDeserialize(SerializationHelper.java:218)
10:47:36,057 ERROR [stderr] (default task-35) ... 96 more
どのモデルでは、「インクリメント」プロパティがありますか?あなたのモデルを共有することはできますか? –
私はworklflowのこの段階で唯一の関連するクラスであるUserクラスを追加しました。しかし、私のモデルクラスはすべて同じ '@ GenericGenerator'を持っています。これも私の以前の設定でうまくいきました – JohnPlata
'@ GeneratedValue'を使って試しましたが、デフォルトで' @ GenericGenerator'はありませんでしたか? – coladict