Bundle has invalid content in tables.sql:_create table YYY - liferay

I'm trying to deploy a service builder module on my Liferay portal. But I'm getting the error below.
Could this be caused because I already have that table on my database? The table was created manually as part of an older project, and now I'm trying to reuse that existing table.
Thanks in advance.
2019-07-24 12:09:47.770 ERROR [pipe-start
998][com_liferay_portal_upgrade_impl:97] Invocation to listener threw
exception com.liferay.portal.kernel.upgrade.UpgradeException: Bundle
com.xxxx.xxxx.service_1.0.0 [998] has invalid
content in tables.sql:_create table dbo.news ( id_ INTEGER not null
primary key,_ title VARCHAR(75) null,_ push_notification
BOOLEAN,_ date_time VARCHAR(75) null,_ short_description VARCHAR(75)
null,_ long_description VARCHAR(75) null,_ picture VARCHAR(75)
null,_ type_ VARCHAR(75) null,_ tag VARCHAR(75) null_); [Sanitized]
at
com.liferay.portal.spring.extender.internal.context.ParentModuleApplicationContextExtender$InitialUpgradeStep.upgrade(ParentModuleApplicationContextExtender.java:220)
at
com.liferay.portal.upgrade.internal.executor.UpgradeExecutor$UpgradeInfosRunnable.run(UpgradeExecutor.java:159)
at
com.liferay.portal.output.stream.container.internal.OutputStreamContainerFactoryTrackerImpl.runWithSwappedLog(OutputStreamContainerFactoryTrackerImpl.java:119)
at
com.liferay.portal.upgrade.internal.executor.UpgradeExecutor.executeUpgradeInfos(UpgradeExecutor.java:110)
at
com.liferay.portal.upgrade.internal.executor.UpgradeExecutor.execute(UpgradeExecutor.java:87)
at
com.liferay.portal.upgrade.internal.release.osgi.commands.ReleaseManagerOSGiCommands$UpgradeInfoServiceTrackerMapListener.keyEmitted(ReleaseManagerOSGiCommands.java:485)
at
com.liferay.portal.upgrade.internal.release.osgi.commands.ReleaseManagerOSGiCommands$UpgradeInfoServiceTrackerMapListener.keyEmitted(ReleaseManagerOSGiCommands.java:474)
at
com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl$DefaultEmitter.emit(ServiceTrackerMapImpl.java:222)
at
com.liferay.osgi.service.tracker.collections.map.PropertyServiceReferenceMapper.map(PropertyServiceReferenceMapper.java:43)
at
com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl$ServiceReferenceServiceTrackerCustomizer.addingService(ServiceTrackerMapImpl.java:260)
at
com.liferay.osgi.service.tracker.collections.internal.map.ServiceTrackerMapImpl$ServiceReferenceServiceTrackerCustomizer.addingService(ServiceTrackerMapImpl.java:248)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:943)
at
org.osgi.util.tracker.ServiceTracker$Tracked.customizerAdding(ServiceTracker.java:1)
at
org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:256)
at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:229)
at
org.osgi.util.tracker.ServiceTracker$Tracked.serviceChanged(ServiceTracker.java:903)
at
org.eclipse.osgi.internal.serviceregistry.FilteredServiceListener.serviceChanged(FilteredServiceListener.java:109)
at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEventPrivileged(ServiceRegistry.java:891)
at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.publishServiceEvent(ServiceRegistry.java:804)
at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistrationImpl.register(ServiceRegistrationImpl.java:127)
at
org.eclipse.osgi.internal.serviceregistry.ServiceRegistry.registerService(ServiceRegistry.java:228)
at
org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:469)
at
org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:487)
at
org.eclipse.osgi.internal.framework.BundleContextImpl.registerService(BundleContextImpl.java:1004)
at
com.liferay.portal.spring.extender.internal.context.ParentModuleApplicationContextExtender$ParentModuleApplicationContextExtension._processInitialUpgrade(ParentModuleApplicationContextExtender.java:613)
at
com.liferay.portal.spring.extender.internal.context.ParentModuleApplicationContextExtender$ParentModuleApplicationContextExtension.start(ParentModuleApplicationContextExtender.java:571)
at
org.apache.felix.utils.extender.AbstractExtender.createExtension(AbstractExtender.java:259)
at
org.apache.felix.utils.extender.AbstractExtender.modifiedBundle(AbstractExtender.java:232)
at
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:488)
at
org.osgi.util.tracker.BundleTracker$Tracked.customizerModified(BundleTracker.java:1)
at
org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:232)
at
org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:450)
at
org.eclipse.osgi.internal.framework.BundleContextImpl.dispatchEvent(BundleContextImpl.java:908)
at
org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at
org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:148)
at
org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEventPrivileged(EquinoxEventPublisher.java:230)
at
org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:137)
at
org.eclipse.osgi.internal.framework.EquinoxEventPublisher.publishBundleEvent(EquinoxEventPublisher.java:129)
at
org.eclipse.osgi.internal.framework.EquinoxContainerAdaptor.publishModuleEvent(EquinoxContainerAdaptor.java:191)
at org.eclipse.osgi.container.Module.publishEvent(Module.java:476)
at org.eclipse.osgi.container.Module.start(Module.java:467) at
org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:428)
at
org.eclipse.osgi.internal.framework.EquinoxBundle.start(EquinoxBundle.java:447)
at
org.eclipse.equinox.console.commands.EquinoxCommandProvider.start(EquinoxCommandProvider.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498) at
org.apache.felix.gogo.runtime.Reflective.invoke(Reflective.java:139)
at
org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:91)
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:599)
at
org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:526)
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:415)
at org.apache.felix.gogo.runtime.Pipe.doCall(Pipe.java:416) at
org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:229) at
org.apache.felix.gogo.runtime.Pipe.call(Pipe.java:59) at
java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748) Caused by:
java.sql.SQLSyntaxErrorException: unexpected token: DBO at
org.hsqldb.jdbc.JDBCUtil.sqlException(JDBCUtil.java:376) at
org.hsqldb.jdbc.JDBCUtil.sqlException(JDBCUtil.java:247) at
org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1817) at
org.hsqldb.jdbc.JDBCStatement.executeUpdate(JDBCStatement.java:208)
at
com.zaxxer.hikari.pool.ProxyStatement.executeUpdate(ProxyStatement.java:117)
at
com.zaxxer.hikari.pool.HikariProxyStatement.executeUpdate(HikariProxyStatement.java)
at com.liferay.portal.dao.db.BaseDB.runSQL(BaseDB.java:294) at
com.liferay.portal.dao.db.BaseDB.runSQL(BaseDB.java:264) at
com.liferay.portal.dao.db.BaseDB.runSQLTemplateString(BaseDB.java:452)
at
com.liferay.portal.dao.db.BaseDB.runSQLTemplateString(BaseDB.java:509)
at
com.liferay.portal.spring.extender.internal.context.ParentModuleApplicationContextExtender$InitialUpgradeStep.upgrade(ParentModuleApplicationContextExtender.java:216)
... 59 more Caused by: org.hsqldb.HsqlException: unexpected token:
DBO at org.hsqldb.error.Error.parseError(Error.java:101) at
org.hsqldb.ParserBase.unexpectedToken(ParserBase.java:815) at
org.hsqldb.ParserBase.checkIsIrregularCharInIdentifier(ParserBase.java:335)
at org.hsqldb.ParserDQL.checkIsSchemaObjectName(ParserDQL.java:115)
at org.hsqldb.ParserDQL.readNewSchemaObjectName(ParserDQL.java:5912)
at org.hsqldb.ParserTable.compileCreateTable(ParserTable.java:78) at
org.hsqldb.ParserDDL.compileCreate(ParserDDL.java:156) at
org.hsqldb.ParserCommand.compilePart(ParserCommand.java:236) at
org.hsqldb.ParserCommand.compileStatements(ParserCommand.java:91) at
org.hsqldb.Session.executeDirectStatement(Session.java:1227) at
org.hsqldb.Session.execute(Session.java:1018) at
org.hsqldb.jdbc.JDBCStatement.fetchResult(JDBCStatement.java:1809)
... 67 more

