I saw the SoundCloud group recording widget here (http://grouprecorder.soundcloudlabs.com) which looks great. I'm wondering if the widget returns the ID of a track once the user finishes uploading it. I'm asking because I want to put the widget in a larger form with fields for pictures, text, etc. and then associate the user's uploaded Soundcloud track with the other fields which are stored in my site's database.
Friday, April 20, 2012
compiling a small C++ program with Visual C++ Express
I opened hello.cpp. Why isn't there File -> Compile -> hello.cpp? What is an other easy way, if any?
Smoothly rotate and change size of UIView with shadow
I have a UIView with a shadow, and subview of the view is a UIImageView.
I want to resize the view when the iPad is rotated, and I'm trying to do this in willRotateToInterfaceOrientation.
If I set the shadow on the UIView in the basic way, the rotation is very choppy, so I'd like to use the suggestion by some people to set the shadow setting layer.shadowPath.
I have tried animating the frame size change using [UIView animateWithDuration:animations], and setting the new shadowPath in the same block, but the shadow path snaps to the new size.
And if I don't change the shadowPath in the animations block, it doesn't change.
From a few searches I've done, animating changes to layer stuff needs to be done with a CABasicAnimation.
So I think the question is, how do I animate a frame size and layer change simultaneously?
Hayes AT Commands: Detect Remote Hangup?
How are you supposed to programatically detect when the remote modem on your call hangs up? I am writing a C program which interfaces with a SoftModem device /dev/ttySL0 in Ubuntu linux. I am able to configure the modem using Hayes AT commands and communicate with the remote modem. However, I haven't been able to determine how I'm supposed to detect that the other end has hung up the line.
I have the modem configured so that when the other end hangs up, the device prints NO CARRIER and switches to command mode. However, I can't use the NO CARRIER string because I can't guarantee that the modem won't receive that string while in data mode.
How do you "listen" for remote hang up?
Drupal: how to set theme language programmatically?
How can i change drupal default language programmatically somewhere in code (like template.php)?
(i need to overwrite default language set by admin in some cases.)
i'm using drupal 6.
PS: please read my own answer for more detail. and if you may help solve that
PS: later i saw a module that was what i wanted. make sure take a look at it:
Administration Language Drupal Module
No Persistence provider for EntityManager named xx
I've searched entire SO, and although posts with the similar title exists this is a different scenario.
I've two projects in my eclipse 1) One JPA project 2) One Web project which consumes the entities from the JPA project. Both are OSGi and Maven enabled. I'm using the latest SpringFramework (3.1.1) for creating RESTful webservices in the Web project.
The project layouts are as follows:
1) JPA Project
com.demo.persistence
|-src
|-com.demo.persistence
|-User
|-META-INF
|-MANIFEST.MF
|-persistence.xml
|-pom.xml
2) Web Project
com.demo.web
|-src
|-com.demo.web.controller
|-Controller.java
|-com.demo.web.dao
|-UserDAO.java
|-UserListDAO.java
|-com.demo.web.model
|-UserBean.java
|-com.demo.web.interfaces
|-UserDAOIntf.java
|-WebContent
|-META-INF
|-MANIFEST.MF
|-WEB-INF
|-classes
|-log4j.properties
|-rest-context.xml
|-rest-context-osgi.xml
|-rest-servlet.xml
|-web.xml
|-pom.xml
com.demo.persistence.User.java
@Entity
@XmlRootElement(name="user")
@Table(name = "T_USER")
@NamedQuery(name = "AllUsers", query = "select u from User u")
public class User {
@Id
@GeneratedValue
@Column(nullable = false)
private long id;
@Basic
@Column(nullable = false)
private String userName;
public void setUserName(String param) {
this.userName = param;
}
public String getUserName() {
return userName;
}
}
com.demo.web.dao.UserDAO
public class UserDAO implements UserDAOInterface {
@PersistenceContext
private EntityManager em;
public User getUser(Long id) {
try{
return em.find(User.class, id);
} finally {
if(em != null)
em.close();
}
}
public List<User> getAllUsers() {
try {
List<User> users = em.createNamedQuery("AllUsers", User.class).getResultList();
return users;
} finally {
if(em != null)
em.close();
}
}
@Transactional
public User addUser(User user) {
try {
em.persist(user);
em.flush();
return user;
} finally {
if(em != null)
em.close();
}
}
}
com.demo.web.model
public class UserBean {
private UserDAO userDAO;
public void addUserDetails( String userName ) {
User user = new User();
user.setUserName(userName);
this.userDAO.addUser(user);
}
public List<User> getAllUsers() {
return this.userDAO.getAllUsers();
}
public User getUser(Long id) {
return this.userDAO.getUser(id);
}
public User addUser(User user) {
return this.userDAO.addUser(user);
}
}
com.demo.web.controller.Controller
@Controller
public class Controller {
private Jaxb2Marshaller jaxb2Marshaller;
private UserBean userBean;
public Jaxb2Marshaller getJaxb2Mashaller() {
return jaxb2Marshaller;
}
public void setJaxb2Mashaller(Jaxb2Marshaller jaxb2Marshaller) {
this.jaxb2Marshaller = jaxb2Marshaller;
}
@RequestMapping(method=RequestMethod.GET, value="/rest/users", headers="Accept=application/xml, application/json")
public @ResponseBody UserListDAO getUserList() {
return new UserListDAO(userBean.getAllUsers());
}
@RequestMapping(method=RequestMethod.GET, value="rest/user/{id}", headers="Accept=application/xml, application/json")
public @ResponseBody User getUser(@PathVariable Long id) {
return userBean.getUser(id);
}
@RequestMapping(method=RequestMethod.POST, value="rest/user/add", headers="Accept=application/xml, application/json")
public @ResponseBody User addUser(@RequestBody String userString) {
Source source = new StreamSource(new StringReader(userString));
User user = (User) jaxb2Marshaller.unmarshal(source);
return userBean.addUser(user);
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation=
"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">
<display-name>com.demo.web</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>
/WEB-INF/classes/log4j.properties
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<!-- The context params that read by ContextLoaderListener -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/rest-context.xml
</param-value>
</context-param>
<!-- This listener will load other application context file in addition to springweb-servlet.xml -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>rest</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>rest</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
</web-app>
rest-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<context:annotation-config />
<context:component-scan base-package="com.demo.web.controller" />
<tx:annotation-driven transaction-manager="transactionManager" />
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="com.demo.persistence" />
</bean>
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- Bean - DAO Mapping -->
<bean id="userDAO" class="com.demo.dao.UserDAO">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<!-- Bean Declarations -->
<bean id="userBean" class="com.demo.web.model.UserBean">
<property name="userDAO" ref="userDAO" />
</bean>
</beans>
rest-context-osgi.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:osgi="http://www.springframework.org/schema/osgi"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/osgi
http://www.springframework.org/schema/osgi/spring-osgi-1.0.xsd">
<osgi:service interface="javax.persistence.EntityManager" ref="entityManagerFactory" />
</beans>
rest-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- To enable @RequestMapping process on type level and method level -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="marshallingConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean>
<bean id="marshallingConverter" class="org.springframework.http.converter.xml.MarshallingHttpMessageConverter">
<constructor-arg ref="jaxbMarshaller" />
<property name="supportedMediaTypes" value="application/xml"/>
</bean>
<bean id="jsonConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json" />
</bean>
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.demo.persistence.User</value>
<value>com.demo.dao.UserListDAO</value>
</list>
</property>
</bean>
<bean id="users" class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg ref="jaxbMarshaller" />
</bean>
<!--bean id="viewResolver" class="org.springframework.web.servlet.view.BeanNameViewResolver" /-->
<bean id="userController" class="com.demo.web.controller.Controller">
<property name="userDAO" ref="userDAO" />
<property name="jaxb2Mashaller" ref="jaxbMarshaller" />
</bean>
</beans>
Console - log4j
ERROR [org.springframework.web.context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/rest-context.xml]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: No Persistence provider for EntityManager named com.demo.persistence
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1455)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:385)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:284)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897)
at org.apache.catalina.core.ContainerBase.access$000(ContainerBase.java:131)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:154)
at org.apache.catalina.core.ContainerBase$PrivilegedAddChild.run(ContainerBase.java:143)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:871)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
at org.eclipse.gemini.web.tomcat.internal.TomcatServletContainer.startWebApplication(TomcatServletContainer.java:122)
at org.eclipse.gemini.web.internal.StandardWebApplication.start(StandardWebApplication.java:91)
at org.eclipse.gemini.web.extender.WebContainerBundleCustomizer.addingBundle(WebContainerBundleCustomizer.java:45)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:482)
at org.osgi.util.tracker.BundleTracker$Tracked.customizerAdding(BundleTracker.java:1)
at org.osgi.util.tracker.AbstractTracked.trackAdding(AbstractTracked.java:262)
at org.osgi.util.tracker.AbstractTracked.track(AbstractTracked.java:234)
at org.osgi.util.tracker.BundleTracker$Tracked.bundleChanged(BundleTracker.java:457)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.dispatchEvent(BundleContextImpl.java:847)
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.framework.internal.core.Framework.publishBundleEventPrivileged(Framework.java:1522)
at org.eclipse.osgi.framework.internal.core.Framework$7.run(Framework.java:1462)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1460)
at org.eclipse.osgi.framework.internal.core.Framework.publishBundleEvent(Framework.java:1453)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:391)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:299)
at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.resumeBundles(PackageAdminImpl.java:311)
at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.processDelta(PackageAdminImpl.java:555)
at org.eclipse.osgi.framework.internal.core.PackageAdminImpl.doResolveBundles(PackageAdminImpl.java:251)
at org.eclipse.osgi.framework.internal.core.PackageAdminImpl$1.run(PackageAdminImpl.java:173)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named com.demo.persistence
at javax.persistence.Persistence.createEntityManagerFactory(Unknown Source)
at org.springframework.orm.jpa.LocalEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalEntityManagerFactoryBean.java:92)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:310)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1504)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1502)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1452)
... 45 more
Sorry for the huge post. But I export my persistence package in the Manifest file and import the same in my web app.
And the persistence provider used is org.eclipse.persistence.jpa.PersistenceProvider.
This has been stopping my project from a month.. :( Please help.
Thanks in advance.
EDIT
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="com.demo.persistence"
transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<class>com.sap.ganges.retailer.sales.persistence.Person</class>
<properties>
<property name="eclipselink.weaving" value="false" />
<property name="eclipselink.ddl-generation" value="create-tables" />
</properties>
</persistence-unit>
</persistence>
Vertical Align Wrapper
I'm messing around with a website out of boredom, and trying to figure out how to vertical align my wrap, which I am failing at lol. I've already horizontally aligned it, and just need help vertical aligning it. (Yes, I have tried vertical-align:middle, but it doesn't work).
* { margin:0; padding:0; }
html { height:100%; }
body { background:/*url(images/bg.jpg)*/#14181a; }
#wrap { width:960px; height:55%; margin:0 auto; background:#293033; }
<div id="wrap">
<div id="logo"></div>
<div id="navgation"></div>
<div id="content"></div>
<div id="footer"></div>
</div>