Why does Eclipse not deploy dependency to Glassfish?

依然范特西╮ 提交于 2019-12-12 13:18:35

问题


I am using Eclipse Helios, Glassfish 3.0.1 (Full Platform) and myfaces 2.0 .

There a two projects in the workspace: A simple Java project (=> JP) and a dynamic web project (=> WP). I added JP to the classpath of WP.

I added one class from JP as a managed bean to the faces-config.xml file of WP.

<managed-bean>
    <managed-bean-name>myBean</managed-bean-name>
    <managed-bean-class>myPackage.MyBean</managed-bean-class>
    <managed-bean-scope>application</managed-bean-scope>
</managed-bean>

When I deploy the package and make a request, an error message is displayed. It says, that the myPackage.MyBean class could not be found.

If I look into WEB-INF/classes directory, of the deployed and running WP project, this directory is empty.

I did not wrote any classes inside WP itself yet, but shouldn't be the classes of JP in that directory?

What can I do to deploy JP together with WP?

Thanks in advance.


回答1:


You need to set the plain Java Project as a module/deployment dependency. In the current Eclipse version (Helios, 3.6) you can do it in Deployment Assembly of the project's properties. In the older versions (Galileo, 3.5 and before) you can do it in Java EE Module Dependencies of the project's properties. It will then end up as a JAR in /WEB-INF/lib.




回答2:


Failing the eclipse tie-in of "Module Dependencies" (or if it all seems complicated) then manually jar the class files of project JP (e.g. as jp.jar) and add the jar to WEB/INF/lib of project WP

this will fix your ClassNotFoundException



来源:https://stackoverflow.com/questions/4044350/why-does-eclipse-not-deploy-dependency-to-glassfish

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!