The fact that the table is already existing is surely the issue. Service builder deployment keep track of the "schema" version that is currently deployed, and if there is none, they create it using the sql script.
In your case, I would suggest
renaming or exporting and delete your current table
deploying your new service
move your data back to the new table created
Once this is done, don’t ever touch that data directly in the database, let your new service handle all future interaction. In fact, it might even be better to import the old data using the service API.

Related

GW: Null Pointer Exception after click on Approve button

Getting NPE after click on Approve button for the payment activity.And also, getting NPE for Reject button. Even though user is authorized to approve the activity but unable to figure it out from which point it throws null value.
Here are the below logs-
ERROR Displaying to the user an exception message that is not a UserDisplayableException
java.lang.NullPointerException
at com.guidewire.pl.system.entity.proxy.AbstractKeyableBeanProxy.getFieldValue(AbstractKeyableBeanProxy.java:159)
at com.guidewire.pl.system.entity.proxy.BeanProxy.getFieldValue(BeanProxy.java:593)
at com.guidewire.pl.system.graph.AbstractForeignKeyLink.getSourceIdsFromBundleIfPossible(AbstractForeignKeyLink.java:32)
at com.guidewire.pl.system.graph.Chain.getSourceIdsFromBundleIfPossible(Chain.java:139)
at com.guidewire.pl.system.graph.Chain.getSourceIdsFromBundleIfPossible(Chain.java:135)
at com.guidewire.pl.system.graph.Chain.getSourceIdsViaBundleIfPossible(Chain.java:44)
at com.guidewire.pl.system.integration.messaging.events.TopLevelEntityGraph.processChainInBundle(TopLevelEntityGraph.java:79)
at com.guidewire.pl.system.integration.messaging.events.TopLevelEntityGraph.getTopLevelObjectIdsReferringToUpdatedBean(TopLevelEntityGraph.java:43)
at com.guidewire.pl.system.bundle.validation.GraphToValidatableBeansImpl.getTopLevelObjectIdsReferringToUpdatedBean(GraphToValidatableBeansImpl.java:63)
at com.guidewire.pl.system.bundle.validation.RootValidatableBeansFinderImpl.findRootBeansToValidate(RootValidatableBeansFinderImpl.java:145)
at com.guidewire.pl.system.preupdate.PreUpdateHelper.executePreUpdateRules(PreUpdateHelper.java:21)
at com.guidewire.pl.system.database.DatabaseBundleWriter.prepareBundleForWritePreIDGeneration(DatabaseBundleWriter.java:73)
at com.guidewire.pl.system.bundle.BundleWriter.commitBundle(BundleWriter.java:85)
at com.guidewire.pl.system.transaction.SessionImpl.flush(SessionImpl.java:139)
at com.guidewire.pl.system.transaction.SessionImpl.commit(SessionImpl.java:200)
at com.guidewire.pl.system.transaction.TransactionManagerImpl.execute(TransactionManagerImpl.java:115)
at com.guidewire.pl.system.transaction.TransactionManagerImpl.commitBundle(TransactionManagerImpl.java:59)
at com.guidewire.pl.system.bundle.EntityBundleImpl.commitAndGetBeans(EntityBundleImpl.java:1669)
at com.guidewire.pl.system.bundle.EntityBundleImpl.commit(EntityBundleImpl.java:1611)
at com.guidewire.pl.web.navigation.EditControllerImpl.commitChanges(EditControllerImpl.java:63)
at com.guidewire.pl.web.navigation.Location.innerCommitChanges(Location.java:476)
at com.guidewire.pl.web.navigation.Location.commitChanges(Location.java:425)
at com.guidewire.pl.web.navigation.LocationConfigCodeGen$6.handleCall(LocationConfigCodeGen.java:91)
at gw.internal.gosu.runtime.GosuRuntimeMethods.invokeMethodInfo(GosuRuntimeMethods.java:252)
at fragment_.pcffragment.ApprovalDetailWorksheet.ApprovalDetailScreen.ApprovalDetailWorksheet_ApproveButton.ToolbarButton_action_0_6.evaluate(Unknown Source)
at gw.internal.gosu.parser.fragments.GosuFragment.evaluate(GosuFragment.java:485) - ({
beforeCommitAction = \ -> Activity.approve()
CurrentLocation.commit()

Lagom framework / Persistent Read Side / Cassandra / DataStax / Table unconfigured

I successfully compiled the code example from http://www.lagomframework.com/documentation/1.0.x/ReadSide.html
It's about the read-side of the CQRS schema.
There is only problem: it doesn't run.
Looks like configuration problem... and the official documentation of Lagom at this point is very incomplete.
The error says:
java.util.concurrent.CompletionException: java.util.concurrent.ExecutionException: com.datastax.driver.core.exceptions.InvalidQueryException: unconfigured table postsummary
Alright, there's a line in the code that does cassandra query, selecting & inserting from & to a table named postsummary.
I thought the tables are auto-created by default. Anyway, in doubt, I simply added this line to my application.conf:
cassandra-journal.keyspace-autocreate = true
cassandra-journal.tables-autocreate = true
Still..., no luck, same error after restarting.
Maybe it has something to do with another error during startup, that says:
[warn] a.p.c.j.CassandraJournal - Failed to connect to Cassandra and initialize. It will be retried on demand. Caused by: ServiceLocator is not bound
I thought... alright, maybe it's trying to contact 9042 (default cassandra port), while lagom by default starts embedded cassandra at 4000.
So I tried adding these lines in application.conf:
cassandra-journal.contact-points = ["127.0.0.1"]
cassandra-journal.port = 4000
lagom.persistence.read-side.cassandra.contact-points = ["127.0.0.1"]
lagom.persistence.read-side.cassandra.port = 4000
Still..., no luck, same error.
Can anyone help me solve it. I need to get this example running, crucial part of CQRS study using lagom.
Some ref.: https://github.com/lagom/lagom/blob/master/persistence/src/main/resources/reference.conf
Here are some screenshots:
Btw, I solved it by creating the tables inside the code, calling this method from the prepare method of the event processor:
private CompletionStage<Done> prepareTables(CassandraSession session) {
CompletionStage<Done> preparePostSummary = session.executeCreateTable(
"CREATE TABLE IF NOT EXISTS postsummary ("
+ "partition bigint, id text, title text, "
+ "PRIMARY KEY (id))"
).whenComplete((ok, err) -> {
if (err != null) {
System.out.println("Failed to create postsummary table, due to: " + err.getMessage());
}
});
CompletionStage<Done> prepareBlogEventOffset = session.executeCreateTable(
"CREATE TABLE IF NOT EXISTS blogevent_offset ("
+ "partition bigint, offset uuid, "
+ "PRIMARY KEY (offset))"
).whenComplete((ok, err) -> {
if (err != null) {
System.out.println("Failed to create blogevent_offset table, due to: " + err.getMessage());
}
});
return preparePostSummary.thenCompose(a -> prepareBlogEventOffset);
}
Thanks!,
Raka
I have a working example here. Even if it does not use auto created tables :
https://github.com/lagom/activator-lagom-cargotracker/blob/master/registration-impl/src/main/java/sample/cargotracker/registration/impl/CargoEventProcessor.java

provide a link to navigate to control panel from liferay theme

I am trying to provide a link to navigate to control panel from my theme.
I used the following piece of code.
<li>Manage Your Profile</li>
This worked fine in my local test environment.
But when I move this to production , I got following error.
10:10:13,998 ERROR [IncludeTag:231] Current URL /group/control_panel/manage?p_p_auth=9AUrwzDp&p_p_id=2&p_p_lifecycle=0&p_p_state=maximized&p_p_mode=view&p_p_col_count=1&refererPlid=25014&_2_struts_action=%2Fmy_account%2Fedit_user&_2_backURL=%2Fgroup%2F19765%2Fdashboard generates exception: An exception occurred processing JSP page /html/portlet/enterprise_admin/init.jsp at line 221
218: boolean isHavingUpdatePermission = false;
219: boolean isHavingAssignUserRolesPermission = false;
220:
221: boolean isOrganization = GroupLocalServiceUtil.getGroup(themeDisplay.getDoAsGroupId()).isOrganization();
222: long orgId = GroupLocalServiceUtil.getGroup(themeDisplay.getDoAsGroupId()).getOrganizationId();
223:
224: List<Role> objRolesList = RoleLocalServiceUtil.getUserGroupRoles(themeDisplay.getUserId(),themeDisplay.getDoAsGroupId());
Stacktrace:
10:10:13,999 ERROR [IncludeTag:154] com.liferay.portal.NoSuchGroupException: No Group exists with the primary key 0
at com.liferay.portal.service.persistence.GroupPersistenceImpl.findByPrimaryKey(GroupPersistenceImpl.java:723)
at com.liferay.portal.service.impl.GroupLocalServiceImpl.getGroup(GroupLocalServiceImpl.java:517)
at com.liferay.portal.dao.jdbc.aop.DynamicDataSourceTransactionInterceptor.invoke(DynamicDataSourceTransactionInterceptor.java:44)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:58)
at com.liferay.portal.service.GroupLocalServiceUtil.getGroup(GroupLocalServiceUtil.java:166)
at org.apache.jsp.html.portlet.enterprise_005fadmin.edit_005fuser_jsp._jspService(edit_005fuser_jsp.java:1162)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:646)
at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:551)
at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:488)
at com.liferay.taglib.util.IncludeTag.include(IncludeTag.java:175)
Please help me to solve this issue .
Thanks In advance
I don't see how do you construct the link, but here is my code which I use for the same task:
#if($themeDisplay.getPermissionChecker().isOmniAdmin())
Control Panel
#end

