mdea
Julho 21, 2011, 2:10pm
#1
Ola boa tarde amigos do fórum.
Ano passado quando elaborei um sistema para o meu TCC, criei um BD no mysql(mysql WorkBench) fiz o mapeamento das entidades no netbenas 6.9.1(atualmente uso a versão 7), onde ele criou todo o mapeamento para mim inclusive as anotações dos relacionamento, o que facilitou muito o meu trabalho. Bom peguei um sistema para fazer e iniciei o projeto novamente no MySQL WorkBench, onde construi o BD que ja esta pronto e funcionando no MySQL, porém quando fui mapear as entidades de maneira automática como antes o Netbeans gera as anotações porém não as anotações dos relacionamentos. Alguém conhece este problema e pode me dar um(as) dicas do que pode estar acontecendo.
mdea
Julho 21, 2011, 2:13pm
#2
Obs.: Já estou fazendo as anotações dos relacionamento manualmente, porém gostaria de resolver o problema.
mdea
Julho 21, 2011, 2:46pm
#3
Achei o problema, fui verificar o sql gerado pelo MySQL Workbench e percebi que ele na hora de exportar o script.sql não estava gerando o sql referente aos CONSTRAINTs e FOREIGN KEYs, é preciso ajustar isso antes de exportar o script sql do modelo(DER) feito no Workbench. É isso ai, sem mais.
fasts
Julho 21, 2011, 3:14pm
#4
Interessante. Como é que se faz pra gerar as classes com as anotações automaticamente?
Saitou
Julho 25, 2011, 11:23am
#5
Interessante. Como é que se faz pra gerar as classes com as anotações automaticamente? [2]
Editando…
Descobri. É fácil. Vá em novo -> Outro ->Persistance -> classes de entidades do banco de dados. Lá você passa ao NetBeans as informações de conexão do seu banco e a partir daí o software pega as tabelas, as transforma em classes e faz o devido mapeamento e relacionamento através das annotations. É lindo !!! _
Link
Setembro 7, 2011, 8:31am
#6
mdea:
Achei o problema, fui verificar o sql gerado pelo MySQL Workbench e percebi que ele na hora de exportar o script.sql não estava gerando o sql referente aos CONSTRAINTs e FOREIGN KEYs, é preciso ajustar isso antes de exportar o script sql do modelo(DER) feito no Workbench. É isso ai, sem mais.
Bom dia Mdea, como vai tudo bem?
Estou tentando usar o Netbeans 7.0.1 + Glassfish 3.x + JPA 2 + Hibernate. Infelizmente não estou obtendo êxito você pode me ajudar?
Com o EclispeLink funciona perfeitamente, mas com o Hibernate não funciona, será que tenho que fazer alguma ação a mais para fazer funcionar?
Veja os erros abaixo listados no meu Glassfish:
Launching GlassFish on Felix platform
07/09/2011 09:59:22 com.sun.enterprise.server.logging.LogManagerService postConstruct
AVISO: Record begin marker is not a proper value so using default.
07/09/2011 09:59:22 com.sun.enterprise.server.logging.LogManagerService postConstruct
AVISO: Record end marker is not a proper value so using default.
07/09/2011 09:59:22 com.sun.enterprise.server.logging.LogManagerService postConstruct
AVISO: Log Format field separator is not a character so using default.
INFO: Registered org.glassfish.ha.store.adapter.cache.ShoalBackingStoreProxy for persistence-type = replicated in BackingStoreFactoryRegistry
INFO: Grizzly Framework 1.9.36 started in: 39ms - bound to [0.0.0.0:7676]
INFO: Grizzly Framework 1.9.36 started in: 66ms - bound to [0.0.0.0:3700]
INFO: Grizzly Framework 1.9.36 started in: 141ms - bound to [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.36 started in: 103ms - bound to [0.0.0.0:4848]
INFO: Grizzly Framework 1.9.36 started in: 118ms - bound to [0.0.0.0:8181]
INFO: The Admin Console is already installed, but not yet loaded.
INFO: WS10010: Web service endpoint deployment events listener registered successfully.
INFO: SEC1002: Security Manager is OFF.
INFO: SEC1010: Entering Security Startup Service
INFO: SEC1143: Loading policy provider com.sun.enterprise.security.provider.PolicyWrapper.
INFO: SEC1115: Realm [admin-realm] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [file] of classtype [com.sun.enterprise.security.auth.realm.file.FileRealm] successfully created.
INFO: SEC1115: Realm [certificate] of classtype [com.sun.enterprise.security.auth.realm.certificate.CertificateRealm] successfully created.
INFO: SEC1011: Security Service(s) Started Successfully
INFO: WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: WEB0169: Created HTTP listener [admin-listener] on host/port [0.0.0.0:4848]
INFO: WEB0171: Created virtual server [server]
INFO: WEB0171: Created virtual server [__asadmin]
INFO: WEB0172: Virtual server [server] loaded default web module []
INFO: WS00018: Webservice Endpoint deployed
NewWebService listening at address at http://NOTEBOOK:8080/HtiSgi/NewWebService
INFO: WS10001: Loading WS-TX Services. Please wait.
INFO: WS00018: Webservice Endpoint deployed
RegistrationPortTypeRPCPortImpl listening at address at http://NOTEBOOK:8080/__wstx-services/RegistrationPortTypeRPC11
INFO: WS00018: Webservice Endpoint deployed
ParticipantPortTypePortImpl listening at address at http://NOTEBOOK:8080/__wstx-services/ParticipantPortType11
INFO: WS00018: Webservice Endpoint deployed
ParticipantPortTypeImpl listening at address at http://NOTEBOOK:8080/__wstx-services/ParticipantPortType
INFO: WS00018: Webservice Endpoint deployed
CoordinatorPortTypePortImpl listening at address at http://NOTEBOOK:8080/__wstx-services/CoordinatorPortType11
INFO: WS00018: Webservice Endpoint deployed
RegistrationRequesterPortTypeImpl listening at address at http://NOTEBOOK:8080/__wstx-services/RegistrationRequesterPortType
INFO: WS00018: Webservice Endpoint deployed
CoordinatorPortTypeImpl listening at address at http://NOTEBOOK:8080/__wstx-services/CoordinatorPortType
INFO: WS00018: Webservice Endpoint deployed
RegistrationPortTypeImpl listening at address at http://NOTEBOOK:8080/__wstx-services/RegistrationPortTypeRPC
INFO: WS00018: Webservice Endpoint deployed
RegistrationRequesterPortTypePortImpl listening at address at http://NOTEBOOK:8080/__wstx-services/RegistrationRequesterPortType11
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-RegistrationService_V11-RegistrationPort
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-WSAT11Service-ParticipantPort
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-WSATCoordinator-Participant
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-WSAT11Service-CoordinatorPort
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-Coordinator-RegistrationRequester
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-WSATCoordinator-Coordinator
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-Coordinator-Registration
INFO: Metro monitoring rootname successfully set to: amx:pp=/mon/server-mon[server],type=WSEndpoint,name=/__wstx-services-RegistrationService_V11-RegistrationRequesterPort
INFO: WEB0671: Loading application [wstx-services] at [/__wstx-services]
INFO: WS10002: WS-TX Services successfully started.
INFO: Hibernate Validator 4.1.0.Final
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: WELD-000900 ${parsedVersion (osgiVersion})
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
GRAVE: Exception while loading the app
GRAVE: Exception while shutting down application container
GRAVE: Exception while shutting down application container : java.lang.NullPointerException
INFO: GlassFish Server Open Source Edition 3.1.1 (12) startup time : Felix (3.687ms), startup services(28.868ms), total(32.555ms)
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: JMXStartupService: Started JMXConnector, JMXService URL = service:jmx:rmi://NOTEBOOK:8686/jndi/rmi://NOTEBOOK:8686/jmxrmi
INFO: WEB0169: Created HTTP listener [http-listener-1] on host/port [0.0.0.0:8080]
INFO: Grizzly Framework 1.9.36 started in: 27ms - bound to [0.0.0.0:8080]
INFO: WEB0169: Created HTTP listener [http-listener-2] on host/port [0.0.0.0:8181]
INFO: Grizzly Framework 1.9.36 started in: 7ms - bound to [0.0.0.0:8181]
INFO: WS00018: Webservice Endpoint deployed
NewWebService listening at address at http://NOTEBOOK:8080/HtiSgi/NewWebService
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
INFO: file:/H:/AmbienteDesenvolvimento/ProjetoDeSistema/Java/ExemploProjetos/HtiSgi/build/web/WEB-INF/classes/_HtiSgiPU login successful
AVISO: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@1696e4c].
AVISO: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@1696e4c] from index [0]
AVISO: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@80726] from index [1]
AVISO: PER01000: Got SQLException executing statement “CREATE TABLE tblUser (id integer, strCPF VARCHAR(11) NOT NULL, booActived boolean, dteAdded TIMESTAMP DEFAULT CURRENT_TIMESTAMP, dteLastChange DATE, strEmail VARCHAR(255) NOT NULL, strHash VARCHAR(32), booLogged boolean, strLogin VARCHAR(255) NOT NULL, strPassword VARCHAR(32) NOT NULL, strUserName VARCHAR(255) NOT NULL, PRIMARY KEY (id))”: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table ‘tbluser’ already exists
INFO: Portable JNDI names for EJB UserSession : [java:global/HtiSgi/UserSession!br.com.hti.session.UserSession, java:global/HtiSgi/UserSession]
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
GRAVE: Exception while loading the app
GRAVE: Exception while shutting down application container
INFO: file:/H:/AmbienteDesenvolvimento/ProjetoDeSistema/Java/ExemploProjetos/HtiSgi/build/web/WEB-INF/classes/_HtiSgiPU logout successful
GRAVE: Exception while shutting down application container : java.lang.NullPointerException
INFO: WS00018: Webservice Endpoint deployed
NewWebService listening at address at http://NOTEBOOK:8080/HtiSgi/NewWebService
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
INFO: EclipseLink, version: Eclipse Persistence Services - 2.3.0.v20110604-r9504
INFO: file:/H:/AmbienteDesenvolvimento/ProjetoDeSistema/Java/ExemploProjetos/HtiSgi/build/web/WEB-INF/classes/_HtiSgiPU login successful
AVISO: Multiple [2] JMX MBeanServer instances exist, we will use the server at index [0] : [com.sun.enterprise.v3.admin.DynamicInterceptor@1696e4c].
AVISO: JMX MBeanServer in use: [com.sun.enterprise.v3.admin.DynamicInterceptor@1696e4c] from index [0]
AVISO: JMX MBeanServer in use: [com.sun.jmx.mbeanserver.JmxMBeanServer@80726] from index [1]
INFO: Portable JNDI names for EJB UserSession : [java:global/HtiSgi/UserSession!br.com.hti.session.UserSession, java:global/HtiSgi/UserSession]
INFO: Instantiated an instance of org.hibernate.validator.engine.resolver.JPATraversableResolver.
GRAVE: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5332)
at com.sun.enterprise.web.WebModule.start(WebModule.java:498)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:917)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2743)
at org.apache.catalina.core.StandardContext.addApplicationListener(StandardContext.java:1966)
at com.sun.enterprise.web.TomcatDeploymentConfig.configureApplicationListener(TomcatDeploymentConfig.java:235)
at com.sun.enterprise.web.TomcatDeploymentConfig.configureWebModule(TomcatDeploymentConfig.java:94)
at com.sun.enterprise.web.WebModuleContextConfig.start(WebModuleContextConfig.java:274)
at com.sun.enterprise.web.WebModuleContextConfig.lifecycleEvent(WebModuleContextConfig.java:172)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:149)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:5329)
… 38 more
Caused by: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:2853)
at org.apache.catalina.core.StandardContext.loadListener(StandardContext.java:4806)
at com.sun.enterprise.web.WebModule.loadListener(WebModule.java:1599)
at org.apache.catalina.core.StandardContext.addListener(StandardContext.java:2740)
… 45 more
Caused by: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:315)
at com.sun.enterprise.web.WebContainer.createListenerInstance(WebContainer.java:749)
at com.sun.enterprise.web.WebModule.createListenerInstance(WebModule.java:1987)
at org.apache.catalina.core.StandardContext.createListener(StandardContext.java:2851)
… 48 more
Caused by: java.lang.NullPointerException
at org.jboss.weld.bootstrap.WeldBootstrap.getManager(WeldBootstrap.java:319)
at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:266)
at org.glassfish.weld.services.JCDIServiceImpl.createManagedObject(JCDIServiceImpl.java:229)
at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:470)
at com.sun.enterprise.container.common.impl.managedbean.ManagedBeanManagerImpl.createManagedBean(ManagedBeanManagerImpl.java:420)
at com.sun.enterprise.container.common.impl.util.InjectionManagerImpl.createManagedObject(InjectionManagerImpl.java:299)
… 51 more
AVISO: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:921)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:901)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:733)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:2000)
at com.sun.enterprise.web.WebContainer.loadWebModule(WebContainer.java:1651)
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:109)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Unknown Source)
GRAVE: Exception while invoking class com.sun.enterprise.web.WebApplication start method
java.lang.Exception: java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
at com.sun.enterprise.web.WebApplication.start(WebApplication.java:138)
at org.glassfish.internal.data.EngineRef.start(EngineRef.java:130)
at org.glassfish.internal.data.ModuleInfo.start(ModuleInfo.java:269)
at org.glassfish.internal.data.ApplicationInfo.start(ApplicationInfo.java:294)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:462)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:382)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1064)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1244)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1232)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:459)
at com.sun.enterprise.v3.admin.AdminAdapter.service(AdminAdapter.java:209)
at com.sun.grizzly.tcp.http11.GrizzlyAdapter.service(GrizzlyAdapter.java:168)
at com.sun.enterprise.v3.server.HK2Dispatcher.dispath(HK2Dispatcher.java:117)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:238)
at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
at java.lang.Thread.run(Unknown Source)
GRAVE: Exception while loading the app
INFO: file:/H:/AmbienteDesenvolvimento/ProjetoDeSistema/Java/ExemploProjetos/HtiSgi/build/web/WEB-INF/classes/_HtiSgiPU logout successful
GRAVE: Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: java.lang.IllegalArgumentException: javax.servlet.ServletException: com.sun.enterprise.container.common.spi.util.InjectionException: Error creating managed object for class: class org.glassfish.webservices.WSServletContextListener
Olá Boa Tarde Amigos estou com um problema na criação de um projeto Java Desktop usando o Hibernate e Netbeans 7.0.1
apos eu fazer a criação do projeto da Classe de Entidade e A Classe de Controle de entidade eu vou na minha classe principal
criar meus métodos para incluir um aluno com apenas nome e idade mas da um erro falado que eu não tenho um método construtor na minha Classe de Controle da Classe de entidade me ajudem que está complicado agradeço.
//Classe Main
package projeto;
import entidades.Aluno;
public class Main {
public static void main(String[] args) {
Aluno a1 = new Aluno();
a1.setId(null);
a1.setNome("Franciso Peido");
a1.setIdade(100);
AlunoJpaController alunoJpaController = new AlunoJpaController();
alunoJpaController.create(a1);
}
}
Classe de Controle da Entidade
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package projeto;
import daos.exceptions.NonexistentEntityException;
import entidades.Aluno;
import entidades.Aluno;
import java.io.Serializable;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
import javax.transaction.UserTransaction;
/**
*
* @author Android
*/
public class AlunoJpaController implements Serializable {
public AlunoJpaController(UserTransaction utx, EntityManagerFactory emf) {
this.utx = utx;
this.emf = emf;
}
private UserTransaction utx = null;
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager(null);
}
public void create(Aluno aluno) {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
em.persist(aluno);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(Aluno aluno) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
aluno = em.merge(aluno);
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Long id = aluno.getId();
if (findAluno(id) == null) {
throw new NonexistentEntityException("The aluno with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Long id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Aluno aluno;
try {
aluno = em.getReference(Aluno.class, id);
aluno.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The aluno with id " + id + " no longer exists.", enfe);
}
em.remove(aluno);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public List<Aluno> findAlunoEntities() {
return findAlunoEntities(true, -1, -1);
}
public List<Aluno> findAlunoEntities(int maxResults, int firstResult) {
return findAlunoEntities(false, maxResults, firstResult);
}
private List<Aluno> findAlunoEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
Query q = em.createQuery("select object(o) from Aluno as o");
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public Aluno findAluno(Long id) {
EntityManager em = getEntityManager();
try {
return em.find(Aluno.class, id);
} finally {
em.close();
}
}
public int getAlunoCount() {
EntityManager em = getEntityManager();
try {
Query q = em.createQuery("select count(o) from Aluno as o");
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
}
Classe de Entidade
package entidades;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Aluno implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String nome;
private int idade;
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Aluno)) {
return false;
}
Aluno other = (Aluno) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "entidades.Aluno[ id=" + id + " ]";
}
}