JBoss Tools Seam Gen逆向工程产品将无法运行,EntityManagerFactory无法绑定

时间:2011-12-23 13:57:59

标签: java eclipse jsf jboss seam

我的软件版本是:

  • Eclipse Indigo SR 1
  • JBoss AS 5.0.1
  • JBoss Tools 3.3.0.v20111020-1412-H45-M4
  • Seam 2.2.2-Final
  • Oracle 11g数据库
  • 最新的ojdbc6.jar驱动程序
  • JDK 1.6.0_16
  • Windows XP

我在Eclipse中连接到我的数据库,创建了一个新的Seam-2项目,并从现有模式中获得了JBoss-Tools逆向工程。我纠正了一些生成的实体对象存在一些问题。现在应用程序将编译并启动,我得到应用程序的“主页”页面,但是当我尝试转到实际提取任何数据的页面时,我得到下面显示的堆栈跟踪。

我也在下面列出了一些源文件。有什么建议?

07:39:49,573 ERROR [viewhandler] Error Rendering View[/CrossRefList.xhtml]
org.jboss.seam.InstantiationException: Could not instantiate Seam component: crossRefList
    at org.jboss.seam.Component.newInstance(Component.java:2170)
    at org.jboss.seam.Component.getInstance(Component.java:2024)
    at org.jboss.seam.Component.getInstance(Component.java:1986)
    at org.jboss.seam.Component.getInstance(Component.java:1980)
    at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:55)
    at org.jboss.seam.Namespace.getComponentInstance(Namespace.java:50)
    at org.jboss.seam.el.SeamELResolver.resolveBase(SeamELResolver.java:148)
    at org.jboss.seam.el.SeamELResolver.getValue(SeamELResolver.java:51)
    at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
    at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
    at org.jboss.el.parser.AstIdentifier.getValue(AstIdentifier.java:44)
    at org.jboss.el.parser.AstValue.getValue(AstValue.java:63)
    at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
    at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
    at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
    at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:201)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:284)
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:154)
    at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:861)
    at org.jboss.seam.ui.util.cdk.RendererBase.renderChild(RendererBase.java:190)
    at org.jboss.seam.ui.util.cdk.RendererBase.renderChildren(RendererBase.java:166)
    at org.jboss.seam.ui.renderkit.DecorateRendererBase.doEncodeChildren(DecorateRendererBase.java:152)
    at org.jboss.seam.ui.util.cdk.RendererBase.encodeChildren(RendererBase.java:92)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
    at org.ajax4jsf.renderkit.RendererBase.renderChild(RendererBase.java:277)
    at org.ajax4jsf.renderkit.RendererBase.renderChildren(RendererBase.java:258)
    at org.richfaces.renderkit.html.SimpleToggleControlTemplate.doEncodeChildren(SimpleToggleControlTemplate.java:301)
    at org.richfaces.renderkit.html.SimpleToggleControlTemplate.doEncodeChildren(SimpleToggleControlTemplate.java:296)
    at org.ajax4jsf.renderkit.RendererBase.encodeChildren(RendererBase.java:120)
    at org.richfaces.renderkit.html.SimpleTogglePanelRenderer.encodeChildren(SimpleTogglePanelRenderer.java:188)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
    at javax.faces.render.Renderer.encodeChildren(Renderer.java:148)
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:930)
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:933)
    at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:592)
    at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:100)
    at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:176)
    at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
    at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
    at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
    at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:206)
    at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
    at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:388)
    at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:515)
    at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:60)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
    at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
    at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    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:235)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:433)
    at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
    at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:601)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
    at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.IllegalArgumentException: EntityManagerFactory not found in JNDI : java:/PEMEntityManagerFactory
    at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:261)
    at org.jboss.seam.persistence.ManagedPersistenceContext.initEntityManager(ManagedPersistenceContext.java:79)
    at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:108)
    at sun.reflect.GeneratedMethodAccessor387.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
    at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
    at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
    at org.jboss.seam.Component.unwrap(Component.java:2301)
    at org.jboss.seam.Component.getInstance(Component.java:2044)
    at org.jboss.seam.Component.getInstance(Component.java:1986)
    at org.jboss.seam.Component.getInstance(Component.java:1980)
    at org.jboss.seam.Component.getInstance(Component.java:1975)
    at org.jboss.seam.framework.Controller.getComponentInstance(Controller.java:272)
    at org.jboss.seam.framework.PersistenceController.getPersistenceContext(PersistenceController.java:20)
    at org.jboss.seam.framework.EntityQuery.getEntityManager(EntityQuery.java:159)
    at org.jboss.seam.framework.EntityQuery.validate(EntityQuery.java:39)
    at sun.reflect.GeneratedMethodAccessor386.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
    at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
    at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
    at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
    at org.jboss.seam.util.Work.workInTransaction(Work.java:61)
    at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
    at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
    at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
    at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
    at org.jboss.seam.intercept.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
    at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
    at mil.navy.cetars.pem.session.CrossRefList_$$_javassist_seam_3.validate(CrossRefList_$$_javassist_seam_3.java)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
    at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144)
    at org.jboss.seam.Component.callComponentMethod(Component.java:2275)
    at org.jboss.seam.Component.callCreateMethod(Component.java:2198)
    at org.jboss.seam.Component.newInstance(Component.java:2158)
    ... 85 more
