gpt4 book ai didi

jakarta-ee - 有没有办法让嵌入式 EJB 容器启动得更快?

转载 作者:行者123 更新时间:2023-12-04 15:36:19 25 4
gpt4 key购买 nike

我正在使用 glassfish 和 netbeans 做我的第一个 Java EE Web 应用程序。当我创建一个需要嵌入式 EJB 容器的单元测试时,它可能需要大约 30 秒才能加载。我认为这是完全可以理解的,因为它“模仿”了 glassfish 服务器。
但是后来我从 Adam Bien 那里看到了这篇文章,它说:

The entire test, with booting the container, takes on my machine about 5 seconds.



http://www.adam-bien.com/roller/abien/entry/embedding_ejb_3_1_container

所以我必须假设某些东西没有正确配置。我正在运行 Linux Mint 12,我的项目使用的是 MySQL 数据库,我的 PC 是 2Ghz 双核,4 GB 内存。大多数一切都使用 netbeans 安装中的默认设置。 (我确实订购了一个新处理器,根据 cpubenchmark.net,它将 CPU 基准测试从 1700 移动到 7800)

如何提高嵌入式 EJB 容器的启动速度?

在查看输出时,罪魁祸首似乎是:
org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA

这是完整的输出:
Jan 9, 2012 5:01:57 PM com.sun.enterprise.v3.server.CommonClassLoaderServiceImpl findDerbyClient INFO: Cannot find javadb client jar file, derby jdbc driver will not be available by default.
Jan 9, 2012 5:01:59 PM org.glassfish.ha.store.spi.BackingStoreFactoryRegistry register INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
Jan 9, 2012 5:02:00 PM com.sun.enterprise.v3.server.AppServerStartup run INFO: GlassFish Server Open Source Edition 3.1.1 (12) startup time : Embedded (1,476ms), startup services(2,053ms), total(3,529ms)
Jan 9, 2012 5:02:00 PM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Jan 9, 2012 5:02:02 PM org.glassfish.admin.mbeanserver.JMXStartupService shutdown INFO: JMXStartupService and JMXConnectors have been shut down.
Jan 9, 2012 5:02:02 PM com.sun.enterprise.v3.server.AppServerStartup stop INFO: Shutdown procedure finished
Jan 9, 2012 5:02:02 PM AppServerStartup run INFO: [Thread[GlassFish Kernel Main Thread,5,main]] exiting
Jan 9, 2012 5:02:02 PM org.glassfish.ha.store.spi.BackingStoreFactoryRegistry register INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
Jan 9, 2012 5:02:02 PM com.sun.enterprise.v3.server.AppServerStartup run INFO: GlassFish Server Open Source Edition 3.1.1 (12) startup time : Embedded (5,874ms), startup services(150ms), total(6,024ms)
Jan 9, 2012 5:02:02 PM org.glassfish.admin.mbeanserver.JMXStartupService$JMXConnectorsStarterThread run INFO: JMXStartupService: JMXConnector system is disabled, skipping.
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.EJBContainerProviderImpl skipJar INFO: ... skipping entry with a Manifest file with a special attribute: glassfish-embedded-static-shell.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding EJB module to ScatteredArchive classes
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive mysql-connector-java-5.1.13-bin.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive commons-codec-1.6.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive commons-codec-1.6-bin.zip
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive ant.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive primefaces-3.0.RC2.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive ant-junit.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive log4j-1.2.15.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive classes
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.DeploymentElement getOrCreateApplication INFO: [DeploymentElement] adding library to ScatteredArchive junit-4.8.2.jar
Jan 9, 2012 5:02:03 PM org.glassfish.ejb.embedded.EJBContainerImpl deploy INFO: [EJBContainerImpl] Deploying app: org.glassfish.embeddable.archive.ScatteredArchive@1ebafda6
Jan 9, 2012 5:02:08 PM org.hibernate.validator.util.Version <clinit> INFO: Hibernate Validator 4.1.0.Final
Jan 9, 2012 5:02:09 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.SecurityLifecycle <init> INFO: SEC1002: Security Manager is OFF.
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.SecurityLifecycle onInitialization INFO: SEC1010: Entering Security Startup Service
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.PolicyLoader loadPolicy INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.auth.realm.Realm doInstantiate INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.auth.realm.Realm doInstantiate INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.auth.realm.Realm doInstantiate INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
Jan 9, 2012 5:02:15 PM com.sun.enterprise.security.SecurityLifecycle onInitialization INFO: SEC1011: Security Service(s) Started Successfully
Jan 9, 2012 5:02:17 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Jan 9, 2012 5:02:26 PM org.hibernate.validator.engine.resolver.DefaultTraversableResolver detectJPA INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
Jan 9, 2012 5:02:26 PM org.eclipse.persistence.session.file:/tmp/gfembed2576733372934037196tmp/applications/classes/_REMPU INFO: EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
Jan 9, 2012 5:02:29 PM org.eclipse.persistence.session.file:/tmp/gfembed2576733372934037196tmp/applications/classes/_REMPU INFO: file:/tmp/gfembed2576733372934037196tmp/applications/classes/_REMPU login successful
...

谢谢

最佳答案

您可以尝试另一个 EJBContainer impl。

OpenEJB Embedded EJBContainer 的测试时间在 1 秒范围内。它支持 GlassFish 描述符——我们在运行 Java EE TCK 时使用它们而不是我们自己的描述符,因为我们懒得编写我们需要的数千个描述符,而 TCK 已经带有完整的 GlassFish 描述符。

或者,也许可以完全尝试不同的方法。

如需更多单元测试风格,请查看:https://stackoverflow.com/a/8716630/190816
IE。在测试用例中构建应用程序并根据需要进行一些模拟。

关于jakarta-ee - 有没有办法让嵌入式 EJB 容器启动得更快?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8794446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com