简体   繁体   English

WebSphere + RAD + Taglib

[英]WebSphere + RAD + Taglib

I have a problem developing my application for WebSphere 7. Here's the setup. 我在开发WebSphere 7的应用程序时遇到问题。这是设置。 I have a maven-based project consisting of multiple modules that is developed in RAD 7.5.5.2 我有一个基于maven的项目,由RAD 7.5.5.2开发的多个模块组成

One the modules is a plain web application (war) that uses JSPs and relies on a taglib. 其中一个模块是一个普通的Web应用程序(war),它使用JSP并依赖于taglib。

Taglib itself is the other module - plain java project with just two files, the taglib descriptor and tag file under META-INF/tags. Taglib本身就是另一个模块 - 只有两个文件的普通java项目,即META-INF / tags下的taglib描述符和标记文件。

When I build the taglib jar and manually copy it to WEB-INF/lib of a web application the tag is picked correctly and rendered on the page. 当我构建taglib jar并手动将其复制到Web应用程序的WEB-INF / lib时,标记被正确选取并在页面上呈现。

When I deploy project via RAD - the taglib is not picked up. 当我通过RAD部署项目时 - 没有拾取taglib。 The error says: 错误说:

```
com.ibm.ws.jsp.JspCoreException: JSPG0047E: Unable to locate tag library for uri http://juriy.com/myproject/jsp/my-taglib 
```

The same tag library packaged as JAR and added to WEB-INF/lib works perfectly. 打包为JAR并添加到WEB-INF / lib的相同标记库完美运行。

When I open the WebSphere admin console, I see that the taglib project is recognized by WebSphere. 当我打开WebSphere管理控制台时,我看到WebSphere识别了taglib项目。 However it is not packaged as JAR, instead the path to the project is added to the webapp classpath. 但是它没有打包为JAR,而是将项目的路径添加到webapp类路径中。 In

```
Troublehooting -> Class Loader Viewer -> Module - com.ibm.ws.classloader.CompoundClassLoader
```

I see the entry for my taglib: 我看到我的taglib的条目:

```
file:/D:/Data/MyProject/UIComponents/target/classes
```

In other words it looks like WS doesn't care to package a project as JAR during development cycle and then it is not picked up as a taglib. 换句话说,看起来WS并不关心在开发周期中将项目打包为JAR,然后它不会被选为taglib。

Is there a way to tell RAD (or WebSphere) "Please package this project as JAR before you add it to the classpath"? 有没有办法告诉RAD(或WebSphere)“在将它添加到类路径之前,请将此项目打包为JAR”? Any alternative way to make this setup work is also appreciated. 任何使这种设置工作的替代方法也是值得赞赏的。 I cannot copy jar manually all the time during development - we all want things to work automatically. 我不能在开发过程中一直手动复制jar - 我们都希望事情能够自动运行。

Disclaimer: I'm not a WebSphere expert (only a week working with this beast) and I might have missed some obvious settings. 免责声明:我不是WebSphere专家(只有一周与这个野兽一起工作),我可能错过了一些明显的设置。 Please suggest whatever might solve this issue. 请提出可能解决此问题的建议。

As far as I know RAD is made on eclipse platform. 据我所知,RAD是在eclipse平台上制作的。 I know that with maven you can create artifacts that builds jar files and placed into the local repository. 我知道,使用maven,您可以创建构建jar文件并放入本地存储库的工件。 Other modules could reference that jars via M2_REPO variable. 其他模块可以通过M2_REPO变量引用该罐。 Then you stick with maven and have to use maven plugins to eclipse that help to integrate maven into eclipse. 然后你坚持使用maven并且必须使用maven插件来进行日食,这有助于将maven集成到eclipse中。 But consider the option to configure your project with project builder and ant . 但考虑使用项目构建器和ant配置项目的选项。 Then you could easily run ant targets upon build to make your jars before the deployment. 然后,您可以在构建之前轻松运行ant目标,以便在部署之前制作jar。 This technique is used not only in eclipse IDE but other IDEs. 此技术不仅用于eclipse IDE,还用于其他IDE。 Running ant targets before or after project build is invaluable feature. 在项目构建之前或之后运行ant目标是非常宝贵的功能。

Package your taglib as a maven jar and install it to your local .m2 repository. 将taglib打包为maven jar并将其安装到本地.m2存储库。 Then reference the dependency in the pom for your main project. 然后引用主项目的pom中的依赖项。 It will be pulled in for packaging. 它将被拉入包装。 If it is relsolving for local development it is probably because workspace resolution is turned on. 如果它正在重新进行本地开发,则可能是因为工作区分辨率已打开。

Also, adding jars to the WEB-INF/lib in a Maven based project is not best practice as you have circumvented the main purpose of maven which is to control the dependencies required to build a project. 此外,在基于Maven的项目中将jar添加到WEB-INF / lib并不是最佳实践,因为您已经规避了maven的主要目的,即控制构建项目所需的依赖项。

您是否尝试在WAR中添加清单

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM