[英]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&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.