Я делаю свое первое веб-приложение на Java EE, используя Glassfish и NetBeans. Когда я создаю модульный тест, для которого требуется встроенный EJB-контейнер, загрузка может занять около 30 секунд. Я подумал, что это вполне понятно, поскольку он «подражает» серверу Glassfish.
Но потом я наткнулся на эту статью от Адама Бина, где говорится:
Весь тест с загрузкой контейнера занимает на моей машине около
5 секунд.
http://www.adam -bien.com / ролик / abien / запись / embedding_ejb_3_1_container
Так что я должен предположить, что что-то не настроено правильно. Я использую Linux Mint 12, мой проект использует базу данных MySQL, и мой компьютер имеет двухъядерный процессор 2 ГГц, 4 ГБ ОЗУ. Большинство всего использует настройки по умолчанию из установки netbeans. (Я заказал новый процессор, который переместит CPU Benchmark с 1700 до 7800 согласно cpubenchmark.net)
Что можно сделать для повышения скорости загрузки встроенного 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
...
Спасибо