Nullpointer exception while creating table using CQL3?

I am trying to create a table in cassandra DB using cql3 and it throws this error on cassadra server and the table is not created, can anyone tell, what is the reason behind it?
Script -->
use demodb1;
CREATE TABLE fishblogscolumnfamily (
userid varchar,
when timestamp,
fishtype varchar,
blog varchar,
image blob,
PRIMARY KEY (userid, when, fishtype)
);
Error:
INFO 14:28:27,057 Create new ColumnFamily:
org.apache.cassandra.config.CFMetaData#70177017[cfId=1024,ksName=demodb1,cfName=fishblogscolumnfamily,cfType=Standa,comparator=org.apache.cassandra.db.marshal.CompositeType(org.apache.cassandra.db.marshal.DateType,org.apache.cassandra.db.marshal.UTF8Type,org.apache.cassandra.db.marshal.UTF8Type),subcolumncomparator=<null>,comment=,readRepairChance=0.1,dclocalReadRepairChance=0.0,replicateOnWrite=true,gcGraceSeconds=864000,defaultValidator=org.apache.cassandra.db.marshal.UTF8Type,keyValidator=org.apache.cassandra.db.marshal.UTF8Type,minCompactionThreshold=4,maxCompactionThreshold=32,keyAlia
java.nio.HeapByteBuffer[pos=0 lim=6 cap=6],columnAliases=[java.nio.HeapByteBuffer[pos=0 lim=4 cap=4], java.nio.HeapByteBuffer[pos=0 lim=8 cap=8]],valueAlias=<n
l>,column_metadata={java.nio.HeapByteBuffer[pos=0 lim=5 cap=5]=ColumnDefinition{name=696d616765, validator=org.apache.cassandra.db.marshal.BytesType, index_typ
null, index_name='null', component_index=2}, java.nio.HeapByteBuffer[pos=0 lim=4 cap=4]=ColumnDefinition{name=626c6f67, validator=org.apache.cassandra.db.marsh
.UTF8Type, index_type=null, index_name='null', component_index=2}},compactionStrategyClass=class org.apache.cassandra.db.compaction.SizeTieredCompactionStrateg
compactionStrategyOptions={},compressionOptions={sstable_compression=org.apache.cassandra.io.compress.SnappyCompressor},bloomFilterFpChance=<null>,caching=KEYS
NLY]
ERROR 14:28:27,071 Error occurred during processing of message.
java.lang.NullPointerException
at org.apache.cassandra.utils.FastByteComparisons$LexicographicalComparerHolder$UnsafeComparer.compareTo(FastByteComparisons.java:223)
at org.apache.cassandra.utils.FastByteComparisons$LexicographicalComparerHolder$UnsafeComparer.compareTo(FastByteComparisons.java:110)
at org.apache.cassandra.utils.FastByteComparisons.compareTo(FastByteComparisons.java:41)
at org.apache.cassandra.utils.FBUtilities.compareUnsigned(FBUtilities.java:184)
at org.apache.cassandra.utils.ByteBufferUtil.compareUnsigned(ByteBufferUtil.java:89)
at org.apache.cassandra.db.marshal.BytesType.bytesCompare(BytesType.java:58)
at org.apache.cassandra.db.marshal.AsciiType.compare(AsciiType.java:48)
at org.apache.cassandra.db.marshal.AsciiType.compare(AsciiType.java:28)
at org.apache.cassandra.db.marshal.AbstractCompositeType.compare(AbstractCompositeType.java:80)
at org.apache.cassandra.db.marshal.AbstractCompositeType.compare(AbstractCompositeType.java:32)
at java.util.TreeMap.rbInsert(Unknown Source)
at java.util.TreeMap.put(Unknown Source)
at org.apache.cassandra.db.TreeMapBackedSortedColumns.addColumn(TreeMapBackedSortedColumns.java:95)
at org.apache.cassandra.db.AbstractColumnContainer.addColumn(AbstractColumnContainer.java:109)
at org.apache.cassandra.db.AbstractColumnContainer.addColumn(AbstractColumnContainer.java:104)
at org.apache.cassandra.config.ColumnDefinition.toSchema(ColumnDefinition.java:195)
at org.apache.cassandra.config.CFMetaData.toSchema(CFMetaData.java:1159)

