Red5 exception creating connection - red5

Red5 was working alright for me, then I decided to upgrade to the latest version. But the new version is showing me an error. I am running a simple client App. When I try to connect I see the exception even if I am connecting to a different app, connection.connect("rtmp://localhost/crazyName") it'will show the exception in this case too. Please someone who can help me with this.
package org.red5.core;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
//import org.slf4j.Logger;
/**
* Sample application that uses the client manager.
*
* #author The Red5 Project (red5#osflash.org)
*/
public class Application extends MultiThreadedApplicationAdapter {
//private static Logger log = Red5LoggerFactory.getLogger(Application.class);
/** {#inheritDoc} */
#Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
//log.info("appConnect");
return true;
}
/** {#inheritDoc} */
#Override
public void disconnect(IConnection conn, IScope scope) {
//log.info("disconnect");
super.disconnect(conn, scope);
}
}
client
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationComplete="onCreationComplete(event)">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
private var connection:NetConnection;
public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.connect("rtmp://localhost/Project");
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
connection.client = this;
}
public function onConnectionNetStatus(event:NetStatusEvent) : void {
// did we successfully connect
if(event.info.code == "NetConnection.Connect.Success") {
Alert.show("Successful Connection", "Information");
} else {
Alert.show("Unsuccessful Connection", event.info.code);
}
}
]]>
</mx:Script>
</mx:Application>
[WARN] [NioProcessor-4] org.red5.server.net.rtmp.RTMPConnManager - Exception creating connection
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'rtmpMinaConnection' defined in class path resource [red5-core.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'deadlockGuardScheduler' of bean class [org.red5.server.net.rtmp.RTMPMinaConnection]: Bean property 'deadlockGuardScheduler' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1514) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1222) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:217) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:350) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:331) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:968) ~[spring-context-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.red5.server.net.rtmp.RTMPConnManager.createConnectionInstance(RTMPConnManager.java:306) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPConnManager.createConnection(RTMPConnManager.java:166) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPConnManager.createConnection(RTMPConnManager.java:56) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPMinaIoHandler.createRTMPMinaConnection(RTMPMinaIoHandler.java:297) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.red5.server.net.rtmp.RTMPMinaIoHandler.sessionCreated(RTMPMinaIoHandler.java:61) [red5-server-common-1.0.6-SNAPSHOT.jar:1.0.6-SNAPSHOT]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.sessionCreated(DefaultIoFilterChain.java:772) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:459) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$700(DefaultIoFilterChain.java:48) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.sessionCreated(DefaultIoFilterChain.java:913) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.filterchain.IoFilterAdapter.sessionCreated(IoFilterAdapter.java:74) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextSessionCreated(DefaultIoFilterChain.java:459) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.fireSessionCreated(DefaultIoFilterChain.java:452) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.service.IoServiceListenerSupport.fireSessionCreated(IoServiceListenerSupport.java:211) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.addNow(AbstractPollingIoProcessor.java:538) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.handleNewSessions(AbstractPollingIoProcessor.java:505) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:67) [mina-core-2.0.9.jar:na]
at org.apache.mina.core.polling.AbstractPollingIoProcessor$Processor.run(AbstractPollingIoProcessor.java:1113) [mina-core-2.0.9.jar:na]
at org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:64) [mina-core-2.0.9.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_45]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_45]
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'deadlockGuardScheduler' of bean class [org.red5.server.net.rtmp.RTMPMinaConnection]: Bean property 'deadlockGuardScheduler' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1076) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:930) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:95) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1510) ~[spring-beans-4.1.7.RELEASE.jar:4.1.7.RELEASE]
... 29 common frames omitted
[WARN] [NioProcessor-4] org.red5.server.net.rtmp.RTMPMinaIoHandler - Force close - session: 3
[WARN] [NioProcessor-4] org.red5.server.net.rtmp.RTMPMinaIoHandler - Force close - session: 3
[INFO] [NioProcessor-4] org.red5.server.net.rtmp.RTMPMinaIoHandler - Close already forced on this session: 3

