简体   繁体   English

webapp运行程序错误(NoInitialContextException)

[英]webapp-runner error (NoInitialContextException)

I have a webapp project (in J2EE) that uses Spring and maven. 我有一个使用Spring和maven的webapp项目(在J2EE中)。 Usually I run this project in my Eclipse tomcat (for debugging purposes). 通常,我在Eclipse tomcat中运行此项目(出于调试目的)。 Now I wanna run this in Heroku and I follow the tutorial in https://devcenter.heroku.com/articles/java-webapp-runner 现在我想在Heroku中运行它,并按照https://devcenter.heroku.com/articles/java-webapp-runner中的教程进行操作

But when I run the command java -jar target/dependency/webapp-runner.jar target/*.war the following error is giving me: 但是当我运行命令java -jar target / dependency / webapp-runner.jar target / *。war时,出现以下错误:

javax.naming.NoInitialContextException: Cannot instantiate class: org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException: org.jnp.interfaces.NamingContextFactory]

I have in my project the following files in webapp/WEB-INF: application-context.xml, servlet.xml and web.xml. 我的项目中webapp / WEB-INF中包含以下文件:application-context.xml,servlet.xml和web.xml。 The jndi configuration in application-context is: 在应用程序上下文中的jndi配置为:

<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/standard"/>

How can I fix this error 我该如何解决这个错误

I had the same issue with a spring 3 / tomcat configuration, making it run on heroku, and I just resolved it, I had this in my application-context.xml 我在spring 3 / tomcat配置中遇到了同样的问题,使其在heroku上运行,我刚刚解决了它,我在application-context.xml有此问题

  <bean id="dataSource"
      class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName">
        <value>java:comp/env/jdbc/catWDB</value>
    </property>
</bean>

And a file on src/main/webapp/META-INF/context.xml which had the URL, user, password and other variables. 还有src/main/webapp/META-INF/context.xml上的文件,其中包含URL,用户,密码和其他变量。

I replaced the bean dataSource in application-context.xml with 我将application-context.xml的bean dataSource替换为

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
    <property name="url" value="jdbc:mysql://SERVER:3306/DATA_BASE?zeroDateTimeBehavior=convertToNull&amp;autoReconnect=true"/>
    <property name="username" value="USERNAME"/>
    <property name="password" value="PASSWORD"/>
</bean>

I now I can deploy using heroku's web-app-runner adding this command 现在,我可以使用heroku的web-app-runner添加此命令来进行部署

web: java -jar target/dependency/webapp-runner.jar target/*.war --port $PORT

to the Procfile 到Procfile

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Heroku Webapp运行程序-启用命名 - Heroku webapp-runner --enable-naming Heroku Webapp运行程序JNDI命名,资源不可用 - Heroku webapp-runner JNDI naming, resource not available Java Web App在带有webapp-runner的Heroku上崩溃 - Java Web App Crashes on Heroku with webapp-runner Spymemcached与hibernate-memcached和webapp-runner发生冲突 - Spymemcached conflict with hibernate-memcached and webapp-runner 上下文路径与 webapp-runner 中的 Spring UrlTag 冲突? - Context path conflict with Spring UrlTag in webapp-runner? 需要帮助Java Web App(webapp运行程序,tomcat)heroku(应用程序崩溃) - Need Help Java Web App (webapp-runner, tomcat) heroku (app crashed) 在webapp-runner中运行的对Heroku Web-app的API调用最终失败,并出现google.common中的NoSuchMethodError和NoClassDefFoundError - API calls to Heroku web-app running in webapp-runner eventually fail with NoSuchMethodError then NoClassDefFoundError in google.common 使用&#39;webapp-runner&#39;运行Spring Boot应用后,它在“ INFO:Starting ProtocolHandler [“ http-nio-8080”]”行中停止 - After running Spring boot app with 'webapp-runner' it's stoping on a line “INFO: Starting ProtocolHandler [”http-nio-8080“]” NoInitialContextException 错误的含义 - The meaning of NoInitialContextException error NoInitialContextException错误Tomcat - NoInitialContextException Error Tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM