How can I specify both module and version in GAE/J cron?
I read this page.
The target string is prepended to your app's hostname.
It is usually the name of a module.
The cron job will be routed to the default version of the named module.
Note that if the default version of the module changes,
the job will run in the new default version.
If there is no module with the name assigend to target,
the name is assumed to be an app version, and App Engine will attempt to
route the job to that version. See About appengine-web.xml
My understanding is that either module name or version can be specified in <target>, but I want to specify both module name and version.
How can I do that?
For achieving your goal, you will need to look for two files (appengine-web.xml, cron.xml), As you already said the target tag of your cron.xml will allow you to set the module or version name, So to be able to do what you need, you can set the app name and module version in appengine-web.xml, Then you can define the module name in the target tag of your cron.xml.
An App Engine Java app must have a file named appengine-web.xml in its WAR, in the directory WEB-INF. This is an XML file whose root element is <appengine-web-app>. A minimal file that specifies the application ID, a version identifier, and no static files or resource files looks like this:
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>_your_app_id_</application>
<version>1</version>
<threadsafe>true</threadsafe>
</appengine-web-app>
A cron.xml file in the WEB-INF directory of your application (alongside appengine-web.xml) controls cron for your Java application. The following is an example cron.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
<cron>
<url>/weeklyreport</url>
<description>Mail out a weekly report</description>
<schedule>every monday 08:30</schedule>
<timezone>America/New_York</timezone>
<target>version-2</target>
</cron>
</cronentries>
Hope it helps
You will achive your goal if you specify target in such format: "version-dot-module"
this is worked for me:
<cron>
<url>/cron/test-cron</url>
<description>test-cron</description>
<schedule>every 1 minutes synchronized</schedule>
<target>v-5-1-dot-my-module-name</target>
</cron>
v-5-1 - version of my module
my-module-name - name of my module
Related
Here is the scenario:
I'm serving the index document for an app engine backed angularjs application from a GAE service via <welcome-file-list>.
Requests for https://<project>.appspot.com/ serve static/index.html via
<welcome-file-list>
<welcome-file>static/index.html</welcome-file>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
This index.html file contains a list of minimized/uglified/combined static resources with hashes in the name for cache busting purposes. All of the included assets work great, but the index.html file is cached for 600 seconds per the default caching rules on appengine.
I'd like to set no-cache headers for this file but it doesn't seem to honor expiration values configured in appengine-web.xml via <static-files>.
I've tried this
<static-files>
<!- also without leading slash, same result -->
<include path="/static/index.html" expiration="30s" />
According to the documentation {1} and a similar SO question {2}, I suggest you to write something like this: (Check the expiration time pattern)
<static-files>
<!- also without leading slash, same result -->
<include path="/static/index.html" expiration="0d 0h 0m 30s" />
{1}: https://cloud.google.com/appengine/docs/standard/java/config/appref#static_cache_expiration
{2}: unable to set cache expiration on in app.yaml for a python app
I have done the below steps for Solr Integration to tomcat on windows machine.Can you please clarify what am I doing wrong here.
1) Download Solr and unzipped Solr 5.2.1 to the below directory C:\downloads\solr-5.2.1\solr-5.2.1.
2)Download Tomcat 7 zipped version and unzipped it to below location C:\downloads\apache-tomcat-7.0.62\apache-tomcat-7.0.62
3)Copy Jar files from C:\downloads\solr-5.2.1\solr-5.2.1\dist\solrj-lib directory to C:\downloads\apache-tomcat-7.0.62\apache-tomcat-7.0.62\lib directory.
4) Create a solr.xml in the C:\downloads\apache-tomcat-7.0.62\apache-tomcat-7.0.62\conf\Catalina\localhost folder.
<?xml version='1.0' encoding='UTF-8'?>
<context docBase="C:/downloads/apache-tomcat-7.0.62/apache-tomcat-7.0.62/webapps/solr.war" debug="0" crossContext="true" >
<environment name="solr" type="java.lang.String" value="/apache-tomcat-7.0.62/webapps/" override="true"></environment>
</context>
5)Copy solr.war file from C:\downloads\solr-5.2.1\solr-5.2.1\server\webapps to
C:\downloads\apache-tomcat-7.0.62\apache-tomcat-7.0.62\webapps folder.
6)Start the tomcat using startup.bat command in bin folder
7)Edit web.xml to
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>C:/downloads/solr-5.2.1/solr-5.2.1</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
8)Restart the tomcat and hit the url http://localhost:8080/solr I get 404 Not found Error.The error in the console is
SEVERE: Error deploying configuration descriptor C:\downloads\apache-tomcat-7.0.
62\apache-tomcat-7.0.62\conf\Catalina\localhost\solr.xml
java.lang.NullPointerException
at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.ja
va:645)
The Solr wiki states that running 5.x versions on Tomcat is no longer supported:
Internally, Solr is still implemented via Servlet APIs and is powered by Jetty -- but this is simply an implementation detail. Deployment as a "webapp" to other Servlet Containers (or other instances of Jetty) is not supported, and may not work in future 5.x versions of Solr when additional changes are likely to be made to Solr internally to leverage custom networking stack features.
I have a command line script (actually a git post-checkout hook) that reloads my Solr application by doing a cURL to:
http://localhost:8080/manager/html/reload?path=/solr
Since I upgraded to Ubuntu 13.04, it now fails, where it used to work before the upgrade.
The cause of the problem is that my newer version of Tomcat (6.0.35), has some new CSRF protection and it now returns 403 Access Denied.
How can I solve the issue and bypass the CSRF protection?
More info:
My /etc/tomcat6/tomcat-users.xml file:
<?xml version='1.0' encoding='utf-8'?>
<role rolename="manager"/>
<user username="tomcat" password="secret" roles="manager"/>
</tomcat-users>
The documentation for Configuring Manager Application access in tomcat mentions some new manager roles, however my error specifically mentions that the single "manager" role still exists for the moment (and I tried the other roles anyway without success).
(As I was writing the question, I found the answer.) Instead of cURLing to the HTML application, I needed to cURL to the "plain text interface".
i.e. instead of
http://localhost:8080/manager/html/reload?path=/solr
Use:
http://localhost:8080/manager/reload?path=/solr
It turns out:
The HTML interface is protected against CSRF but the text and JMX interfaces are not.
This fits with the new role called "manager-script". To ensure my app will work in the future I changed my /etc/tomcat6/tomcat-users.xml file:
<?xml version='1.0' encoding='utf-8'?>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="secret" roles="manager-gui,manager-script"/>
</tomcat-users>
I have several Silverlight utility and control projects that I re-use in several different applications with-in my web application. These are all worked on in the same solution. Each Silverlight application has it's own page.
Example Setup
Utilities
CommonResources
I've strong name keyed and created extmap for these projects, but the dll's are still in the xaps. The version is defnied as 1.0.0.0 in the assembly.cs.
CommonResources
1.0.0.0
{public key here}
Silverlight.Common.CommonResources.dll
These all reference Utilities and CommonResources
- ManageFoo
- ManageBar
- etc
Can I assembly cache the utilities and CommonResources dll?
You may try adding an XML file (e.g. named Common.CommonResources.extmap.xml) to the CommonResources project, and set “Copy to Output Directory” to “Copy if newer”, with the following content:
<?xml version="1.0"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<assembly>
<name>Common.CommonResources</name>
<version>*.*.*.*</version>
<publickeytoken>*</publickeytoken>
<relpath>Common.CommonResources.dll</relpath>
<extension downloadUri="Common.CommonResources.zip" />
</assembly>
</manifest>
I don't see why you couldn't in this scenario. In fact it seems to be the ideal candidate.
You'll need to make sure you generate extmap files for your Utilities and CommonResources dlls. The file looks like this:
<?xml version="1.0"?>
<manifest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<assembly>
<name>System.Windows.Controls.Data.DataForm.Toolkit</name>
<version>2.0.5.0</version>
<publickeytoken>31bf3856ad364e35</publickeytoken>
<relpath>System.Windows.Controls.Data.DataForm.Toolkit.dll</relpath>
<extension downloadUri="System.Windows.Controls.Data.DataForm.Toolkit.zip" />
</assembly>
</manifest>
and has the name of the form:
<dllname>.extmap.dll
and must be in the same location as the dll itself.
I developed a Java web application in Netbeans 6.5 using a MySQL database and Hibernate. Both the development database server and development application server (Tomcat 6) reside on my development machine. Everything works; the application pulls data from the database correctly.
Now, I'm ready to move it to the production server. Again, the DB server and app server are on the same machine. I deploy the WAR file and try to access the application; I can access the static pages but the Servlets that use the database error out with the exception:
org.hibernate.exception.JDBCConnectionException: Cannot open connection
I'm pretty sure the problem relates to Tomcat not knowing about the data source. It seems as if Netbeans handles this for me. I've read that I might need to add a RESOURCE entry so I took some advice from this site which gave me a context.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/EmployeeDirectory">
<Resource
name="jdbc/employeedirectory" auth="Container"
type="javax.sql.DataSource" username="EmployeeDir"
password="EmployeeDirectory" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://127.0.0.1:3306/EmployeeDirectory?autoReconnect=true"
maxActive="15" maxIdle="7"
validationQuery="Select 1" />
</Context>
a web.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Omit Servlet Info -->
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/employeedirectory</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
and a hibernate.cfg.xml of:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/employeedirectory</property>
<property name="hibernate.hbm2ddl.auto">update</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Omit other Mappings -->
<mapping class="EmployeeDirectory.data.PhoneNumber" resource="EmployeeDirectory/data/PhoneNumber.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Now, I get a org.hibernate.HibernateException: Could not find datasource error.
Am I on the right path for moving from development to production? What am I missing?
I think you are on the right track. I would first set up the datasource and verify it out side of hibernate. Here is a good article on that: http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.htm and some examples here: http://www.mbaworld.com/docs/jndi-datasource-examples-howto.html
Then, I would configure hibernate to use the datsource. From looking at your hibernate.cfg.xml file I think you should try changing hibernate.connection.datasource to jdbc/employeedirectory
the jndi datasource should be defined in /tomcat/server.xml see Tomcat JNDI Datasource how-to and not in webapp/context.xml
Tomcat 6 requires that you add the resource tag to the context.xml, not the server.xml. You could in Tomcat 5.x. I have it working fine in a separate install of Tomcat, but I'm still trying to use connection pooling inside NB 6.5.
That same Apache site has a link to the Tomcat 6 version of JNDI and it tells you to add the resource tag to the context.xml.