Caused by: javax.naming.NameNotFoundException: PEMEntityManagerFactory not bound
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
    at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
    at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
    at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:722)
    at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:682)
    at javax.naming.InitialContext.lookup(InitialContext.java:392)
    at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManagerFactoryFromJndiOrValueBinding(ManagedPersistenceContext.java:257)
    ... 129 more

我的web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>PEM</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.seam</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
    <param-value>Mojarra-1.2</param-value>
  </context-param>
  <context-param>
    <param-name>org.richfaces.SKIN</param-name>
    <param-value>blueSky</param-value>
  </context-param>
  <listener>
    <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
  </listener>
  <filter>
    <filter-name>Seam Filter</filter-name>
    <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>Seam Filter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <servlet>
    <servlet-name>Seam Resource Servlet</servlet-name>
    <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>Seam Resource Servlet</servlet-name>
    <url-pattern>/seam/resource/*</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>facelets.DEVELOPMENT</param-name>
    <param-value>true</param-value>
  </context-param>
  <context-param>
    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
    <param-value>.xhtml</param-value>
  </context-param>
  <security-constraint>
    <display-name>Restrict raw XHTML Documents</display-name>
    <web-resource-collection>
      <web-resource-name>XHTML</web-resource-name>
      <url-pattern>*.xhtml</url-pattern>
    </web-resource-collection>
    <auth-constraint/>
  </security-constraint>
</web-app>

的persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<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_1_0.xsd" 
             version="1.0">

   <persistence-unit name="PEM" transaction-type="JTA">
      <provider>org.hibernate.ejb.HibernatePersistence</provider>

      <jta-data-source>java:/PEMDatasource</jta-data-source>
      <properties>
         <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
         <property name="hibernate.hbm2ddl.auto" value="validate"/>
         <property name="hibernate.show_sql" value="true"/>
         <property name="hibernate.format_sql" value="true"/>
         <property name="hibernate.default_schema" value="PEM"/>
         <property name="jboss.entity.manager.factory.jndi.name" value="java:/PEMEntityManagerFactory"/>
      </properties>
   </persistence-unit>

</persistence>

的JBoss-web.xml中

<!DOCTYPE jboss-web PUBLIC
    "-//JBoss//DTD Web Application 4.2//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
<jboss-web>  
    <class-loading java2ClassLoadingCompliance="false">
        <loader-repository>
            seam.jboss.org:loader=PEM
            <loader-repository-config>java2ParentDelegation=false</loader-repository-config>
        </loader-repository>
    </class-loading>
</jboss-web>

MY-ds.xml中

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE datasources
    PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
    "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
<datasources>

   <local-tx-datasource>
      <jndi-name>PEMDatasource</jndi-name>
      <use-java-context>true</use-java-context>
      <connection-url>jdbc:oracle:thin:@my_db_url:1521:dev</connection-url>
      <driver-class>oracle.jdbc.OracleDriver</driver-class>
      <user-name>MyDBUser</user-name>
      <password>MyDBPass</password>
   </local-tx-datasource>

</datasources>

的components.xml

<?xml version="1.0" encoding="UTF-8"?>
<components xmlns="http://jboss.com/products/seam/components"
            xmlns:core="http://jboss.com/products/seam/core"
            xmlns:persistence="http://jboss.com/products/seam/persistence"
            xmlns:drools="http://jboss.com/products/seam/drools"
            xmlns:bpm="http://jboss.com/products/seam/bpm"
            xmlns:security="http://jboss.com/products/seam/security"
            xmlns:mail="http://jboss.com/products/seam/mail"
            xmlns:web="http://jboss.com/products/seam/web"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation=
                "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.2.xsd
                 http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.2.xsd
                 http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.2.xsd
                 http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.2.xsd
                 http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.2.xsd
                 http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.2.xsd
                 http://jboss.com/products/seam/web http://jboss.com/products/seam/web-2.2.xsd
                 http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.2.xsd">

   <core:init debug="true" jndi-pattern="@jndiPattern@"/> 

   <core:manager concurrent-request-timeout="500"
                 conversation-timeout="120000"
                 conversation-id-parameter="cid"
                 parent-conversation-id-parameter="pid"/>

   <!-- Make sure this URL pattern is the same as that used by the Faces Servlet -->
   <web:hot-deploy-filter url-pattern="*.seam"/>
   <!-- If you are still using JBoss 4, uncomment this to have your PU started -->
<!--    <persistence:entity-manager-factory name="entityManagerFactory"
                      persistence-unit-name="PEM"/>
 -->
    <!-- If you are still using JBoss 4, uncomment this to have the entityManagerFactory ysed -->
<!--    <persistence:managed-persistence-context name="entityManager" auto-create="true"
                          entity-manager-factory="#{entityManagerFactory}"/>
 -->
    <persistence:managed-persistence-context name="entityManager" auto-create="true"
                           persistence-unit-jndi-name="java:/PEMEntityManagerFactory"/>

   <drools:rule-base name="securityRules">
      <drools:rule-files><value>/security.drl</value></drools:rule-files>
   </drools:rule-base>

   <security:rule-based-permission-resolver security-rules="#{securityRules}"/>

   <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>

   <event type="org.jboss.seam.security.notLoggedIn">
      <action execute="#{redirect.captureCurrentView}"/>
   </event>
   <event type="org.jboss.seam.security.loginSuccessful">
      <action execute="#{redirect.returnToCapturedView}"/>
   </event>

   <mail:mail-session host="localhost" port="25"/>

   <!-- For use with jBPM pageflow or process management -->
   <!--
   <bpm:jbpm>
      <bpm:process-definitions></bpm:process-definitions>
      <bpm:pageflow-definitions></bpm:pageflow-definitions>
   </bpm:jbpm>
   -->

</components>

hibernate-console.properties

#File used by hibernate tools to override <datasource> and other container specific settings in persistence.xml
hibernate.connection.password=MyDBPass
hibernate.connection.username=MyDBUser
hibernate.connection.driver_class=oracle.jdbc.OracleDriver
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
hibernate.connection.url=jdbc:oracle:thin:@my_db_url:1521:dev

hibernate.connection.provider_class=org.hibernate.connection.DriverManagerConnectionProvider
hibernate.datasource=
hibernate.transaction.manager_lookup_class=

1 个答案:

答案 0 :(得分:0)

不确定是什么问题,但我得出结论,在Eclipse中使用热代码替换运行JBoss 5.0.1不起作用。我安装了5.1.0用于eclipse开发,以及一个外部独立5.0.1实例,用于在最终部署之前测试我的应用程序。这种情况运作良好。