How to allow selection then deselection in selectManyChoice LOV outside a view criteria - oracle-adf

here is my issue.
I got a selectManyChoice in a form (that is not part of a view criteria). Everything work just fine except when a user select 1 or multiple entries, they can't deselect them all otherwise I get a PPR exception.
The setup I have is a simple LOV based on a query, that was made available in my AM data model, I simply dragged the LOV from my Data control to my form to a selectManyChoice. The selectManyChoice is in autoSubmit because I also got a onValueChangeListener that need to be prompted.
without my onValueChangeListener I still get the error the same way (selecting something and then de-selecting everything)
Leaving the selection empty doesn't generate any error and let the form be used normally, but selecting something and then de-selecting it cause the error...
For information purpose, I use jDeveloper version 11.1.1.9.0
Thanks in advance !
Here is the PPR error launched in case it can help
java.lang.NullPointerException
at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.findObjectFromIndex( FacesCtrlListBinding.java:292)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.getInputValue( FacesCtrlListBinding.java:215)
at oracle.jbo.uicli.binding.JUCtrlValueBinding.internalGet(JUCtrlValueBinding.java:2374)
at oracle.jbo.uicli.binding.JUCtrlListBinding.internalGet(JUCtrlListBinding.java:3807)
at oracle.adfinternal.view.faces.model.binding.FacesCtrlListBinding.internalGet( FacesCtrlListBinding.java:524)
at oracle.adf.model.binding.DCControlBinding.get(DCControlBinding.java:768)
at javax.el.MapELResolver.getValue(MapELResolver.java:196)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:173)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:200)
at com.sun.el.parser.AstValue.getValue(AstValue.java:138)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:206)
at org.apache.myfaces.trinidad.bean.FacesBeanImpl.getProperty(FacesBeanImpl.java:68)
at org.apache.myfaces.trinidad.component.UIXComponentBase.getProperty(UIXComponentBase.java:1429)
at org.apache.myfaces.trinidad.component.UIXValue.getValue(UIXValue.java:79)
at org.apache.myfaces.trinidad.component.UIXEditableValue.validate(UIXEditableValue.java:187)
at org.apache.myfaces.trinidad.component.UIXEditableValue._executeValidate(UIXEditableValue.java:616)
at org.apache.myfaces.trinidad.component.UIXEditableValue.processValidators(UIXEditableValue.java:304)
at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl$ProcessValidationsCallback.invokeContextCallback (LifecycleImpl.java:1675)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1661)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.invokeOnComponent( ContextSwitchingComponent.java:223)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnComponent(UIXComponentBase.java:1682)
at org.apache.myfaces.trinidad.component.UIXComponentBase.invokeOnChildrenComponents( UIXComponentBase.java:1565)
at oracle.adf.view.rich.component.fragment.UIXInclude.invokeOnComponent(UIXInclude.java:157)

Apparently there is a patch for it the bug occur from version 11.1.1.7.0 to 11.1.1.9.0 here is the link to the oracle ticket describing the issue
support.oracle.com ticket page
the patch number needed to fix this issue is 16224082
this issue is fixed in 12.1.3.0.0

Related

I am not creating a table but am getting CREATE TABLE permission denied in database

I am using a Spring Boot application to read/write from a SQL Server database. Everything is working but I get a "CREATE TABLE permission denied in database" error every time I start the application even though I don't want to create a table. My database configuration class looks like this.
#Configuration
public class DashboardDbConfiguration {
#Bean
public DataSource getDataSource(){
DataSourceBuilder<?> dsBuilder = DataSourceBuilder.create();
dsBuilder.driverClassName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
dsBuilder.url("jdbc:sqlserver://ip:xxx;databaseName=name");
dsBuilder.username("AppId");
dsBuilder.password("password");
return dsBuilder.build();
}
}
My application.properties file has the following.
spring.security.user.name=userName
spring.security.user.password=userPassword
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.SQLServer2012Dialect
spring.jpa.hibernate.ddl-auto=update
The actual error looks like this.
2020-05-21 09:53:02.003 WARN 9828 --- [ restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlString(AbstractSchemaMigrator.java:559) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.applySqlStrings(AbstractSchemaMigrator.java:504) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.createTable(AbstractSchemaMigrator.java:277) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.GroupedSchemaMigratorImpl.performTablesMigration(GroupedSchemaMigratorImpl.java:71) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.performMigration(AbstractSchemaMigrator.java:207) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.internal.AbstractSchemaMigrator.doMigration(AbstractSchemaMigrator.java:114) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:183) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:312) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:462) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:892) [hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:57) [spring-orm-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:365) [spring-orm-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:390) [spring-orm-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:377) [spring-orm-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:341) [spring-orm-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1758) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1695) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:573) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$$Lambda$103.0000000011F9B370.getObject(Unknown Source) ~[na:na]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) [spring-beans-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:780) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:412) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
at com.dashboard.dashboardApplication.DashboardWebApplication.main(DashboardWebApplication.java:30) ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0-internal]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95) ~[na:1.8.0-internal]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:55) ~[na:1.8.0-internal]
at java.lang.reflect.Method.invoke(Method.java:507) ~[na:2.6 (06-30-2015)]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.0.5.RELEASE.jar:2.0.5.RELEASE]
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: CREATE TABLE permission denied in database 'DashboardTest'.
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:258) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1535) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:845) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:752) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7151) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2478) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:219) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:199) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.microsoft.sqlserver.jdbc.SQLServerStatement.execute(SQLServerStatement.java:729) ~[mssql-jdbc-6.2.2.jre8.jar:na]
at com.zaxxer.hikari.pool.ProxyStatement.execute(ProxyStatement.java:95) ~[HikariCP-2.7.9.jar:na]
at com.zaxxer.hikari.pool.HikariProxyStatement.execute(HikariProxyStatement.java) ~[HikariCP-2.7.9.jar:na]
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
... 40 common frames omitted
Is there a way to eliminate this error?
You find answer in this post How does spring.jpa.hibernate.ddl-auto property exactly work in Spring? - you can set spring.jpa.hibernate.ddl-auto=none

Spark - Reading from SQL Server using com.microsoft.azure

I am trying to read from a table using com.microsoft.azure. Below is the code snippet
import org.apache.log4j.{Level, Logger}
import org.apache.spark.sql.SparkSession
import com.microsoft.azure.sqldb.spark.config.Config
import com.microsoft.azure.sqldb.spark.connect._
import com.microsoft.azure.sqldb.spark.query._
import org.apache.spark.sql.functions.to_date
val spark = SparkSession.builder().master("local[*]").appName("DbApp").getOrCreate()
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver")
val config = Config(Map(
"url" -> "jdbc:sqlserver://localhost:1433",
"databaseName" -> "Student",
"dbTable" -> "dbo.MemberDetail",
"authentication" -> "SqlPassword",
"user" -> "test",
"password" -> "****"
))
val df = spark.sqlContext.read.sqlDB(config)
println("Total rows: " + df.count)
However I am getting below error
Exception in thread "main" java.lang.NoClassDefFoundError: scala/Product$class
at com.microsoft.azure.sqldb.spark.config.SqlDBConfigBuilder.<init>(SqlDBConfigBuilder.scala:31)
at com.microsoft.azure.sqldb.spark.config.Config$.apply(Config.scala:254)
at com.microsoft.azure.sqldb.spark.config.Config$.apply(Config.scala:235)
at DbApp$.main(DbApp.scala:55)
at DbApp.main(DbApp.scala)
MSSQL JDBC Version: mssql-jdbc-7.2.2.jre8
azure-sqldb-spark version: 1.0.2
Could anyone kindly guide me what am I doing wrong.?
The class doesn't seem to be set in your config nor specified anywhere else. Class.forName just validates presence of the JDBC driver. The driver is also for microsoft.sqlserver, which is different library.
Consider using this:
import com.microsoft.sqlserver.jdbc.SQLServerDriver
import java.util.Properties
val jdbcHostname = "localhost"
val jdbcPort = 1433
val jdbcDatabase = "Student"
val jdbcTable = "dbo.MemberDetail"
val MyDBUrl = s"jdbc:sqlserver://${jdbcHostname}:${jdbcPort};database=${jdbcDatabase}"
val MyDBProperties = new Properties()
MyDBProperties.put("user", "test")
MyDBProperties.put("password", "****")
MyDBProperties.setProperty("Driver", "com.microsoft.sqlserver.jdbc.SQLServerDriver")
val df = spark.read.jdbc(MyDBUrl, jdbcTable, MyDBProperties)
This approach was most stable in my environment (using Databricks and Azure SQL DB).
Related knowledgebase article available here.
Since you are using azure-sqldb-spark to connect to SQL server.
All connection properties in Microsoft JDBC Driver for SQL Server are supported in this connector. Add connection properties as fields in the com.microsoft.azure.sqldb.spark.config.Config object.
You don't need to create the jdbc driver Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") again.
Your cold should be like this:
import com.microsoft.azure.sqldb.spark.config.Config
import com.microsoft.azure.sqldb.spark.connect._
val config = Config(Map(
"url" -> "locaohost",
"databaseName" -> "MyDatabase",
"dbTable" -> "dbo.Clients",
"user" -> "username",
"password" -> "*********",
"connectTimeout" -> "5", //seconds
"queryTimeout" -> "5" //seconds
))
val collection = sqlContext.read.sqlDB(config)
collection.show()
Please ref:
Connect Spark to SQL DB using the connector
azure-sqldb-spark
Hope this helps.
This issue is due to version (versions are mentioned in the question itself) conflict between com.microsoft.azure.sqldb and com.microsoft.jdbc driver, after downloading com.microsoft.azure.sqldb with all its dependencies from below link it worked.
Note: com.microsoft.azure.sqldb works on Java 8, I downgraded my java runtime version.
Click here to com.microsoft.azure.sqldb with all dependencies

javax.naming.NameNotFoundException: env/jdbc/DataSource on JBOSS with SQL Server

The JNDI name in my domain.xml is
The Context.lookup has been defined as follows:
dsName = "java:comp/env";
Context ctx = (Context) new javax.naming.InitialContext();
Context envCtx = (Context)ctx.lookup(dsName);
DataSource ds = (DataSource)envCtx.lookup("jdbc/DataSource");
conn = ds.getConnection();
I'm getting the following exception when connected to SQLserver with the following configuration where as it is working fine with Oracle.The lookup name somehow is not validated properly and connection object is getting null.
javax.naming.NameNotFoundException: env/jdbc/DataSource
ERROR [stderr] (ServerService Thread Pool -- 78) at
org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:104)
ERROR [stderr] (ServerService Thread Pool -- 78) at
org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)
java.lang.NullPointerException
Even Tried with something like
DataSource ds = (DataSource)envCtx.lookup("java:comp/env/jdbc/DataSource");
Could anyone suggest on this.
Thanks
Check the logs and/or the JNDI tree in the administration console.
Try these:
"java:DataSource"
"java:jboss/datasources/DataSource"
If not, please paste here the data source config section in the config file (e.g. standalone.xml)

Google App Engine trouble using Mail API

Hello I have a contact form with a post method on my contacts page and want to be able to use the Mail API to send outgoing mail from my google app engine application So I decided to use the mail API and registered myself as an authorized sender on my developer console and initiated the command --enable_sendmail=yes applicationID however when I test it, it gives me this error. I'm still fairly new to google app engine and not sure why that is happening.
"INFO 2015-08-06 18:44:50,935 mail_stub.py:142] MailService.Send
From: abdallahozaifa19527#gmail.com
To: Hozaifa
Subject: Test
/bin/sh: 1: sendmail: not found
ERROR 2015-08-06 18:44:50,944 mail_stub.py:263] Error sending mail using sendmail: [Errno 32] Broken pipe"
import os
import webapp2
import jinja2
from google.appengine.api import mail
template_dir = os.path.join(os.path.dirname(__file__), 'templates')
jinja_env = jinja2.Environment(loader = jinja2.FileSystemLoader(template_dir),
autoescape = True)
class Handler(webapp2.RequestHandler):
def write(self, *a, **kw):
self.response.out.write(*a, **kw)
def render_str(self, template, **params):
t = jinja_env.get_template(template)
return t.render(params)
def render(self, template, **kw):
self.write(self.render_str(template, **kw))
class MainPage(Handler):
def get(self):
self.render("index.html")
class AboutPage(Handler):
def get(self):
self.render("about.html")
class ProjectsPage(Handler):
def get(self):
self.render("projects.html")
class ExperiencePage(Handler):
def get(self):
self.render("experience.html")
class ContactPage(Handler):
def get(self):
self.render("contact.html")
def post(self):
name = self.request.get('name')
email = self.request.get('email')
message = self.request.get('message')
if (name and email and message):
message = mail.EmailMessage(sender="abdallahozaifa19527#gmail.com", subject="Test")
message.to = "Hozaifa<abdallahozaifa19527#gmail.com>"
message.send()
else:
self.write("It didnt work!")
app = webapp2.WSGIApplication([('/', MainPage),
('/about.html', AboutPage),
('/projects.html', ProjectsPage),
('/experience.html', ExperiencePage),
('/contact.html', ContactPage)])
My code works, however it does not work with the google app engine SDK because the SDK doesn't have the send mail, I was trying to test it using the SDK, problem solved!

MSSQL server connection time out groovy grails application

I have an application developed in groovy on grails(1.1.1). I've used a hibernate enable pooled configured datasource of MySQL Server in datasource.groovy code snippet as folows-
hibernate {
cache.use_second_level_cache=true
cache.use_query_cache=true
cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'
}
environments {
development {
dataSource {
logSql = true
dbCreate = "update" // one of 'create', 'create-drop','update'
url = "jdbc:mysql://<dev-server-ip>:3306/<db-name>"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://<test-server-ip>:3306/<db-name>"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:mysql://<prod-server-ip>:3306/<db-name>"
}
}
For connecting to another MS SQL Server 2005. I've defined a service class with following connection settings
def connection = Sql.newInstance(
"jdbc:sqlserver://<mssql-db-server-ip>;databaseName=<db-name>",
'<username>',
'<password>',
'com.microsoft.sqlserver.jdbc.SQLServerDriver')
I know that this connection is not pooled connection. And create session each time when I use this connection for retrieve data. So, Is there any mechanism to create pooled connection in service class?
When I run a query from service class using this ms sql server connection to select a data query like
String pullData() {
def userId = "sample_user"
def testData = connection.firstRow("select distinct (COLUMN_NAME1+' > '+replace(COLUMN_NAME2,' > ', '>')+' > '+COLUMN_NAME3+' > '+COLUMN_NAME4+' > '+EMAIL) testRow from VIEW_NAME where lower(substring(EMAIL,1,(select charindex('#',EMAIL))-1 )) = lower(?)",[userId])
def myStringList = testData.testRow.split(' > ')
def myTestDataList = myStringList[4].split('#')
def email = myTestDataList[0]
return email
}
I got an exception. The stacktrace is
org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.reflect.UndeclaredThrowableException
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.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
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.processRequest(ApplicationDispatcher.java:436)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:374)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:302)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at jcifs.http.NtlmHttpFilter.doFilter(NtlmHttpFilter.java:125)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:636)
Caused by: java.lang.reflect.UndeclaredThrowableException
at PullDataService$$EnhancerByCGLIB$$881a39b3.pullData(<generated>)
at PullDataService$$FastClassByCGLIB$$f8a1c77f.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
... 33 more
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: Connection timed out
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1368)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.terminate(SQLServerConnection.java:1355)
at com.microsoft.sqlserver.jdbc.TDSChannel.write(IOBuffer.java:1548)
at com.microsoft.sqlserver.jdbc.TDSWriter.flush(IOBuffer.java:2368)
at com.microsoft.sqlserver.jdbc.TDSWriter.writePacket(IOBuffer.java:2270)
at com.microsoft.sqlserver.jdbc.TDSWriter.endMessage(IOBuffer.java:1877)
at com.microsoft.sqlserver.jdbc.TDSCommand.startResponse(IOBuffer.java:4403)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:386)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4026)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1416)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:185)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:160)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:281)
at PullDataService.pullData(PullDataService.groovy:38)
at PullDataService$$FastClassByCGLIB$$7ff09ca7.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149)
... 40 more
Please help me, I am suffering it from a long time. Any suggestion is appreciable. Thanks in advance.
There are a couple of things I can see that would slow down this query. Mainly you creating a string column based on a bunch of different fields and calling distinct on it. Distinct is not needed as you are only using the first result and the other columns are not needed as you only care about the email. Consider something like this instead:
def userId = "sample_user".toLowerCase()
def testData = connection.firstRow("select top 1 EMAIL as email" +
" from VIEW_NAME" +
" where lower(EMAIL) like ?",[userId + "#%"])
def email = testData?.email?.split('#')[0]
return email
It could still be slow due to the like clause but should be much faster than using distinct.
You may want to consider adding a column to your view/underlying table to have a separate userid column to the email address column.

Resources