Encrypting datasource passwords: java.lang.SecurityException: Unauthenticated caller:null

I'm trying to encrypt my database password using a JBOSS security domain.
The datasource is defined in oracle-ds.xml as follows:
<datasources>
<local-tx-datasource>
<jndi-name>OracleDS</jndi-name>
<connection-url>jdbc:oracle:thin:#dbhost:1521:db</connection-url>
<driver-class>oracle.jdbc.driver.OracleDriver</driver-class>
<!-- app works fine when you use unencrypted password like this
<user-name>username</user-name>
<password>unencrypted_pass</password>
-->
<!-- Use the security domain defined in conf/login-config.xml for username and encrypted password-->
<security-domain>Encrypt-my-Password</security-domain>
....etc
The login-config.xml file contains this entry:
<application-policy name="Encrypt-my-Password">
<authentication>
<login-module
code="com.mycompany.global.er.util.ErSecureIdentityLoginModule"
flag="required">
<module-option name="username">databaseUsername</module-option>
<module-option name="password">232487h4873hf4</module-option>
<module-option name="managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=OracleDS</module-option>
</login-module>
</authentication>
</application-policy>
NB the ErSecureIdentityLoginModule is a class already used to encrypt / decrypt DB passwords in another application, where it works fine.
As soon as I started using this config the application throws an exception as follows when you try to access the datasource:
java.lang.SecurityException: Unauthenticated caller:null
org.jboss.security.integration.JBossSecuritySubjectFactory.createSubject(JBossSecuritySubjectFactory.java:92)
org.jboss.resource.connectionmanager.BaseConnectionManager2.getSubject(BaseConnectionManager2.java:687)
org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateConnection(BaseConnectionManager2.java:495)
org.jboss.resource.connectionmanager.BaseConnectionManager2$ConnectionManagerProxy.allocateConnection(BaseConnectionManager2.java:941)
org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(WrapperDataSource.java:89)
org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:92)
org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:111)
org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2101)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1325)
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
com.mycompany.er.batch.data.DbHelper.createEntityManager(DbHelper.java:30)
com.mycompany.er.batch.data.DbHelper.createAndBegin(DbHelper.java:49)
com.mycompany.er.basman.HibernateTransactionFilter.doFilter(HibernateTransactionFilter.java:53)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
I downloaded the source code for jboss 5.0.1GA and debugged with TRACE enabled. There is an interesting stack trace produced:
2012-03-12 18-13-40:Login failure
javax.security.auth.login.LoginException: java.lang.NullPointerException
at org.jboss.resource.security.SubjectActions$AddPrincipalsAction.run(SubjectActions.java:101)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.resource.security.SubjectActions.addPrincipals(SubjectActions.java:139)
at org.jboss.resource.security.ConfiguredIdentityLoginModule.login(ConfiguredIdentityLoginModule.java:98)
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 javax.security.auth.login.LoginContext.invoke(LoginContext.java:769)
at javax.security.auth.login.LoginContext.access$000(LoginContext.java:186)
at javax.security.auth.login.LoginContext$4.run(LoginContext.java:683)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
at javax.security.auth.login.LoginContext.login(LoginContext.java:579)
at org.jboss.security.plugins.auth.JaasSecurityManagerBase.defaultLogin(JaasSecurityManagerBase.java:552)
at org.jboss.security.plugins.auth.JaasSecurityManagerBase.authenticate(JaasSecurityManagerBase.java:486)
at org.jboss.security.plugins.auth.JaasSecurityManagerBase.isValid(JaasSecurityManagerBase.java:365)
at org.jboss.security.plugins.JaasSecurityManager.isValid(JaasSecurityManager.java:160)
at org.jboss.security.integration.JBossSecuritySubjectFactory.createSubject(JBossSecuritySubjectFactory.java:9
0)
The NullPointerException refers to this line of code in org.jboss.resource.security.SubjectActions:
static class AddPrincipalsAction implements PrivilegedAction
{
Subject subject;
Principal p;
AddPrincipalsAction(Subject subject, Principal p)
{
this.subject = subject;
this.p = p;
}
public Object run()
{
subject.getPrincipals().add(p);
return null;
}
}
However this doesn't help much, and I can't understand what I'm doing wrong.
Help!
I have since got this working. I had to remove a shedload of optional jboss components but it's not 100% clear how I fixed it exactly. One possibility is that the password encryption was not correct - ie I was using the wrong library to encrypt it, so it wasn't being decrypted correctly.

Resources