WebSphere wsadmin ClassNotFound 异常
我正在尝试将 wsadmin 与 Jython 结合使用来部署 EAR 文件。在实际部署之前,我需要使用 Java 类运行数据库更新。我遇到了 ClassNotFoundException,这对我来说没有意义。
背景: EAR 文件已分解。 wsadmin 工具使用以下选项启动:
-wsadmin_classpath %CP%
-javaoption -Dpython.path=%CP%
这两个选项都指向相同的类路径,其中包含所有必需的 JAR。
jython 脚本获取与数据库的连接,并调用实用程序类来创建数据库脚本。实用程序类使用反射从类路径加载其他类(这是我们正在使用的库的硬性要求,无法更改)。它基本上看起来像这样:
from liquibase import Liquibase
def main(args):
conn = getConnection(args)
updater = Liquibase(conn)
updater.update()
在 update() 方法期间,Liquibase 使用反射来实例化一些 Java 类。这是我得到 ClassNotFoundException 的地方,例如 ClassNotFoundException: com.foo.CustomUpdate
在我的脚本中,我可以导入 com.foo.CustomUpdate 类并且不会出现错误:
from com.foo import CustomUpdate
c = CustomUpdate("select 1")
print c.getUpdate()
所以我知道该类位于类路径上。我唯一的想法是,它与我们正在使用的库的反射方面有关。还有其他人遇到过这样的事情吗?
如果上述问题无法解决,我唯一的其他想法是将其拆分为 shell 脚本并使用 Java 运行数据库更新,然后使用 wsadmin 部署 EAR。
I'm trying to use wsadmin with Jython to deploy an EAR file. Before the actual deployment, I need to run a DB update using a Java class. I'm running into a ClassNotFoundException that isn't making sense to me.
Background:
The EAR file is exploded. The wsadmin tool is started with the following options:
-wsadmin_classpath %CP%
-javaoption -Dpython.path=%CP%
Both of those point to the same classpath, which contains all necessary JARs.
The jython script gets a connection to a database, and calls a utility class to create a database script. The utility class uses reflection to load other classes from the classpath (that is a hard-and-fast requirement of the library we are using, it can't be changed). It basically looks like this:
from liquibase import Liquibase
def main(args):
conn = getConnection(args)
updater = Liquibase(conn)
updater.update()
During the update() method, Liquibase uses reflection to instantiate some Java classes. This is where I get a ClassNotFoundException, for example ClassNotFoundException: com.foo.CustomUpdate
In my script, I can import the com.foo.CustomUpdate class and get no errors:
from com.foo import CustomUpdate
c = CustomUpdate("select 1")
print c.getUpdate()
So I know that the class is on the classpath. My only idea is that it has something to do with the reflection aspect of the library we are using. Has anybody else run up against anything like this?
My only other idea, if the above is unfixable, is to split things out into a shell script and use Java to run the DB update and then wsadmin to deploy the EAR.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论