spring3+struts2+JPA配置时出现 Unable to find file 警告,求解答。

YYZhQ 2012-04-21 05:58:37
2012-04-21 16:51:10,984 WARN org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements:61 - Unable to find file (ignored): jndi:/localhost/yesplm2/
java.io.FileNotFoundException: jndi:/localhost/yesplm2/
at org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:385)
at java.net.URL.openStream(URL.java:1009)
at org.hibernate.ejb.packaging.InputStreamZippedJarVisitor.doProcessElements(InputStreamZippedJarVisitor.java:57)
at org.hibernate.ejb.packaging.AbstractJarVisitor.getMatchingEntries(AbstractJarVisitor.java:146)
at org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(NativeScanner.java:128)
at org.hibernate.ejb.Ejb3Configuration.addScannedEntries(Ejb3Configuration.java:467)
at org.hibernate.ejb.Ejb3Configuration.scanForClasses(Ejb3Configuration.java:828)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:582)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:72)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:225)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeansOfType(DefaultListableBeanFactory.java:398)
at org.springframework.beans.factory.BeanFactoryUtils.beansOfTypeIncludingAncestors(BeanFactoryUtils.java:275)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.detectPersistenceExceptionTranslators(PersistenceExceptionTranslationInterceptor.java:139)
at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.<init>(PersistenceExceptionTranslationInterceptor.java:79)
at org.springframework.dao.annotation.PersistenceExceptionTranslationAdvisor.<init>(PersistenceExceptionTranslationAdvisor.java:70)
at org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor.setBeanFactory(PersistenceExceptionTranslationPostProcessor.java:99)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeAwareMethods(AbstractAutowireCapableBeanFactory.java:1439)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1408)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:710)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:410)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:895)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
2012-04-21 16:51:12,921 INFO org.hibernate.tool.hbm2ddl.SchemaValidator.validate:121 - Running schema validator
2012-04-21 16:51:12,921 INFO org.hibernate.tool.hbm2ddl.SchemaValidator.validate:129 - fetching database metadata
2012-04-21 16:51:12,968 INFO org.hibernate.tool.hbm2ddl.TableMetadata.<init>:65 - table found: yespm.person
2012-04-21 16:51:12,968 INFO org.hibernate.tool.hbm2ddl.TableMetadata.<init>:66 - columns: [first_name, last_name, emplid]


求解答。

...全文
277 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
YYZhQ 2012-07-05
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 的回复:]
我也遇到了相同的问题,查了 n 久找不到答案,看源码也没头绪,看前面提到的帖子也不知道怎么办
最后无意中的解决:
把 persistence.xml 移到默认的 src/META-INF 下面
并把 applicationContext.xml 里的配置去掉就好了
[/Quote]
不知道你的配置是怎么做的,我的persistence.xml原本就在src/META-INF 下
junglezax 2012-06-19
  • 打赏
  • 举报
回复
我也遇到了相同的问题,查了 n 久找不到答案,看源码也没头绪,看前面提到的帖子也不知道怎么办
最后无意中的解决:
把 persistence.xml 移到默认的 src/META-INF 下面
并把 applicationContext.xml 里的配置去掉就好了
YYZhQ 2012-05-03
  • 打赏
  • 举报
回复
还是找不到原因,也不能老挂在这儿,准备结贴散分,答者有分吧。
YYZhQ 2012-04-27
  • 打赏
  • 举报
回复
这个警告很明显,知道是什么意思,可是却并不知道是什么原因。
to:cseu
里面并没有类似的配置,这用的是Bruce Phillips 提供的一个例子:
http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html,后来在其另一个例子中提到了这个问题:http://www.brucephillips.name/blog/index.cfm/2010/12/28/Recommended-Way-To-Structure-A-Spring-3-JPA-2-and-Maven-Web-Application。他在里面提到:I think this is from a bug in the Hibernate code, as the application works fine. I researched the error on the internet and only found one reference that might be applicable (see reference 3). But if anyone has more insight on why this warning is generated and if there is something I need to configure differently please comment.
他认为是hibernate的bug,同时也引用了他提到的从网上找到的同样问题的描述(reference 3),链接如下:感兴趣的可以看一下:http://community.jboss.org/message/548971。这个问题我最终仍不能解决,现在换了配置方法,参照的是springside的配置,现在没有问题了,但究竟是何原因出现的这个问题,仍是不解中。
yjflinchong 2012-04-27
  • 打赏
  • 举报
回复
地址错误。 目录找不到
chkaka 2012-04-25
  • 打赏
  • 举报
回复
java.io.FileNotFoundException: jndi:/localhost/yesplm2/
文件找不到
cseu 2012-04-24
  • 打赏
  • 举报
回复
请检查你的persistence.xml的配置有没有更新。
看这个报错很可能是persistence里配置了<jar-file>jndi:/localhost/yesplm2/</jar-file>
a312983516 2012-04-24
  • 打赏
  • 举报
回复
java.io.FileNotFoundException: jndi:/localhost/yesplm2/

找不到路径
YYZhQ 2012-04-23
  • 打赏
  • 举报
回复
没人知道吗?配置文件如下:
WEB-INF/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/javaeehttp://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="struts2springjpa" version="2.5">
<display-name>Struts 2 Spring JPA Example</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>

META-INF/persistence.xml

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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/persistencehttp://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<!-- this persistence unit is for the web application -->
<persistence-unit name="springJpaPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>java:comp/env/jdbc/yespm</non-jta-data-source>

<class>com.yesrj.ppm.global.system.model.Person</class>

<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.use_sql_comments" value="true" />
<!--
<property name="hibernate.connection.provider_class" value="org.hibernate.connection.ProxoolConnectionProvider"/>
<property name="hibernate.proxool.pool_alias" value="MysqlPool"/>
<property name="hibernate.proxool.xml" value="proxool.xml"/>
-->
</properties>
</persistence-unit>

</persistence>

META-INF/proxool.xml

<?xml version="1.0" encoding="utf-8"?>
<something-else-entirely>
<proxool>
<alias>MysqlPool</alias>

<driver-url>jdbc:mysql://localhost:3306/yespm</driver-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<driver-properties>
<property name="user" value="root" />
<property name="password" value="root" />
</driver-properties>

<house-keeping-sleep-time>90000</house-keeping-sleep-time>
<prototype-count>5</prototype-count>
<maximum-connection-count>100</maximum-connection-count>
<minimum-connection-count>10</minimum-connection-count>
</proxool>
</something-else-entirely>


WEB-INF/classes/applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- scans the classpath for annotated components (including @Repostory
and @Service that will be auto-registered as Spring beans -->
<context:component-scan base-package="com.yesrj.ppm.global.system" />

<!-- methods or classes needing to run in a complete transaction will
be annotated with Transactional -->
<tx:annotation-driven />

<!-- Creates a data source that can provide a connection to in-memory embedded database populated
with test data
see: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/ch12s08.html -->

<!-- This will ensure that hibernate or jpa exceptions are automatically translated into
Spring's generic DataAccessException hierarchy for those classes annotated with Repository
For example see PersonDaoJpa-->
<bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

<!-- JPA Entity Manager Factory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceXmlLocation" value="META-INF/persistence.xml" />
<property name="persistenceUnitName" value="springJpaPersistenceUnit" />
</bean>

<!-- bean post-processor for JPA annotations -->
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" />


<!-- Transaction Config -->
<bean id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<!-- use declarative transaction management -->
<tx:annotation-driven transaction-manager="transactionManager"/>

</beans>


WEB-INF/classes/struts.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

<constant name="struts.devMode" value="true" />

<package name="system" extends="struts-default">

<interceptors>
<interceptor-stack name="appDefaultStack">
<interceptor-ref name="defaultStack">
<param name="exception.logEnabled">true</param>
<param name="exception.logLevel">ERROR</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>

<default-interceptor-ref name="appDefaultStack" />

<global-results>
<result name="error">/error.jsp</result>
</global-results>


<global-exception-mappings>
<exception-mapping exception="java.lang.Exception"
result="error" />
</global-exception-mappings>

<action name="personFinder"
class="com.yesrj.plm2.global.system.action.PersonFinder" method="execute">
<result name="success">/personinfo.jsp</result>
</action>

<action name="allPersonsFinder"
class="com.yesrj.plm2.global.system.action.AllPersonsFinder" method="execute">

<result name="success">/personsinfo.jsp</result>

</action>

<action name="*PersonUpdate"
class="com.yesrj.plm2.global.system.action.PersonUpdater" method="{1}">

<result name="input">/inputpersonupdate.jsp</result>
<result name="success">/personupdated.jsp</result>

</action>

<action name="personDelete"
class="com.yesrj.plm2.global.system.action.PersonDeleter" method="execute">

<result name="success">/persondeleted.jsp</result>

</action>

<action name="*PersonSave" class="com.yesrj.plm2.global.system.action.PersonSaver"
method="{1}">

<result name="input">/inputpersonsave.jsp</result>
<result name="success">/personsaved.jsp</result>

</action>

</package>

</struts>


WEB-INF/classes/下还有log4j.xml和log4j.dtd,跟它们应该没关系吧。

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