Skip to main content

[SOLVED] Deploying EAR fails on Singleton initialization with "create-tables" configuration

3 replies [Last post]
groverblue
Offline
Joined: 2006-06-23
Points: 0

I'm getting the following error when deploying my EAR application. The issue appears to be that the MSSQL driver is throwing an exception when it attempts to CREATE a table that already exists in the database. IMO, this should prevent the container from creating an EntityManager for injection in the Singleton bean.

Here is the error:

Exception Occurred :Error occurred during deployment: Exception while loading the 
app : javax.ejb.CreateException: Initialization failed for Singleton ApplicationBean.
Please see server.log for more details. PER01003: Deployment encountered SQL
Exceptions: PER01000: Got SQLException executing statement "CREATE TABLE ADDRESS
(ID NUMERIC(19) IDENTITY NOT NULL, ADDRESS1 VARCHAR(40) NOT NULL, ADDRESS2 VARCHAR(40)
NULL, ADDRESS3 VARCHAR(40) NULL, ADDRESSSTATE Char(2), CITY VARCHAR(20) NOT NULL,
COUNTY VARCHAR(20) NULL, ZIP4 Char(4), ZIP5 Char(5), PRIMARY KEY (ID))":
com.microsoft.sqlserver.jdbc.SQLServerException: There is already an object
named 'ADDRESS' in the database.

Here is part of my persistence.xml :

    <properties>
      <property name="eclipselink.logging.level" value="SEVERE"/>
      <property name="eclipselink.ddl-generation" value="create-tables"/>
      <property name="eclipselink.jpa.uppercase-column-names" value="true"/>
    </properties>

Is there a fix for this, or a workaround that doesn't require me to change the ddl-generation type?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04
Points: 0

forums@java.net wrote:
> I'm getting the following error when deploying my EAR application. The
> issue appears to be that the MSSQL driver is throwing an exception
> when it
> attempts to CREATE a table that already exists in the database. IMO,
> this
> should prevent the container from creating an EntityManager for
> injection in
> the Singleton bean.

Create table failure is usually just a warning and do not prevents PU
initialization
>
> Here is the error:
>
> Exception Occurred :Error occurred during deployment: Exception while
> loading
> the app : javax.ejb.CreateException: Initialization failed for Singleton
> ApplicationBean. Please see server.log for more details. PER01003:
> Deployment
> encountered SQL Exceptions: PER01000: Got SQLException executing
> statement
> "CREATE TABLE ADDRESS (ID NUMERIC(19) IDENTITY NOT NULL, ADDRESS1
> VARCHAR(40)
> NOT NULL, ADDRESS2 VARCHAR(40) NULL, ADDRESS3 VARCHAR(40) NULL,
> ADDRESSSTATE
> Char(2), CITY VARCHAR(20) NOT NULL, COUNTY VARCHAR(20) NULL, ZIP4
> Char(4),
> ZIP5 Char(5), PRIMARY KEY (ID))":
> com.microsoft.sqlserver.jdbc.SQLServerException: There is already an
> object
> named 'ADDRESS' in the database.
> Here is part of my persistence.xml :
>
> value="SEVERE"/> value="create-tables"/> name="eclipselink.jpa.uppercase-column-names" value="true"/>
>
> Is there a fix for this, or a workaround that doesn't require me to
> change
> the ddl-generation type?
>
>
> --
>
> [Message sent by forum member 'groverblue']
>
> View Post: http://forums.java.net/node/874439
>
>

groverblue
Offline
Joined: 2006-06-23
Points: 0

Appears to have been a problem with not using an XA connection and XADataSource. Changed to :

Resource Type: javax.sql.XADataSource
Datasource Classname: com.microsoft.sqlserver.jdbc.SQLServerXADataSource
Non Transactional Connections: Enabled

mvatkina
Offline
Joined: 2005-04-04
Points: 0

If you accessing more than one resource in the same transaction, only 1
of them can be a non-XA resource.

