OSGi 包启动问题
我有一个 Java 应用程序。我创建了一个 OSGi 包,并在 Activator.start 中添加了 MyMain Class.main() 。应用程序已启动,但数据库连接有问题。 “java.sql.SQLException:客户端尝试签出连接已超时。” 如果我将我的应用程序作为应用程序启动,它就可以正常工作。 怎么了? 多谢!
I have a Java application. I created a OSGi bundle and in Activator.start i added MyMain Class.main() .Application started but it have a problem with DB connection.
'java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.'
If i start my application as an application it works fine.
What is wrong?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定你到底做了什么,但是使用 OSGi 时不需要 main 方法。主要方法是启动您的程序,在本例中是 OSGi 容器,而不是您的代码。容器将通过运行 Activator 类来运行您的代码,在这里您可以实例化您自己的应用程序特定对象并调用任何合适的方法。
由于您尚未发布代码(您应该),我只能猜测您正在主方法而不是普通方法中创建数据库连接,这就是它不起作用的原因,因为未调用 main 。
Not sure exactly what you have done, but there is no need for a main method when using OSGi. A main method is for starting your program, which in this case is the OSGi container, NOT your code. The container will run your code by running your Activator class, and in here you can instantiate your own application specific objects and call whatever methods are appropriate.
Since you haven't posted the code (you should), I can only guess that you are creating your DB connection in your main method instead of a normal method, which is why it is not working, since the main is not called.