Java SecurityManager with SpringSecurity - securitymanager

I try join Java Security Manager to project with SpringSecurity (SS). I have the goal: my project works with SS and has dataSource (db2 database) as authentication-manager. I added ScriptManager(ScriptEngine) to project. Now I tries to setup security of project, what deny untrusted code. I use NetBeans and in properties of Tomcat (6.0.20) setup "Use Security Manager". Next, I edited {catalina.base}/conf/catalina.police. I added next "grants":
grant codeBase "file:${catalina.base}/webapps/myapp/-" {
permission java.security.AllPermission;
};
grant codeBase "file:${catalina.base}/webapps/myapp/WEB-INF/-" {
permission java.security.AllPermission;
};
grant codeBase "file:${catalina.base}/webapps/myapp/WEB-INF/lib/-" {
permission java.security.AllPermission;
};
grant codeBase "file:${catalina.base}/webapps/myapp/WEB-INF/classes/-" {
permission java.security.AllPermission;
};
grant codeBase "file:${catalina.base}/work/Catalina/localhost/myapp/" {
permission java.lang.RuntimePermission "defineClassInPackage.org.apache.jasper.runtim e";
permission java.lang.RuntimePermission "accessDeclaredMembers";
};
grant codeBase "file:${catalina.base}/webapps/myapp/-" {
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.reflect.ReflectPermission "accessDeclaredMembers";
permission java.io.FilePermission "${catalina.home}${file.separator}myapp${file.sepa rator}*", "read";
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "*";
permission java.util.PropertyPermission "*", "read";
};
And now problem. When I run my code under debuger I get next error:
07.12.2010 2:06:02 org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
07.12.2010 2:06:04 org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.http.UserDeta ilsServiceInjectionBeanPostProcessor#0': Initialization of bean failed; nested exception is java.security.AccessControlException: access denied (java.lang.RuntimePermission accessDeclaredMembers)
.................................................
and tomcat out:
Using CATALINA_BASE: /home/user/.netbeans/6.8/apache-tomcat-6.0.20_base
Using CATALINA_HOME: /usr/local/apache-tomcat-6.0.20
Using CATALINA_TMPDIR: /home/user/.netbeans/6.8/apache-tomcat-6.0.20_base/temp
Using JRE_HOME: /usr/lib/jvm/java
Using Security Manager
Listening for transport dt_socket at address: 11555
07.12.2010 2:04:43 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-sun-1.6.0.u11/jre/lib/i386/server:/usr/lib/jvm/java-1.6.0-sun-1.6.0.u11/jre/lib/i386:/usr/lib/jvm/java-1.6.0-sun-1.6.0.u11/jre/../lib/i386:/usr/lib/jvm/java-1.6.0-sun-1.6.0.u11/jre/lib/i386/client:/usr/lib/jvm/java-1.6.0-sun-1.6.0.u11/jre/lib/i386:/usr/lib/jvm/java-1.6.0-sun-1.6.0.u11/jre/../lib/i386:/usr/lib/mpi/gcc/openmpi/lib:/usr/java/packages/lib/i386:/lib:/usr/lib
07.12.2010 2:04:43 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8084
07.12.2010 2:04:43 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-9443
07.12.2010 2:04:43 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1536 ms
07.12.2010 2:04:43 org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
07.12.2010 2:04:43 org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.20
07.12.2010 2:04:45 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/deniz/NetBeansProjects/opensee/build/web/WEB-INF/lib/servlet.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
07.12.2010 2:04:45 org.apache.juli.ClassLoaderLogManager readConfiguration
WARNING: Reading /home/deniz/NetBeansProjects/opensee/build/web/WEB-INF/classes/logging.properties is not permitted. See "per context logging" in the default catalina.policy file.
07.12.2010 2:04:45 org.apache.catalina.core.StandardContext addApplicationListener
INFO: The listener "com.sun.faces.config.ConfigureListener" is already configured for this context. The duplicate definition has been ignored.
log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader).
log4j:WARN Please initialize the log4j system properly.
07.12.2010 2:04:47 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Initializing Mojarra 2.0.2 (FCS b10) for context '/opensee'
07.12.2010 2:04:47 org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
07.12.2010 2:04:47 org.apache.catalina.core.StandardContext start
SEVERE: Context [/opensee] startup failed due to previous errors
07.12.2010 2:04:47 com.sun.faces.config.ConfigureListener contextDestroyed
SEVERE: Unexpected exception when attempting to tear down the Mojarra runtime
java.lang.IllegalStateException: Application was not properly initialized at startup, could not find Factory: javax.faces.application.ApplicationFactory
at javax.faces.FactoryFinder$FactoryManager.getFactor y(FactoryFinder.java:804)
at javax.faces.FactoryFinder.getFactory(FactoryFinder .java:306)
at com.sun.faces.config.InitFacesContext.getApplicati on(InitFacesContext.java:104)
at com.sun.faces.config.ConfigureListener.contextDest royed(ConfigureListener.java:309)
at org.apache.catalina.core.StandardContext.listenerS top(StandardContext.java:3973)
at org.apache.catalina.core.StandardContext.stop(Stan dardContext.java:4577)
.................
Also, when I insert this grant:
grant {
permission java.security.AllPermission;
};
all ok.
OS: openSUSE 11.1
OpenJDK 1.6.0.0-b11
For setup used this tutorial: http://www.mikeski.net/site/node/18
Thanks all...

