11 Replies Latest reply on Feb 9, 2008 8:21 PM by Mc Java

    Illegal @PersistenceUnit? Help!

    Mc Java Newbie

      Hi all. I'm a newbie trying to get JBoss to persist data into a MySql db, using an EJB3. You folks were kind enough to help me get JBoss set up to use MySql, which now seems set. I see new tables, like JMS_MESSAGES, in my MySql db. If it matters, I'm using the JBoss 4.2 Eclipse plugin.

      Next, though, my EJB is failing to register when JBoss starts up. I'm getting an "Illegal @PersistenceUnit" message. I should say I'm also a newbie at EJB.

      Below is the JBoss log. Below that is my EJB3. I'd really appreciate any help you folks could give me (again...). Thanks!


      15:55:59,029 INFO [Server] Starting JBoss (MX MicroKernel)...
      15:55:59,030 INFO [Server] Release ID: JBoss [Trinity] 4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)
      15:55:59,031 INFO [Server] Home Dir: C:\jboss-4.2.2.GA
      15:55:59,031 INFO [Server] Home URL: file:/C:/jboss-4.2.2.GA/
      15:55:59,033 INFO [Server] Patch URL: null
      15:55:59,033 INFO [Server] Server Name: default
      15:55:59,034 INFO [Server] Server Home Dir: C:\jboss-4.2.2.GA\server\default
      15:55:59,034 INFO [Server] Server Home URL: file:/C:/jboss-4.2.2.GA/server/default/
      15:55:59,034 INFO [Server] Server Log Dir: C:\jboss-4.2.2.GA\server\default\log
      15:55:59,034 INFO [Server] Server Temp Dir: C:\jboss-4.2.2.GA\server\default\tmp
      15:55:59,034 INFO [Server] Root Deployment Filename: jboss-service.xml
      15:55:59,354 INFO [ServerInfo] Java version: 1.6.0-oem,Sun Microsystems Inc.
      15:55:59,354 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.6.0-oem-b104,Sun Microsystems Inc.
      15:55:59,354 INFO [ServerInfo] OS-System: Windows XP 5.1,x86
      15:55:59,586 INFO [Server] Core system initialized
      15:56:01,118 INFO [WebService] Using RMI server codebase: http://127.0.0.1:8083/
      15:56:01,120 INFO [Log4jService$URLWatchTimerTask] Configuring from URL: resource:jboss-log4j.xml
      15:56:01,423 INFO [TransactionManagerService] JBossTS Transaction Service (JTA version) - JBoss Inc.
      15:56:01,423 INFO [TransactionManagerService] Setting up property manager MBean and JMX layer
      15:56:01,546 INFO [TransactionManagerService] Starting recovery manager
      15:56:01,659 INFO [TransactionManagerService] Recovery manager started
      15:56:01,659 INFO [TransactionManagerService] Binding TransactionManager JNDI Reference
      15:56:03,448 INFO [EJB3Deployer] Starting java:comp multiplexer
      15:56:03,650 INFO [STDOUT] no object for null
      15:56:03,652 INFO [STDOUT] no object for null
      15:56:03,663 INFO [STDOUT] no object for null
      15:56:03,674 INFO [STDOUT] no object for {urn:jboss:bean-deployer}supplyType
      15:56:03,680 INFO [STDOUT] no object for {urn:jboss:bean-deployer}dependsType
      15:56:05,686 INFO [NativeServerConfig] JBoss Web Services - Native
      15:56:05,686 INFO [NativeServerConfig] jbossws-native-2.0.1.SP2 (build=200710210837)
      15:56:06,365 INFO [Embedded] Catalina naming disabled
      15:56:06,482 INFO [AprLifecycleListener] The Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.6.0\bin;.;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;c:\Program Files\Java\jre1.6.0\bin\client;c:\Program Files\Java\jre1.6.0\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Program Files\Common Files\Roxio Shared\9.0\DLLShared\;C:\Program Files\Common Files\Adobe\AGL
      15:56:06,521 INFO [Http11Protocol] Initializing Coyote HTTP/1.1 on http-127.0.0.1-8080
      15:56:06,522 INFO [AjpProtocol] Initializing Coyote AJP/1.3 on ajp-127.0.0.1-8009
      15:56:06,522 INFO [Catalina] Initialization processed in 157 ms
      15:56:06,522 INFO [StandardService] Starting service jboss.web
      15:56:06,524 INFO [StandardEngine] Starting Servlet Engine: JBossWeb/2.0.1.GA
      15:56:06,556 INFO [Catalina] Server startup in 33 ms
      15:56:06,631 INFO [TomcatDeployer] deploy, ctxPath=/, warUrl=.../deploy/jboss-web.deployer/ROOT.war/
      15:56:07,156 INFO [TomcatDeployer] deploy, ctxPath=/invoker, warUrl=.../deploy/http-invoker.sar/invoker.war/
      15:56:07,251 INFO [TomcatDeployer] deploy, ctxPath=/jbossws, warUrl=.../deploy/jbossws.sar/jbossws-context.war/
      15:56:07,329 INFO [TomcatDeployer] deploy, ctxPath=/jbossmq-httpil, warUrl=.../deploy/jms/jbossmq-httpil.sar/jbossmq-httpil.war/
      15:56:07,813 INFO [TomcatDeployer] deploy, ctxPath=/web-console, warUrl=.../deploy/management/console-mgr.sar/web-console.war/
      15:56:08,146 INFO [MailService] Mail Service bound to java:/Mail
      15:56:08,272 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-local-jdbc.rar
      15:56:08,298 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-ha-xa-jdbc.rar
      15:56:08,320 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-local-jdbc.rar
      15:56:08,346 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jboss-xa-jdbc.rar
      15:56:08,383 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/jms/jms-ra.rar
      15:56:08,410 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/mail-ra.rar
      15:56:08,441 INFO [RARDeployment] Required license terms exist, view META-INF/ra.xml in .../deploy/quartz-ra.rar
      15:56:08,449 INFO [QuartzResourceAdapter] start quartz!!!
      15:56:08,499 INFO [SimpleThreadPool] Job execution threads will use class loader of thread: main
      15:56:08,517 INFO [QuartzScheduler] Quartz Scheduler v.1.5.2 created.
      15:56:08,520 INFO [RAMJobStore] RAMJobStore initialized.
      15:56:08,520 INFO [StdSchedulerFactory] Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
      15:56:08,520 INFO [StdSchedulerFactory] Quartz scheduler version: 1.5.2
      15:56:08,520 INFO [QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
      15:56:08,698 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=ConnectionFactoryBinding,name=JmsXA' to JNDI name 'java:JmsXA'
      15:56:08,772 INFO [ConnectionFactoryBindingService] Bound ConnectionManager 'jboss.jca:service=DataSourceBinding,name=DefaultDS' to JNDI name 'java:DefaultDS'
      15:56:09,403 INFO [A] Bound to JNDI name: queue/A
      15:56:09,405 INFO [B] Bound to JNDI name: queue/B
      15:56:09,406 INFO [C] Bound to JNDI name: queue/C
      15:56:09,407 INFO [D] Bound to JNDI name: queue/D
      15:56:09,409 INFO [ex] Bound to JNDI name: queue/ex
      15:56:09,424 INFO [testTopic] Bound to JNDI name: topic/testTopic
      15:56:09,425 INFO [securedTopic] Bound to JNDI name: topic/securedTopic
      15:56:09,427 INFO [testDurableTopic] Bound to JNDI name: topic/testDurableTopic
      15:56:09,429 INFO [testQueue] Bound to JNDI name: queue/testQueue
      15:56:09,451 INFO [UILServerILService] JBossMQ UIL service available at : /127.0.0.1:8093
      15:56:09,477 INFO [DLQ] Bound to JNDI name: queue/DLQ
      15:56:09,638 WARN [ServiceController] Ignoring request to stop nonexistent service: jboss.j2ee:jar=CMPStockListApp.jar,name=StockListBean,service=EJB3
      15:56:09,638 WARN [ServiceController] Ignoring request to destroy nonexistent service: jboss.j2ee:jar=CMPStockListApp.jar,name=StockListBean,service=EJB3
      15:56:09,638 WARN [JmxKernelAbstraction] jboss.j2ee:jar=CMPStockListApp.jar,name=StockListBean,service=EJB3 is not registered
      15:56:09,639 WARN [ServiceController] Problem starting service jboss.j2ee:service=EJB3,module=CMPStockListApp.jar
      java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.
      at org.jboss.injection.PersistenceContextHandler.handleFieldAnnotations(PersistenceContextHandler.java:182)
      at org.jboss.injection.InjectionUtil.processFieldAnnotations(InjectionUtil.java:137)
      at org.jboss.injection.InjectionUtil.processAnnotations(InjectionUtil.java:174)
      at org.jboss.ejb3.EJBContainer.processMetadata(EJBContainer.java:358)
      at org.jboss.ejb3.SessionContainer.processMetadata(SessionContainer.java:140)
      at org.jboss.ejb3.Ejb3Deployment.processEJBContainerMetadata(Ejb3Deployment.java:292)
      at org.jboss.ejb3.Ejb3Deployment.start(Ejb3Deployment.java:356)
      at org.jboss.ejb3.Ejb3Module.startService(Ejb3Module.java:91)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:417)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy33.start(Unknown Source)
      at org.jboss.ejb3.EJB3Deployer.start(EJB3Deployer.java:512)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
      at org.jboss.mx.interceptor.DynamicInterceptor.invoke(DynamicInterceptor.java:97)
      at org.jboss.system.InterceptorServiceMBeanSupport.invokeNext(InterceptorServiceMBeanSupport.java:238)
      at org.jboss.wsf.container.jboss42.DeployerInterceptor.start(DeployerInterceptor.java:87)
      at org.jboss.deployment.SubDeployerInterceptorSupport$XMBeanInterceptor.start(SubDeployerInterceptorSupport.java:188)
      at org.jboss.deployment.SubDeployerInterceptor.invoke(SubDeployerInterceptor.java:95)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy34.start(Unknown Source)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
      at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy9.deploy(Unknown Source)
      at org.jboss.deployment.scanner.URLDeploymentScanner.deploy(URLDeploymentScanner.java:421)
      at org.jboss.deployment.scanner.URLDeploymentScanner.scan(URLDeploymentScanner.java:634)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner$ScannerThread.doScan(AbstractDeploymentScanner.java:263)
      at org.jboss.deployment.scanner.AbstractDeploymentScanner.startService(AbstractDeploymentScanner.java:336)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalStart(ServiceMBeanSupport.java:289)
      at org.jboss.system.ServiceMBeanSupport.jbossInternalLifecycle(ServiceMBeanSupport.java:245)
      at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.system.ServiceController$ServiceProxy.invoke(ServiceController.java:978)
      at $Proxy0.start(Unknown Source)
      at org.jboss.system.ServiceController.start(ServiceController.java:417)
      at sun.reflect.GeneratedMethodAccessor9.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy4.start(Unknown Source)
      at org.jboss.deployment.SARDeployer.start(SARDeployer.java:302)
      at org.jboss.deployment.MainDeployer.start(MainDeployer.java:1025)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:819)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:782)
      at org.jboss.deployment.MainDeployer.deploy(MainDeployer.java:766)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
      at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
      at org.jboss.mx.interceptor.AbstractInterceptor.invoke(AbstractInterceptor.java:133)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.interceptor.ModelMBeanOperationInterceptor.invoke(ModelMBeanOperationInterceptor.java:142)
      at org.jboss.mx.server.Invocation.invoke(Invocation.java:88)
      at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
      at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
      at org.jboss.mx.util.MBeanProxyExt.invoke(MBeanProxyExt.java:210)
      at $Proxy5.deploy(Unknown Source)
      at org.jboss.system.server.ServerImpl.doStart(ServerImpl.java:482)
      at org.jboss.system.server.ServerImpl.start(ServerImpl.java:362)
      at org.jboss.Main.boot(Main.java:200)
      at org.jboss.Main$1.run(Main.java:508)
      at java.lang.Thread.run(Unknown Source)
      15:56:09,640 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.2.2.GA/server/default/deploy/CMPStockListApp.jar/
      15:56:09,846 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
      15:56:09,852 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=EJB_1.jar,name=CalculatorBean,service=EJB3 with dependencies:
      15:56:09,969 INFO [EJBContainer] STARTED EJB: org.jboss.tutorial.stateless.bean.CalculatorBean ejbName: CalculatorBean
      15:56:10,017 INFO [JmxKernelAbstraction] creating wrapper delegate for: org.jboss.ejb3.stateless.StatelessContainer
      15:56:10,017 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=EJB_1.jar,name=MyFirstBean,service=EJB3 with dependencies:
      15:56:10,024 INFO [EJBContainer] STARTED EJB: org.jboss.tutorial.stateless.bean.MyFirstBean ejbName: MyFirstBean
      15:56:10,030 INFO [EJB3Deployer] Deployed: file:/C:/jboss-4.2.2.GA/server/default/deploy/EJB_1.jar/
      15:56:10,040 INFO [TomcatDeployer] deploy, ctxPath=/FirstWebProject, warUrl=.../deploy/FirstWebProject.war/
      15:56:10,114 INFO [TomcatDeployer] deploy, ctxPath=/jmx-console, warUrl=.../deploy/jmx-console.war/
      15:56:10,194 ERROR [URLDeploymentScanner] Incomplete Deployment listing:

      --- MBeans waiting for other MBeans ---
      ObjectName: jboss.j2ee:service=EJB3,module=CMPStockListApp.jar
      State: FAILED
      Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.

      --- MBEANS THAT ARE THE ROOT CAUSE OF THE PROBLEM ---
      ObjectName: jboss.j2ee:service=EJB3,module=CMPStockListApp.jar
      State: FAILED
      Reason: java.lang.RuntimeException: Illegal @PersistenceUnit on private javax.persistence.EntityManager beans.StockListBean._manager :There is no default persistence unit in this deployment.


      15:56:10,246 INFO [Http11Protocol] Starting Coyote HTTP/1.1 on http-127.0.0.1-8080
      15:56:10,258 INFO [AjpProtocol] Starting Coyote AJP/1.3 on ajp-127.0.0.1-8009
      15:56:10,274 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 11s:238ms


      AND THIS IS THE EJB:

      package beans;

      import beans.Stock;
      import javax.ejb.Stateless;
      import javax.persistence.EntityManager;
      import javax.persistence.PersistenceContext;

      @Stateless
      public class StockListBean implements StockList {

      // the reference to the entity manager
      @PersistenceContext
      private EntityManager _manager;

      // the public business methods. these must be coded in the
      // interface also.

      public String getStock(String ticker) throws StockException {
      Stock stock = _manager.find(Stock.class, ticker);
      if (stock == null) {
      throw new StockException();
      }
      return stock.getName();
      }

      public void addStock(String ticker, String name)
      throws StockException {
      Stock stock = _manager.find(Stock.class, ticker);
      if (stock != null) {
      throw new StockException();
      }
      _manager.persist(new Stock(ticker, name));
      }

      public void updateStock(String ticker, String name)
      throws StockException{
      Stock stock = _manager.find(Stock.class, ticker);
      if (stock == null) {
      throw new StockException();
      }
      stock.setName(name);
      }

      public void deleteStock(String ticker)
      throws StockException {
      Stock stock = _manager.find(Stock.class, ticker);
      if (stock == null) {
      throw new StockException();
      }
      _manager.remove(stock);
      }
      }



        • 1. Re: Illegal @PersistenceUnit? Help!
          jaikiran pai Master

          Post the output of the following command:

          1) From the command prompt, cd to the deploy folder of JBoss.
          2) Run this command:

          jar -tf CMPStockListApp.jar


          Post the output here. That will show us whether the jar has been packaged correctly. Also, post the contents of persistence.xml file which is packaged in your application.

          By the way, you are using Java 6. I would recommend, using Java 5, since JBoss 4.2 is not fully qualified to run with Java 6.

          15:55:59,354 INFO [ServerInfo] Java version: 1.6.0-oem,Sun Microsystems Inc.
          15:55:59,354 INFO [ServerInfo] Java VM: Java HotSpot(TM) Client VM 1.6.0-oem-b104,Sun Microsystems Inc.


          • 2. Re: Illegal @PersistenceUnit? Help!
            Mc Java Newbie

            I actually getting an io exception trying to run the jar command. Might this be related to the packaging itself?

            In addition to being a newbie at JBoss, I'm also on Vista for the first time. When I navigate using the file system to CMPStockListApp.jar, it shows as a normal FOLDER. I believe this would cause the io exception. I don't see a single FILE called CMPStockListApp.jar, like I was expecting.

            Sorry to sound like SUCH a newbie, but could you recommend a next step? I'll continue working on it here, of course...

            Thanks again...

            • 3. Re: Illegal @PersistenceUnit? Help!
              jaikiran pai Master

               

              When I navigate using the file system to CMPStockListApp.jar, it shows as a normal FOLDER.


              Looks like the application is deployed in exploded form (http://wiki.jboss.org/wiki/Wiki.jsp?page=ExplodedDeployment) which is a valid form of deployment in JBoss.


              Sorry to sound like SUCH a newbie, but could you recommend a next step?


              Try this then:

              - From the command prompt cd to C:/jboss-4.2.2.GA/server/default/deploy/CMPStockListApp.jar (remember the application is a exploded archive, so you will be able to 'cd' to this).
              - Run the following command:

              dir /b /s


              Post the output here.




              • 4. Re: Illegal @PersistenceUnit? Help!
                Mc Java Newbie

                Hey! That I can do! Here it is:


                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar>dir /b /s
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\beans
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\META-INF
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\beans\Stock.class
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\beans\StockException
                .class
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\beans\StockList.clas
                s
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\beans\StockListBean.
                class
                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar\META-INF\MANIFEST.MF


                C:\jboss-4.2.2.GA\server\default\deploy\CMPStockListApp.jar>

                • 5. Re: Illegal @PersistenceUnit? Help!
                  Mc Java Newbie

                  I couldn't find a persistence.xml file anywhere in my JBoss folders... I did find a persistence.properties. Would that help?

                  • 6. Re: Illegal @PersistenceUnit? Help!
                    jaikiran pai Master

                    You will have to place a persistence.xml file under META-INF folder with the relevant entries in that xml. Go through this http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html_single/index.html for an introduction about EJB3.

                    Specifically, look at this http://docs.jboss.org/ejb3/app-server/reference/build/reference/en/html_single/index.html#entityconfig for entity configuration files.

                    • 7. Re: Illegal @PersistenceUnit? Help!
                      Mc Java Newbie

                      Will do. Trying to work on this tonight. Will post results. Thanks.

                      • 8. Re: Illegal @PersistenceUnit? Help!
                        Mc Java Newbie

                        OK. I'm getting close!

                        Within Eclipse, I selected the "JPA facet", which then generated the persistence.xml.

                        My next problem brings me to precisely the main point I've been trying to learn about--CMP! My example "Stock" class contains these annotions:

                        @Entity
                        @Table(schema="BrianDb")

                        The Eclipse editor is now showing this error message on the @Table line:

                        "Table 'Stock' cannot be resolved."

                        Unlike the dozens of previous errors solved to get to this point, this error makes me happy! I'm right at the crux of container-managed persistence now, right?

                        BrianDb is my MySql db, and the error message is correct: there is no table named "Stock" in it yet.

                        So next, I'm supposed to do some simple configuration, and that table will be magically created for me, right?

                        If you can tell me how to do that, I will send you a free six pack, and a big bowl of nacho Doritos.

                        Thanks!

                        • 9. Re: Illegal @PersistenceUnit? Help!
                          Mc Java Newbie

                          I've found that if I manually create a table called "Stock", using the MySql Administrator, this error message goes away. So I assume my Eclipse project is correctly viewing my database. I just don't know how to have the tables created automatically on the basis of my annotations and configurations...

                          • 10. Re: Illegal @PersistenceUnit? Help!
                            Mc Java Newbie

                            I changed persistence.properties, and that created the tables. Now my editor is happy. Last task: get the thing to actually run!

                            Thanks very, very much for your help. I was pretty lost without you.

                            --McJava1967

                            • 11. Re: Illegal @PersistenceUnit? Help!
                              Mc Java Newbie

                              IT WORKED!
                              IT WORKED!
                              IT WORKED!

                              I'm PERSISTING!

                              Thanks for your help!

                              I'll be back...