I had the same problem.. but I comment this line in .../conf/red5-core.xml:
property name="deadlockGuardScheduler" ref="deadlockGuardScheduler"
It worked for me...

Related

Unable to Instantiate Class while Alter Region adding cache loaded to that region

I have an apache geode setup where there is one locator and one Server. we have a region employee in that. we were trying to implement in-line cache where a cache miss will lookup into database and will fill apache geode, but after deployment of Jars when i am trying to alter the region . It shows exception
Stack Trace:
[error 2021/04/09 15:18:30.513 IST <Function Execution Processor2> tid=0x3a] Error instantiating class: <com.abc.geode.ApacheGeode.EmployeeCacheLoader>
java.lang.RuntimeException: Error instantiating class: <com.abc.geode.ApacheGeode.EmployeeCacheLoader>
at org.apache.geode.management.internal.configuration.domain.DeclarableTypeInstantiator.newInstance(DeclarableTypeInstantiator.java:43)
at org.apache.geode.management.internal.cli.functions.RegionAlterFunction.alterRegion(RegionAlterFunction.java:202)
at org.apache.geode.management.internal.cli.functions.RegionAlterFunction.executeFunction(RegionAlterFunction.java:67)
at org.apache.geode.management.cli.CliFunction.execute(CliFunction.java:37)
at org.apache.geode.internal.cache.MemberFunctionStreamingMessage.process(MemberFunctionStreamingMessage.java:201)
at org.apache.geode.distributed.internal.DistributionMessage.scheduleAction(DistributionMessage.java:372)
at org.apache.geode.distributed.internal.DistributionMessage$1.run(DistributionMessage.java:436)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.geode.distributed.internal.ClusterOperationExecutors.runUntilShutdown(ClusterOperationExecutors.java:475)
at org.apache.geode.distributed.internal.ClusterOperationExecutors.doFunctionExecutionThread(ClusterOperationExecutors.java:393)
at org.apache.geode.logging.internal.executors.LoggingThreadFactory.lambda$newThread$0(LoggingThreadFactory.java:119)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassCastException: com.abc.geode.ApacheGeode.EmployeeCacheLoader cannot be cast to org.apache.geode.cache.Declarable
at org.apache.geode.management.internal.configuration.domain.DeclarableTypeInstantiator.newInstance(DeclarableTypeInstantiator.java:34)
public class EmployeeCacheLoader implements CacheLoader<Long,Employee>, Declarable {
#Override
public Employee load(LoaderHelper<Long, Employee> helper) throws CacheLoaderException {
Employee e=new Employee();
e.setEmail("a#b.com");
e.setIdemployee(2L);
return e;
}
#Override
public void close() {
}
#Override
public void init(Properties props) {
}
Things tried
I tried by not implementing Declarable but still no success.
I have not done any change for serializer.
I've just tried the scenario using Apache Geode 1.13.2 and it works just fine, you can find the example here. Do you have multiple versions of the same jar within the server's class path?, that might be the reason for the exception.
Cheers.

spring data elasticsearch Invocation of init method failed; nested exception is java.lang.AbstractMethodError

I have problem with Spring Data Elasticsearch. I configure elasticsearch like this:
#Configuration
#EnableJpaRepositories(basePackages = {"org.project.repositories"})
#EnableElasticsearchRepositories(basePackages = "org.project.repositorieselastic")
#EnableTransactionManagement
public class PersistenceContext {
#Bean
public ElasticsearchOperations elasticsearchTemplate() {
return new ElasticsearchTemplate(client());
}
#Bean
public Client client(){
Settings settings = ImmutableSettings.settingsBuilder()
// Setting "transport.type" enables this module:
.put("cluster.name", "elasticsearch")
.put("client.transport.ignore_cluster_name", false)
.build();
TransportClient client= new TransportClient(settings);
TransportAddress address = new InetSocketTransportAddress("127.0.0.1", 9300);
client.addTransportAddress(address);
return client;
}
}
My repo looks like.
#Repository()
public interface UserFavoriteElasticRepo extends ElasticsearchRepository<UserFavorite, Long> {
}
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.project.repositorieselastic.UserFavoriteElasticRepo org.project.services.elastic.FavoriteIndexerService.elasticRepo; nested exception
is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userFavoriteElasticRepo': Invocation of init method failed; nested exception is java.lang.AbstractMethodError
It's look like the implementation is not generated. But I don't know where to investigate. I tried to use one package and use this - https://github.com/izeye/spring-boot-throwaway-branches/commit/874ccba09189d6ef897bc430c43b6e3705404399 but with no success.
I solved the problem adding this in pom file
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>1.12.2.RELEASE</version>
</dependency>
I've got same exception using spring-data-elasticsearch.
But exception was thrown when I declared new methods in repository:
ex.:
public interface UserFavoriteElasticRepo extends ElasticsearchRepository<UserFavorite, Long> {
Page<UserFavorite> findBySomeProperty(String propertyValue, Pageable pageable);
}
It was casued due to spring-data-elasticsearch, spring-data-commons versions. Function declarations have changed: org.springframework.data.repository.query.QueryLookupStrategy.resolveQuery - it caused the exception.
For spring-data-elasticsearch version 2.0.0.RELEASE you have to use spring-data-commons with version 1.12.0.
If you have spring-data-jpa in your project it also uses spring-data-commons. For spring-data-jpa v1.9.0.RELEASE, spring-data-commons is v1.11.0.RELEASE
Could you provide what frameworks and versions of spring you are using? Also If you could put whole stacktrace, it will be helpfull?

Spring boot JNDI datasource lookup failure - Name comp/env/jdbc not found in context "java:"

I have setup a spring boot (v 1.1.9) application to deploy as a WAR file. And I'm trying to integrate this web application with an existing data service module (added as a maven dependency).
Environment trying to deploy: WebSphere Application Server 8.5.5.4
The issue I'm facing is an application start-up failure when try to look-up a JNDI dataSource (jdbc/fileUploadDS) as below within the dependent data service module.
#Configuration
#Profile("prod")
public class JndiDataConfig implements DataConfig {
#Bean
public DataSource dataSource() throws NamingException {
Context ctx = new InitialContext();
return (DataSource) ctx.lookup("java:comp/env/jdbc/fileUploadDS");
}
}
My Spring Boot configuration:
#Configuration
#ComponentScan(basePackages = { "au.com.aiaa.fileupload.data.*", "demo" })
#EnableAutoConfiguration(exclude = { HibernateJpaAutoConfiguration.class, DataSourceAutoConfiguration.class })
public class SampleApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(applicationClass, args);
}
#Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<SampleApplication> applicationClass = SampleApplication.class;
#Bean
public static Properties fileUploadJndiProperties() throws NamingException {
JndiObjectFactoryBean jndiFactoryBean = new JndiObjectFactoryBean();
jndiFactoryBean.setJndiName("props/FileUploadProperties");
jndiFactoryBean.setExpectedType(Properties.class);
jndiFactoryBean.setLookupOnStartup(true);
jndiFactoryBean.afterPropertiesSet();
return (Properties) jndiFactoryBean.getObject();
}
}
Note that I'm able to lookup props/FileUploadProperties successfully. But failing to do the same for a datasource.
My doubt is it is trying to load a EmbeddedWebApplicationContext which is not what I want.
The stack trace is:
Instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.sql.DataSource au.com.aiaa.fileupload.data.dao.configuration.JndiDataConfig.dataSource() throws javax.naming.NamingException] threw exception; nested exception is **javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".**
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:301)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1186)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:706)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:762)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at **org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:109)**
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:691)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:142)
at org.springframework.boot.context.web.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:89)
at org.springframework.boot.context.web.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:51)
at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:175)
..................
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Factory method [public javax.sql.DataSource au.com.aiaa.fileupload.data.dao.configuration.JndiDataConfig.dataSource() throws javax.naming.NamingException] threw exception; nested exception is **javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".**
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:188)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:586)
... 132 common frames omitted
Caused by: javax.naming.NameNotFoundException: Name comp/env/jdbc not found in context "java:".
at com.ibm.ws.naming.ipbase.NameSpace.getParentCtxInternal(NameSpace.java:1970)
at com.ibm.ws.naming.ipbase.NameSpace.retrieveBinding(NameSpace.java:1377)
at com.ibm.ws.naming.ipbase.NameSpace.lookupInternal(NameSpace.java:1220)
at com.ibm.ws.naming.ipbase.NameSpace.lookup(NameSpace.java:1142)
at com.ibm.ws.naming.urlbase.UrlContextImpl.lookupExt(UrlContextImpl.java:1436)
at com.ibm.ws.naming.java.javaURLContextImpl.lookupExt(javaURLContextImpl.java:477)
at com.ibm.ws.naming.java.javaURLContextRoot.lookupExt(javaURLContextRoot.java:485)
at com.ibm.ws.naming.java.javaURLContextRoot.lookup(javaURLContextRoot.java:370)
at org.apache.aries.jndi.DelegateContext.lookup(DelegateContext.java:161)
at javax.naming.InitialContext.lookup(InitialContext.java:436)
at au.com.aiaa.fileupload.data.dao.configuration.JndiDataConfig.dataSource(JndiDataConfig.java:41)
at au.com.aiaa.fileupload.data.dao.configuration.JndiDataConfig$$EnhancerBySpringCGLIB$$8001dbbe.CGLIB$dataSource$0(<generated>)
at au.com.aiaa.fileupload.data.dao.configuration.JndiDataConfig$$EnhancerBySpringCGLIB$$8001dbbe$$FastClassBySpringCGLIB$$3c9e0518.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:312)
at au.com.aiaa.fileupload.data.dao.configuration.JndiDataConfig$$EnhancerBySpringCGLIB$$8001dbbe.dataSource(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:166)
What am I missing here? Even when I try to explicitly define the dataSource bean method in SampleApplication.java like below it fails with the same error.
#Bean
public static DataSource dataSource() throws NamingException {
JndiObjectFactoryBean jndiFactoryBean = new JndiObjectFactoryBean();
jndiFactoryBean.setJndiName("java:comp/env/jdbc/fileUploadDS");
jndiFactoryBean.setExpectedType(DataSource.class);
jndiFactoryBean.setLookupOnStartup(true);
jndiFactoryBean.setResourceRef(true);
jndiFactoryBean.afterPropertiesSet();
return (DataSource) jndiFactoryBean.getObject();
}
I referred this and it says we need to set enableNaming() on servlet container? Can I do something similar for non-embedded web application context? Or is it purely a WAS 8.5 issue??
You need to have resource reference with jdbc/fileUploadDS name in your web.xml. And make sure it is bound to actual datasource name during installation or via ibm-web-bnd.xml file.
Definition in web.xml:
<resource-ref>
<description />
<res-ref-name>jdbc/fileUploadDS</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
If you dont want to use web.xml, then in normal Java EE app you could just add in web component (servlet, filter) the following class annotation:
#Resource(name="jdbc/fileUploadDS", type=javax.sql.DataSource.class, lookup="jdbc/fileUploadDS")
but I'm not Spring-boot expert, so don't know, if it will work or is possible there.
I am able to connect my Spring-Boot application (deployed in Websphere Application Server 9) to WAS datasource.
The following code worked for me, for connecting to DataSource:
#Bean(name = "WASDataSource")
public DataSource WASDataSource() throws Exception {
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
return dataSourceLookup.getDataSource("DSNAME");
}
#Bean(name = "WASDataSourceJdbcTemplate")
public JdbcTemplate jdbcTemplate_WASDS(#Qualifier("WASDataSource")
DataSource dsDB2) {
return new JdbcTemplate(dsDB2);
}
Note: The name of Datasource "DSNAME" is the name which appears on the UI of Websphere console.
You can see that via -> Select Resources > JDBC > Data Sources.
Then I created jdbc template:
#Autowired
#Qualifier("WASDataSourceJdbcTemplate")
private JdbcTemplate db2WASTemplate;`
And running query using the query method works fine :
db2WASTemplate.query()
I did not create any Web.xml or ibm-web-bnd.xml files
I just configured spring boot with my custom datasource as follows:
#Bean
#ConfigurationProperties("spring.datasource")
public DataSource dataSource() {
return DataSourceBuilder.create().build();
}
and inside the application.properties file I defined all datasource settings as usual
spring.datasource.driver-class-name= ***
spring.datasource.url= ***
spring.datasource.username= ***
spring.datasource.password= ***
spring.datasource.jndi-name=jdbc/myDB
It works nicely with #SpringBootApplication with all other default settings
I am facing the same problem. I don't know how to define tag in spring boot since there is no web.xml file in the spring boot.
So far what I came to know that we have to define it in the application file from where we start our spring application. I think we need to use this method to set the Datasource:
#Bean(destroyMethod="")
#ConfigurationProperties(prefix="datasource.mine")
public DataSource dataSource() throws Exception {
JndiDataSourceLookup dataSourceLookup = new JndiDataSourceLookup();
return dataSourceLookup.getDataSource("java:jdbc/configurationFile");
}

NoClassDefFoundError in org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53

NoClassDefFoundError in org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53
I'm developing an AOP logger. It works fine with a straight up Java class with a main() method but is failing when used in conjunction with Spring Boot. The logging jar file is in both the bootclasspath and the class path. An exception is thrown even before I'm able to print out the class path. Am I missing a configuration step to make Spring Boot happy?
The exception:
java.lang.reflect.InvocationTargetException
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:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.co.brs.logging.aop.AopLogger
at com.co.brs.restserver.RestApplication.main(RestApplication.java:73)
... 6 more
The command line:
/usr/java/latest/bin/java -Xbootclasspath/p:/usr/local/co/lib/logging-logger.jar -server -cp /usr/local/co/lib/logging-logger.jar:/usr/local/co/bin/../lib/restserver:/usr/local/co/lib/*:/usr/local/co/catalog/lib/*:/usr/local/co/lib/logging-logmanager/* -jar /usr/local/co/bin/../lib/restserver/rest-server.jar >> /usr/local/co/bin/../log/restserver.out 2>&1 &
The RestApplication.java:
#Configuration
#EnableAutoConfiguration
#ComponentScan({"com.co.brs.restserver.component", "com.co.brs.restserver.service", "com.co.brs.restserver.web", "com.co.brs.restserver.doc"})
public class RestApplication {
#Value("${keystore.file}") private String keystoreFile;
#Value("${keystore.pass}") private String keystorePass;
#Value("${keystore.type}") private String keystoreType;
#Value("${secure.port}") private String securePort;
/**
* Start Spring boot Application
* #throws Exception
*/
public static void main(String[] args) throws Exception {
ClassLoader loader = RestApplication.class.getClassLoader();
System.out.println(System.getProperty("java.class.path"));
//Get the System Classloader
ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();
//Get the URLs
URL[] urls = ((URLClassLoader)sysClassLoader).getURLs();
for(int i=0; i< urls.length; i++)
{
System.out.println(urls[i].getFile());
}
SpringApplication restApp = new SpringApplication(RestApplication.class);
restApp.setShowBanner(false);
restApp.setDefaultProperties(new HashMap<String, Object>());
ApplicationContext context = restApp.run(args);
RestService restService = context.getBean(RestService.class);
restApp.setRegisterShutdownHook(true);
// Start component
if (!restService.start()) {
// Failed to start
System.out.println("Failed to start - exiting\n");
System.exit(SpringApplication.exit(context, new JobExecutionExitCodeGenerator()));
}
System.out.println("Rest Service is up and running");
}
And the AOP Logger snippet:
pointcut logMethod():
(execution(public * *(..)) && !execution(public * get*(..)) && !execution(public void set*(..))
&& !cflow(adviceexecution() && !execution(public com.co.brs.logging* *(..))));
before(): logMethod() {...}
The pom.xml file includes the following dependencies:
<dependency>
<groupId>com.co.brs.logging</groupId>
<artifactId>logging-logger</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.8.2</version>
</dependency>
and
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
I updated the point cut in the AOPLogger to ignore main() methods and got farther.
The point cut:
pointcut logMethod():
(execution(public * *(..)) && !execution(public * get*(..)) && !execution(public void set*(..)) && !execution(public void main(..))
&& !cflow(adviceexecution() && !execution(public com.co.brs.logging* *(..))));
New output: (The code is getting into the execution:
java.lang.reflect.InvocationTargetException
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:483)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/aspectj/runtime/reflect/Factory
at com.co.brs.logging.CatalogHandler.ajc$preClinit(CatalogHandler.java:1)
at com.co.brs.logging.CatalogHandler.<clinit>(CatalogHandler.java:1)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:433)
at java.util.logging.LogManager$5.run(LogManager.java:966)
at java.security.AccessController.doPrivileged(Native Method)
at java.util.logging.LogManager.loadLoggerHandlers(LogManager.java:958)
at java.util.logging.LogManager.initializeGlobalHandlers(LogManager.java:1578)
at java.util.logging.LogManager.access$1500(LogManager.java:145)
at java.util.logging.LogManager$RootLogger.accessCheckedHandlers(LogManager.java:1667)
at java.util.logging.Logger.getHandlers(Logger.java:1776)
at org.slf4j.bridge.SLF4JBridgeHandler.removeHandlersForRootLogger(SLF4JBridgeHandler.java:169)
at org.springframework.boot.logging.log4j.Log4JLoggingSystem.beforeInitialize(Log4JLoggingSystem.java:64)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:135)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
at org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
at org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:54)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:276)
at com.emc.brs.restserver.RestApplication.main(RestApplication.java:62)
... 6 more
I further updated the pointcut to only include the package for my product and now the code gets past the initial boot without a problem. The final pointcut defines an intercept for my package, not simple getters and setters, not the logging package itself, not main() methods and not while already giving advice.
pointcut logMethod():
(execution(public com.co.brs* *(..))
&& !execution(public * get*(..))
&& !execution(public void set*(..))
&& !execution(public void main(..))
&& !cflow(adviceexecution()
&& !execution(public com.co.brs.logging* *(..))));
before(): logMethod()
{ ... }
To me it looks like you want to capture public method calls within a certain package instead of method calls returning types from that package, i.e. execution(public * com.co.brs..*(..)) rather than execution(public com.co.brs..* *(..)). The same is true for the logging execution at the end, you also got that one wrong.
You can also further refine your pointcut, e.g. by
using a construct like com.co.brs..* instead of com.co.brs* to explicitly denote that you mean package com.co.brs and all its subpackages,
omitting the public modifiers on subsequent pointcuts chained together via && because the first pointcut already limits executions to public ones.
You also do not need the outermost parentheses enclosing everything.
pointcut logMethod():
execution(public * com.co.brs..*(..)) &&
!execution(* get*(..)) &&
!execution(void set*(..)) &&
!execution(void main(..)) &&
!cflow(adviceexecution()) &&
!execution(* com.co.brs.logging..*(..));
Please also note that !cflow(adviceexecution()) also excludes execution of other advice from other aspects. If this is what you want it is fine. If not, you should rather use something like !within(MyAdvice) instead.

Red5 Application fails to connect

I am attempting to run a basic application on Red5 that just makes an attempt to connect to the red5 server (on localhost). The source for this application is below:
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.scope.IScope;
// import org.red5.server.api.service.ServiceUtils;
/**
* Sample application that uses the client manager.
*
* #author The Red5 Project (red5#osflash.org)
*/
public class Application extends ApplicationAdapter {
/** {#inheritDoc} */
#Override
public boolean connect(IConnection conn, IScope scope, Object[] params) {
return true;
}
/** {#inheritDoc} */
#Override
public void disconnect(IConnection conn, IScope scope) {
super.disconnect(conn, scope);
}
}
My client code is also pretty basic. For brevity, the snippet is below:
public function onCreationComplete(event:FlexEvent) : void {
// setup connection code
connection = new NetConnection();
connection.connect("rtmp://localhost/Player");
connection.addEventListener(NetStatusEvent.NET_STATUS, onConnectionNetStatus);
connection.client = this;
}
public function onConnectionNetStatus(event:NetStatusEvent) : void {
// did we successfully connect
if(event.info.code == "NetConnection.Connect.Success") {
Alert.show("Successful Connection", "Information");
} else {
Alert.show("Unsuccessful Connection "+event.info.code, "Information");
}
Note that I make the alert box show the error code so I can see what happens.
On the client side, when I attempt to connect, I get two failure messages:
Unsuccessful Connection NetConnection.Connect.Closed
Unsuccessful Connection NetConnection.Connect.Rejected
And on the server side I am seeing the following:
[INFO] [NioProcessor-10]
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder - Action connect
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPConnection -
Setting object encoding to AMF3
[INFO] [NioProcessor-10] org.red5.server.net.rtmp.RTMPHandler - Scope
Player not found on localhost
[WARN] [Red5_Scheduler_Worker-3]
org.red5.server.net.rtmp.RTMPConnection - Closing RTMPMinaConnection
from 127.0.0.1 : 50051 to localhost (in: 3334 out 3256 ), with id 9
due to long handshake
It seems clear that something is wrong due to some kind of mis- configuration. Unfortunately, I have no idea where to look for the problem.
Could someone please give some idea of what is going wrong and how I can fix this? Thank you...
ADDITION: Startup Exception that occurs when running Red5 v1 RC2:
Exception in thread "Launcher:/Player" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with
name 'web.context' defined in ServletContext resource [/WEB-INF/red5-web.xml]:
Unsatisfied dependency expressed through bean property 'clientRegistry': : Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml];
nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1199)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1091)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
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:585)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
at org.red5.server.tomcat.TomcatLoader$1.run(TomcatLoader.java:593)
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.red5.server.WebScope] for bean with name 'web.scope' defined in ServletContext resource [/WEB-INF/red5-web.xml]; nested exception is java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1262)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:576)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1331)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:317)
at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:185)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:833)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:790)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:707)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1184)
... 11 more
Caused by: java.lang.ClassNotFoundException: org.red5.server.WebScope
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1680)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1526)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:417)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1283)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1254)
... 19 more
Another Fact could be that u have 2 Red5.jars so u have to delete one. In my case it worked rly good.
Big Ty for this post
Change org.red5.server.WebScope to org.red5.server.scope.WebScope in your red5-web.xml file.
what version of Red5 is that?
Are there any exceptions when you startup your custom webapp? There might be already an error in the startup of the server that consequently leads to your issue.
Sebastian
The application scope that you are attempting to connect to "Player" does not exist on the server; the log notes this as "Scope Player not found on localhost". What this means in general is that your application didn't load. The reason that it didn't load looks like class package error for WebScope. Change the beans class attribute to org.red5.server.scope.WebScope and try again.