Related

Apache ranger 2.1.0 - Installation failed

I am trying to install the latest version of Apache ranger 2.1.0 and getting this error while installing ranger admin. [E] Ranger all admins default password change request failed and there is not much error logs.
2020-09-05 20:21:14,541 [JISQL] /usr/lib/jvm/jre-11-openjdk-11.0.8.10-0.el7_8.x86_64/bin/java -cp /usr/share/java/mysql-connector-java.jar:/opt/apache-ranger/ranger-2.1.0-admin/jisql/lib/* org.apache.util.sql.Jisql -driver mysqlconj -cstring jdbc:mysql://localhost/ranger -u 'ranger' -p '********' -noheader -trim -c \; -query "insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by,active) values ('DEFAULT_ALL_ADMIN_UPDATE', current_timestamp, 'Ranger 2.1.0', current_timestamp, 'pas-bifrostx0.myntra.com','N') ;"
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2020-09-05 20:21:15,219 [I] Ranger all admins default password change request is in process..
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.persistence.internal.security.PrivilegedAccessHelper (file:/opt/apache-ranger/ranger-2.1.0-admin/ews/webapp/WEB-INF/lib/eclipselink-2.5.2.jar) to method com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.getXmlEncoding()
WARNING: Please consider reporting this to the maintainers of org.eclipse.persistence.internal.security.PrivilegedAccessHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-09-05 20:21:19,448 [JISQL] /usr/lib/jvm/jre-11-openjdk-11.0.8.10-0.el7_8.x86_64/bin/java -cp /usr/share/java/mysql-connector-java.jar:/opt/apache-ranger/ranger-2.1.0-admin/jisql/lib/* org.apache.util.sql.Jisql -driver mysqlconj -cstring jdbc:mysql://localhost/ranger -u 'ranger' -p '********' -noheader -trim -c \; -query "delete from x_db_version_h where version = 'DEFAULT_ALL_ADMIN_UPDATE' and active = 'N' and updated_by='pas-bifrostx0.myntra.com';"
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
2020-09-05 20:21:20,073 [E] Ranger all admins default password change request failed
Also, regardless of this error, I was able to start the service with sudo ranger-admin start and is able to do telnet localhost 6080 but web UI is not showing up.
Found the following error in ews/logs/catalina.out
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class org.apache.ranger.entity.XXAccessAuditV4] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1619)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1082)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:857)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:443)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:325)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5128)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5653)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1689)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1679)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.persistence.PersistenceException: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [defaultPU] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class org.apache.ranger.entity.XXAccessAuditV4] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.createPredeployFailedPersistenceException(EntityManagerSetupImpl.java:1954)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1945)
at org.eclipse.persistence.jpa.PersistenceProvider.createContainerEntityManagerFactory(PersistenceProvider.java:322)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:360)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:384)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:371)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.afterPropertiesSet(LocalContainerEntityManagerFactoryBean.java:336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1677)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1615)
... 21 more
Caused by: Exception [EclipseLink-28018] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.EntityManagerSetupException
Exception Description: Predeployment of PersistenceUnit [defaultPU] failed.
Internal Exception: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class org.apache.ranger.entity.XXAccessAuditV4] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.exceptions.EntityManagerSetupException.predeployFailed(EntityManagerSetupException.java:230)
... 30 more
Caused by: Exception [EclipseLink-7161] (Eclipse Persistence Services - 2.5.2.v20140319-9ad6abd): org.eclipse.persistence.exceptions.ValidationException
Exception Description: Entity class [class org.apache.ranger.entity.XXAccessAuditV4] has no primary key specified. It should define either an #Id, #EmbeddedId or an #IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy.
at org.eclipse.persistence.exceptions.ValidationException.noPrimaryKeyAnnotationsFound(ValidationException.java:1422)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.validatePrimaryKey(EntityAccessor.java:1536)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.processMappingAccessors(EntityAccessor.java:1243)
at org.eclipse.persistence.internal.jpa.metadata.accessors.classes.EntityAccessor.process(EntityAccessor.java:697)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProject.processStage2(MetadataProject.java:1793)
at org.eclipse.persistence.internal.jpa.metadata.MetadataProcessor.processORMMetadata(MetadataProcessor.java:576)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processORMetadata(PersistenceUnitProcessor.java:585)
at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.predeploy(EntityManagerSetupImpl.java:1869)
... 28 more
Sep 05, 2020 2:56:32 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
Sep 05, 2020 2:56:32 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [] startup failed due to previous errors
Sep 05, 2020 2:56:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Closing Spring root WebApplicationContext
Sep 05, 2020 2:56:32 PM org.apache.catalina.core.ApplicationContext log
INFO: Shutting down log4j
Sep 05, 2020 2:56:32 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [com.mysql.cj.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 05, 2020 2:56:32 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
SEVERE: The web application [] registered the JDBC driver [org.apache.solr.client.solrj.io.sql.DriverImpl] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
Sep 05, 2020 2:56:32 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [org.apache.hadoop.fs.FileSystem$Statistics$StatisticsDataReferenceCleaner] but has failed to stop it. This is very likely to create a memory leak.
Sep 05, 2020 2:56:32 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [mysql-cj-abandoned-connection-cleanup] but has failed to stop it. This is very likely to create a memory leak.
Sep 05, 2020 2:56:32 PM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal#2dfce76e]) and a value of type [org.apache.hadoop.fs.FileSystem.Statistics.StatisticsData] (value [9910 bytes read, 0 bytes written, 0 read ops, 0 large read ops, 0 write ops]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Sep 05, 2020 2:56:32 PM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks
SEVERE: The web application [] created a ThreadLocal with key of type [org.apache.htrace.core.Tracer.ThreadLocalContext] (value [org.apache.htrace.core.Tracer$ThreadLocalContext#4073a8a9]) and a value of type [org.apache.htrace.core.Tracer.ThreadContext] (value [org.apache.htrace.core.Tracer$ThreadContext#42aecda1]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Sep 05, 2020 2:56:32 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-6080"]
Sep 05, 2020 2:56:37 PM org.apache.catalina.loader.WebappClassLoaderBase findResourceInternal
INFO: Illegal access: this web application instance has been stopped already. Could not load []. The following stack trace is thrown for debugging purposes as well as to attempt to terminate the thread which caused the illegal access.
Can someone please help here or redirect me to Ranger community so that I can reach out to someone for here.
Thanks in advance.
Issues were related to JAVA 11. I was trying to run ranger with JAVA 11
(https://issues.apache.org/jira/browse/RANGER-2575) but seems like it doesn't work. Building and running against java 8 worked.

Remote EJB lookup using OpenEJB in Tomee

Am trying to use example given here
http://openejb.apache.org/hello-world.html
With OpenEJB I am able to output HelloWorld
I am trying same in Apache Tomee
I have Remote EJB bean like this
#Remote
public interface Hello{
public String sayHello();
}
#Stateless
public class HelloBean implements Hello{
public String sayHello(){
return "Hello World!!!!";
}
}
packed it in a jar
jar cvf hello.jar org
Deployed on Apache Tomee
Tomee Log after deploying hello.jar
03-Oct-2017 15:55:51.778 INFO [localhost-startStop-1] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/home/ashish/apache-tomee-plus-7.0.2/webapps/manager)
03-Oct-2017 15:55:51.805 INFO [localhost-startStop-1] sun.reflect.DelegatingMethodAccessorImpl.invoke At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
03-Oct-2017 15:55:51.826 INFO [localhost-startStop-1] sun.reflect.DelegatingMethodAccessorImpl.invoke Deployment of web application directory /home/ashish/apache-tomee-plus-7.0.2/webapps/manager has finished in 137 ms
03-Oct-2017 15:55:51.831 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Starting ProtocolHandler [http-nio-8080]
03-Oct-2017 15:55:51.839 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Starting ProtocolHandler [ajp-nio-8009]
03-Oct-2017 15:55:51.845 INFO [main] sun.reflect.DelegatingMethodAccessorImpl.invoke Server startup in 5735 ms
03-Oct-2017 15:56:51.874 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.config.ConfigurationFactory.configureApplication Configuring enterprise application: /home/ashish/apache-tomee-plus-7.0.2/webapps/hello.jar
03-Oct-2017 15:56:51.914 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.config.InitEjbDeployments.deploy Auto-deploying ejb HelloBean: EjbDeployment(deployment-id=HelloBean)
03-Oct-2017 15:56:51.915 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.config.AppInfoBuilder.build Enterprise application "/home/ashish/apache-tomee-plus-7.0.2/webapps/hello.jar" loaded.
03-Oct-2017 15:56:51.925 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.Assembler.createAppClassLoader Creating dedicated application classloader for hello
03-Oct-2017 15:56:51.926 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.Assembler.createApplication Assembling app: /home/ashish/apache-tomee-plus-7.0.2/webapps/hello.jar
03-Oct-2017 15:56:51.945 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.JndiBuilder.bind Jndi(name=HelloBeanRemote) --> Ejb(deployment-id=HelloBean)
03-Oct-2017 15:56:51.945 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.JndiBuilder.bind Jndi(name=global/hello/HelloBean!org.acme.Hello) --> Ejb(deployment-id=HelloBean)
03-Oct-2017 15:56:51.945 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.JndiBuilder.bind Jndi(name=global/hello/HelloBean) --> Ejb(deployment-id=HelloBean)
03-Oct-2017 15:56:51.969 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.Assembler.startEjbs Created Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=Default Stateless Container)
03-Oct-2017 15:56:51.987 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.Assembler.startEjbs Started Ejb(deployment-id=HelloBean, ejb-name=HelloBean, container=Default Stateless Container)
03-Oct-2017 15:56:51.988 INFO [ContainerBackgroundProcessor[StandardEngine[Catalina]]] org.apache.openejb.assembler.classic.Assembler.createApplication Deployed Application(path=/home/ashish/apache-tomee-plus-7.0.2/webapps/hello.jar)
Now I have created void main class and trying to access this EJB
It throws error
My Main Class
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
public class HelloClient {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
//props.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
//props.put(Context.PROVIDER_URL, "ejbd://localhost:8080");
//props.put(Context.PROVIDER_URL, " http://localhost:8080/openejb/ejb");
Context ctx = new InitialContext(props);
Object ref = ctx.lookup("HelloBeanRemote");
Hello h = (Hello) PortableRemoteObject.narrow(ref, Hello.class);
String result = h.sayHello();
System.out.println(result);
}
}
using : props.put(Context.PROVIDER_URL, "ejbd://127.0.0.1:4201");
run:
Oct 03, 2017 7:12:26 PM org.apache.openejb.client.StickToLastServerConnectionFactoryStrategy connect
WARNING: Cannot connect to server(s): 127.0.0.1:4201 Exception:
java.net.ConnectException: Cannot connect to server 'ejbd://127.0.0.1:4201'. Check that the server is started and that the specified serverURL is correct.
at org.apache.openejb.client.SocketConnectionFactory$SocketConnection.open(SocketConnectionFactory.java:55)
at org.apache.openejb.client.SocketConnectionFactory.getConnection(SocketConnectionFactory.java:35)
at org.apache.openejb.client.ConnectionManager.getConnection(ConnectionManager.java:43)
at org.apache.openejb.client.StickToLastServerConnectionFactoryStrategy.connect(StickToLastServerConnectionFactoryStrategy.java:70)
at org.apache.openejb.client.StickToLastServerConnectionFactoryStrategy.connect(StickToLastServerConnectionFactoryStrategy.java:47)
at org.apache.openejb.client.ServerMetaData.connect(ServerMetaData.java:57)
at org.apache.openejb.client.Client.processRequest(Client.java:58)
at org.apache.openejb.client.Client.request(Client.java:42)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:87)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:234)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at java8demo.HelloClient.main(HelloClient.java:25)
Exception in thread "main" javax.naming.NamingException: Cannot lookup '/HelloBeanRemote'. [Root exception is java.rmi.RemoteException: Cannot connect to any servers: Server #0: ejbd://127.0.0.1:4201]
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:240)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at java8demo.HelloClient.main(HelloClient.java:25)
Caused by: java.rmi.RemoteException: Cannot connect to any servers: Server #0: ejbd://127.0.0.1:4201
at org.apache.openejb.client.StickToLastServerConnectionFactoryStrategy.connect(StickToLastServerConnectionFactoryStrategy.java:66)
at org.apache.openejb.client.ServerMetaData.connect(ServerMetaData.java:57)
at org.apache.openejb.client.Client.processRequest(Client.java:58)
at org.apache.openejb.client.Client.request(Client.java:42)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:87)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:234)
... 2 more
/home/ashish/.cache/netbeans/8.2/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
using: props.put(Context.PROVIDER_URL, "ejbd://localhost:8080");
run:
Exception in thread "main" javax.naming.NamingException: Cannot lookup '/HelloBeanRemote'. [Root exception is java.rmi.RemoteException: Cannot open object output stream to server: ; nested exception is:
java.net.SocketException: Broken pipe (Write failed)]
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:240)
at javax.naming.InitialContext.lookup(InitialContext.java:417)
at java8demo.HelloClient.main(HelloClient.java:25)
Caused by: java.rmi.RemoteException: Cannot open object output stream to server: ; nested exception is:
java.net.SocketException: Broken pipe (Write failed)
at org.apache.openejb.client.Client.processRequest(Client.java:107)
at org.apache.openejb.client.Client.request(Client.java:42)
at org.apache.openejb.client.JNDIContext.request(JNDIContext.java:87)
at org.apache.openejb.client.JNDIContext.lookup(JNDIContext.java:234)
... 2 more
Caused by: java.net.SocketException: Broken pipe (Write failed)
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1877)
at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(ObjectOutputStream.java:1786)
at java.io.ObjectOutputStream.<init>(ObjectOutputStream.java:247)
at org.apache.openejb.client.Client.processRequest(Client.java:104)
... 5 more
/home/ashish/.cache/netbeans/8.2/executor-snippets/run.xml:53: Java returned: 1
BUILD FAILED (total time: 0 seconds)
By default Tomee doesn't allow Remote EJB lookup
you need to enable it inside Apache-Tomee/conf/system.properties file
// enable remote access
tomee.remote.support = true
// blacklist none
tomee.serialization.class.blacklist = -
// whitelist all classes or you can define your classes
tomee.serialization.class.whitelist = *
openejb.system.apps = true
openejb.servicemanager.enabled = true
once these configuration are changeed, restart tomee and tomee deploy your EJB's
and all EJB's can be accessed using following url
Properties p = new Properties();
p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
p.put(Context.PROVIDER_URL, "http://localhost:8080/tomee/ejb");
final InitialContext ctx = new InitialContext(p);
Hello hbr = (Hello) ctx.lookup("HelloBeanRemote");
One other mistake I was doing that
I used openejb-client-3.0.jar from OpenEJb container
instead of openejb-client-7.0.2.jar from apache lib folder
Use client jar above 3 version

Struts startup failed due to logging errors

Struts application can not start with log4j.
What is wrong?
Here is log4j.properties:
# Direct to stdout
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
# Root logger option
log4j.rootLogger=INFO, stdout
# Good for troubleshooting
log4j.logger.org.hibernate=INFO
# Log JDBC parameters
log4j.logger.org.hibernate.type=ALL
Struts startup failed due to logging errors.
INFO: Starting Servlet Engine: Apache Tomcat/7.0.55
апр 28, 2015 3:42:01 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter struts2
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:120)
at com.opensymphony.xwork2.util.logging.commons.CommonsLogger.info(CommonsLogger.java:42)
at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:175)
at org.apache.struts2.config.StrutsXmlConfigurationProvider.register(StrutsXmlConfigurationProvider.java:102)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:234)
...
апр 28, 2015 3:42:01 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
апр 28, 2015 3:42:01 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/Struts2HiberQuize_last] startup failed due to previous errors
Your application server is failing to start due to problems with SLF4J (Simple Logging Facade for Java), not Log4j. You are probably:
including an old version of SLF4J, or
mixing multiple versions of SLF4J (one of which old), or
there is an old SLF4J version in the application server's shared libraries.
To fix this,
ensure you have the latest version of SLF4J, or a version higher than 1.6.0;
if not enough, check out which SLF4J classes are loaded ( and from where), as described here.

Sample Grails 2.14 app not working in Tomcat

Grails 2.1.4
Tomcat 7.0.37
Java 1.7
Window 7
I created Sample Grails app in eclipse, i run with run-app. it is working fine and able to open in brower also.
But for same application, i build .war file with grails:maven-install. And i am trying to deploy, But i am getting below error:
Mar 26, 2013 11:56:26 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/HelloGrails-0.1] startup failed due to previous errors
Mar 26, 2013 11:56:26 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/HelloGrails-0.1] created a ThreadLocal with key of type [org.codehaus.groovy.runtime.GroovyCategorySupport.MyThreadLocal] (value [org.codehaus.groovy.runtime.GroovyCategorySupport$MyThreadLocal#644aa32b]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference#601e8f7d]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Mar 26, 2013 11:56:26 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/HelloGrails-0.1] created a ThreadLocal with key of type [org.codehaus.groovy.reflection.ClassInfo.ThreadLocalMapHandler] (value [org.codehaus.groovy.reflection.ClassInfo$ThreadLocalMapHandler#639ca35]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference#3c0a60c4]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Please help me..............
Thanks,
Ravi
create a file named logging.properties in WEB-INF/classes with following content:
org.apache.catalina.core.ContainerBase.[Catalina].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler
Restart apache and look to the stacktrace

Failure to deploy grails app with cloudfoundry plugin

"grails cf-push" results in errors listed below. Is there a way using the cloudfoundry plugin to "start fresh". I would prefer not to lose my test data in a MySQL database and a MongoDB database.
May 18, 2012 6:31:26 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 18, 2012 6:31:26 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors
May 18, 2012 6:31:26 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [] created a ThreadLocal with key of type [org.codehaus.groovy.reflection.ClassInfo.ThreadLocalMapHandler] (value [org.codehaus.groovy.reflection.ClassInfo$ThreadLocalMapHandler#6434d75f]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference#4927d15e]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
2012-05-18 18:31:26,379 [main] ERROR context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'grailsApplication' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager
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:384)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:66)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: java.lang.NoClassDefFoundError: org/apache/http/conn/ClientConnectionManager
at java.lang.Class.forName(Class.java:169)
at java.lang.Class.forName(Class.java:247)
Caused by: java.lang.ClassNotFoundException: org.apache.http.conn.ClientConnectionManager
... 2 more
Stopping Tomcat because the context stopped.
stderr.log is :
May 18, 2012 6:41:00 PM org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-31903
May 18, 2012 6:41:00 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 403 ms
May 18, 2012 6:41:00 PM org.apache.catalina.realm.JAASRealm setContainer
INFO: Set JAAS app name Catalina
May 18, 2012 6:41:00 PM org.apache.catalina.core.StandardService start
INFO: Starting service Catalina
May 18, 2012 6:41:00 PM org.apache.catalina.core.StandardEngine start
INFO: Starting Servlet Engine: Apache Tomcat/6.0.35
May 18, 2012 6:41:00 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory ROOT
May 18, 2012 6:41:02 PM org.apache.catalina.core.StandardContext start
SEVERE: Error listenerStart
May 18, 2012 6:41:02 PM org.apache.catalina.core.StandardContext start
SEVERE: Context [] startup failed due to previous errors
May 18, 2012 6:41:02 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [] created a ThreadLocal with key of type [org.codehaus.groovy.reflection.ClassInfo.ThreadLocalMapHandler] (value org.codehaus.groovy.reflection.ClassInfo$ThreadLocalMapHandler#6d1576d7]) and a value of type [java.lang.ref.SoftReference] (value [java.lang.ref.SoftReference#1c2d5534]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
If you do cf-update or delete the app and re-run cf-push, it will ask you if you want to use the existing MySQL and Mongo services. If you do there isn't any data loss - just don't delete the services along with the app before re-running cf-push.
Make sure you're using 'grails prod cf-push' since that will use the production configuration - there is a warning displayed if you run 'grails cf-push' to that effect.
The root cause is a CNFE from the HttpClient library. See if you can get it working locally and it should work fine on Cloud Foundry since you're just pushing a war file.
I found the problem. I added a service that used an external jar from a third party package. The third party package shipped with 2 jars: one with dependencies and one without dependencies. I extracted the 3rd party zip into my classpath, but only included the one without dependencies in my lib directory. When I switched to using the jar with dependencies, the app deployed.The following things made this simple problem difficult to resolve:the error logs simply stated that there was a problem with 'grailsApplication' and there was a class not foundthe app ran on my workstation using run-app,the app doesn't run on my workstation using run-war (regardless of whether the correct jars are supplied),lack of sleep!
On to the next issue!

Resources