-marina

forums@java.net wrote:
> Well, I modified the persistence.xml to remove the table creation, and
> this
> is the error I get now:
>
>
> Exception while loading the app : javax.ejb.CreateException:
> Initialization
> failed for Singleton ApplicationBean javax.ejb.CreateException:
> Initialization failed for Singleton ApplicationBean at
> com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:547)
>
> at
> com.sun.ejb.containers.AbstractSingletonContainer.access$100(AbstractSingletonContainer.java:79)
>
> at
> com.sun.ejb.containers.AbstractSingletonContainer$SingletonContextFactory.create(AbstractSingletonContainer.java:719)
>
> at
> com.sun.ejb.containers.AbstractSingletonContainer.instantiateSingletonInstance(AbstractSingletonContainer.java:451)
>
> at
> org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:216)
>
> at
> org.glassfish.ejb.startup.SingletonLifeCycleManager.initializeSingleton(SingletonLifeCycleManager.java:177)
>
> at
> org.glassfish.ejb.startup.SingletonLifeCycleManager.doStartup(SingletonLifeCycleManager.java:155)
>
> at
> org.glassfish.ejb.startup.EjbApplication.start(EjbApplication.java:177)
> 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
> org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:202)
> at
> org.glassfish.admin.rest.ResourceUtil.runCommand(ResourceUtil.java:195)
> at
> org.glassfish.admin.rest.resources.TemplateListOfResource.createResource(TemplateListOfResource.java:148)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597) at
> com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
>
> at
> com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
>
> at
> com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
>
> at
> com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
>
> at
> com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
>
> at
> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
>
> at
> com.sun.jersey.server.impl.uri.rules.SubLocatorRule.accept(SubLocatorRule.java:134)
>
> at
> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
>
> at
> com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
>
> at
> com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
>
> at
> com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
>
> at
> com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
>
> at
> com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer._service(GrizzlyContainer.java:182)
>
> at
> com.sun.jersey.server.impl.container.grizzly.GrizzlyContainer.service(GrizzlyContainer.java:147)
>
> at
> org.glassfish.admin.rest.adapter.RestAdapter.service(RestAdapter.java:184)
>
> 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(Thread.java:662) Caused by:
> javax.persistence.PersistenceException: Exception [EclipseLink-4002]
> (Eclipse
> Persistence Services - 2.3.0.v20110604-r9504):
> org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
> java.sql.SQLException: Error in allocating a connection. Cause:
> java.lang.IllegalStateException: Local transaction already has 1 non-XA
> Resource: cannot add more resources. Error Code: 0 at
> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:501)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:275)
>
> at
> com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:208)
>
> at
> com.sun.enterprise.container.common.impl.EntityManagerWrapper.createNamedQuery(EntityManagerWrapper.java:532)
>
> at
> com.mycomp.myapp.ejb.ApplicationBean.postContructInitialization(ApplicationBean.java:102)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597) at
> com.sun.ejb.containers.interceptors.BeanCallbackInterceptor.intercept(InterceptorManager.java:1009)
>
> at
> com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
>
> at
> com.sun.ejb.containers.interceptors.CallbackInvocationContext.proceed(CallbackInvocationContext.java:113)
>
> at
> com.sun.ejb.containers.interceptors.SystemInterceptorProxy.doCallback(SystemInterceptorProxy.java:138)
>
> at
> com.sun.ejb.containers.interceptors.SystemInterceptorProxy.init(SystemInterceptorProxy.java:120)
>
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>
> at java.lang.reflect.Method.invoke(Method.java:597) at
> com.sun.ejb.containers.interceptors.CallbackInterceptor.intercept(InterceptorManager.java:964)
>
> at
> com.sun.ejb.containers.interceptors.CallbackChainImpl.invokeNext(CallbackChainImpl.java:65)
>
> at
> com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:393)
>
> at
> com.sun.ejb.containers.interceptors.InterceptorManager.intercept(InterceptorManager.java:376)
>
> at
> com.sun.ejb.containers.AbstractSingletonContainer.createSingletonEJB(AbstractSingletonContainer.java:538)
>
> ... *61 more Caused by: Exception [EclipseLink-4002] (Eclipse Persistence
> Services - 2.3.0.v20110604-r9504):
> org.eclipse.persistence.exceptions.DatabaseException Internal Exception:
> java.sql.SQLException: Error in allocating a connection. Cause:
> java.lang.IllegalStateException: Local transaction already has 1 non-XA
> Resource: cannot add more resources. *Error Code: 0 at
> org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:309)
>
> at
> org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:135)
>
> at
> org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)
>
> at
> org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connectInternal(DatasourceAccessor.java:330)
>
> at
> org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.connectInternal(DatabaseAccessor.java:293)
>
> at
> org.eclipse.persistence.internal.databaseaccess.DatasourceAccessor.connect(DatasourceAccessor.java:418)
>
> at
> org.eclipse.persistence.sessions.server.ConnectionPool.buildConnection(ConnectionPool.java:216)
>
> at
> org.eclipse.persistence.sessions.server.ExternalConnectionPool.startUp(ExternalConnectionPool.java:146)
>
> at
> org.eclipse.persistence.sessions.server.ServerSession.connect(ServerSession.java:489)
>
> at
> org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:617)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)
>
> at
> org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:472)
>
> ... 86 more Caused by: java.sql.SQLException: Error in allocating a
> connection. Cause: java.lang.IllegalStateException: Local transaction
> already
> has 1 non-XA Resource: cannot add more resources. at
> com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:120) at
> org.eclipse.persistence.sessions.JNDIConnector.connect(JNDIConnector.java:123)
>
> ... 96 more Caused by: javax.resource.spi.ResourceAllocationException:
> Error
> in allocating a connection. Cause: java.lang.IllegalStateException: Local
> transaction already has 1 non-XA Resource: cannot add more resources. at
> com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:307)
>
> at
> com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:190)
>
> at
> com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:165)
>
> at
> com.sun.enterprise.connectors.ConnectionManagerImpl.allocateConnection(ConnectionManagerImpl.java:160)
>
> at com.sun.gjc.spi.base.DataSource.getConnection(DataSource.java:113)
> ... 97
> more Caused by: com.sun.appserv.connectors.internal.api.PoolingException:
> java.lang.IllegalStateException: Local transaction already has 1 non-XA
> Resource: cannot add more resources. at
> com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:218)
>
> at
> com.sun.enterprise.connectors.ConnectionManagerImpl.getResource(ConnectionManagerImpl.java:338)
>
> at
> com.sun.enterprise.connectors.ConnectionManagerImpl.internalGetConnection(ConnectionManagerImpl.java:301)
>
> ... 101 more Caused by:
> com.sun.appserv.connectors.internal.api.PoolingException:
> java.lang.IllegalStateException: Local transaction already has 1 non-XA
> Resource: cannot add more resources. at
> com.sun.enterprise.resource.rm.SystemResourceManagerImpl.enlistResource(SystemResourceManagerImpl.java:107)
>
> at
> com.sun.enterprise.resource.pool.PoolManagerImpl.getResource(PoolManagerImpl.java:208)
>
> ... 103 more Caused by: java.lang.IllegalStateException: Local
> transaction
> already has 1 non-XA Resource: cannot add more resources. at
> com.sun.enterprise.transaction.JavaEETransactionManagerSimplified.enlistResource(JavaEETransactionManagerSimplified.java:334)
>
> at
> com.sun.enterprise.resource.rm.SystemResourceManagerImpl.enlistResource(SystemResourceManagerImpl.java:103)
>
> ... 104 more
>
>
>
>
> --
>
> [Message sent by forum member 'groverblue']
>
> View Post: http://forums.java.net/node/874439
>
>