Re: [jboss-user] [JBoss Microcontainer Development] - Testing jboss-reflect with a SecurityManager enabled
by Adrian Brock
Adrian Brock [http://community.jboss.org/people/adrian%40jboss.org] replied to the discussion
"Testing jboss-reflect with a SecurityManager enabled"
To view the discussion, visit: http://community.jboss.org/message/534062#534062
--------------------------------------------------------------
> Kabir Khan wrote:
>
> This has been committed against https://jira.jboss.org/jira/browse/JBREFLECT-109 https://jira.jboss.org/jira/browse/JBREFLECT-109.
>
> I did not need the extra permissions in ContainerTestPlugin, all that was needed was a IntrospectionEnumTestCase.properties:
>
> test.Permission.0=java.lang.RuntimePermission, accessClassInPackage.sun.reflect.annotation
>
>
>
>
> Without that I got this
>
>
>
> java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.reflect.annotation)
> at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
> at java.security.AccessController.checkPermission(AccessController.java:546)
> at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
> at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1512)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
> at java.lang.Class.forName0(Native Method)
> at java.lang.Class.forName(Class.java:247)
> at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
> <snip/>
>
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
> at java.util.HashMap.readObject(HashMap.java:1030)
> 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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
> at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
> at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
> at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
> at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
> at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
> at org.jboss.test.AbstractTestCase.deserialize(AbstractTestCase.java:352)
> at org.jboss.test.classinfo.test.AbstractClassInfoTest.access$0(AbstractClassInfoTest.java:1)
> at org.jboss.test.classinfo.test.AbstractClassInfoTest$1.run(AbstractClassInfoTest.java:100)
> at java.security.AccessController.doPrivileged(Native Method)
> at org.jboss.test.classinfo.test.AbstractClassInfoTest.testBasics(AbstractClassInfoTest.java:96)
> at org.jboss.test.classinfo.test.ClassInfoEnumTest.testEnum(ClassInfoEnumTest.java:71)
> at org.jboss.test.classinfo.test.ClassInfoEnumTest.testEnumFieldAnnotation(ClassInfoEnumTest.java:64)
That actually looks like a bug to me.
We are assuming that the annotations cached in InheritableAnnotationsHolder can be Serialized, but
there's no guarantee in the spec that Annotations are Serializable.
It just so happens that the ones Sun implements are, but it obviously fails to Serialize them if you have a
SecurityManager enabled due to the package restriction.
In a different JDK they might not even be Serializable.
More correctly we should reget the annotations during the readObject() processing rather than serializing them,
or probably, just let the the state revert back to UNKNOWN_ANNOTATIONS_*.
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/534062#534062]
Start a new discussion in JBoss Microcontainer Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years, 1 month
[EJB 3.0] - How can I share Entities between JBoss AS and J2SE?
by Barry Sheward
Barry Sheward [http://community.jboss.org/people/bsheward] created the discussion
"How can I share Entities between JBoss AS and J2SE?"
To view the discussion, visit: http://community.jboss.org/message/534054#534054
--------------------------------------------------------------
Hi,
I have a package full of Entity Beans (annotated with @Entity and @Table). This package exists within a JAR which until now has been deployed as part of a EAR into JBoss AS. The persistence.xml in the JAR is:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence xmlns=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="abc">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:abc/datastore/ABCDS</jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect"/>
<property name="hibernate.hbm2ddl.auto" value="validate"/>
<property name="hibernate.show_sql" value="true"/>
<property name="hibernate.format_sql" value="true"/>
</properties>
</persistence-unit>
</persistence>
I want to use the same set of Entity Beans in a J2SE application, but I've run into some problems. It seems that I cannot define 2 persistence units in the same JAR, so under time contraints, I copied my Entity Bean classes, used the following persistence.xml in a different JAR file:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Persistence deployment descriptor for dev profile -->
<persistence xmlns=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence"
xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
version="1.0">
<persistence-unit name="abc-se">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
</persistence-unit>
</persistence>
With the following code:
Map configOverrides = new HashMap();
configOverrides.put( "hibernate.dialect", "org.hibernate.dialect.SQLServerDialect" );
configOverrides.put( "hibernate.connection.driver_class", "net.sourceforge.jtds.jdbc.Driver" );
configOverrides.put( "hibernate.connection.username", user );
configOverrides.put( "hibernate.connection.password", password );
configOverrides.put( "hibernate.connection.url", url );
LOGGER.info( "Create EntityManagerFactory" );
EntityManagerFactory emf = Persistence.createEntityManagerFactory( "abc-se", configOverrides );
LOGGER.info( "Create EntityManager" );
em = emf.createEntityManager(); // Retrieve an application managed entity manager
So, my question is, how can I share a single JAR of Entities across a J2EE application? I can see a few options:
1. Create a JNDI based datasource in my J2SE application, and use the "abc" persistence unit.
2. Use the "abc" persistence unit in my J2SE application, but somehow remove the JNDI reference and use the configOverrides map before creating the EntityManager.
3. Find some way to define 2 persistence units in the same JAR
4. Something else?
Can anybody offer any advice?
Thanks and Regards,
Barry
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/534054#534054]
Start a new discussion in EJB 3.0 at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years, 1 month
Re: [jboss-user] [JBoss Microcontainer Development] - Testing jboss-reflect with a SecurityManager enabled
by Kabir Khan
Kabir Khan [http://community.jboss.org/people/kabir.khan%40jboss.com] replied to the discussion
"Testing jboss-reflect with a SecurityManager enabled"
To view the discussion, visit: http://community.jboss.org/message/534053#534053
--------------------------------------------------------------
This has been committed against https://jira.jboss.org/jira/browse/JBREFLECT-109 https://jira.jboss.org/jira/browse/JBREFLECT-109.
I did not need the extra permissions in ContainerTestPlugin, all that was needed was a IntrospectionEnumTestCase.properties:
test.Permission.0=java.lang.RuntimePermission, accessClassInPackage.sun.reflect.annotation
Without that I got this
java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.reflect.annotation)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkPackageAccess(SecurityManager.java:1512)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:327)
at java.lang.ClassLoader.loadClass(ClassLoader.java:250)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:398)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at java.io.ObjectInputStream.resolveClass(ObjectInputStream.java:604)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1575)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1496)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1732)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1030)
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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at java.util.HashMap.readObject(HashMap.java:1030)
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 java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
at org.jboss.test.AbstractTestCase.deserialize(AbstractTestCase.java:352)
at org.jboss.test.classinfo.test.AbstractClassInfoTest.access$0(AbstractClassInfoTest.java:1)
at org.jboss.test.classinfo.test.AbstractClassInfoTest$1.run(AbstractClassInfoTest.java:100)
at java.security.AccessController.doPrivileged(Native Method)
at org.jboss.test.classinfo.test.AbstractClassInfoTest.testBasics(AbstractClassInfoTest.java:96)
at org.jboss.test.classinfo.test.ClassInfoEnumTest.testEnum(ClassInfoEnumTest.java:71)
at org.jboss.test.classinfo.test.ClassInfoEnumTest.testEnumFieldAnnotation(ClassInfoEnumTest.java:64)
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/534053#534053]
Start a new discussion in JBoss Microcontainer Development at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years, 1 month
[jBPM] - Variables Performance
by Andre Muniz
Andre Muniz [http://community.jboss.org/people/andre.muniz] created the discussion
"Variables Performance"
To view the discussion, visit: http://community.jboss.org/message/534048#534048
--------------------------------------------------------------
Hi!
My use case is very simple: I need to load all the pending tasks and show information about them (including variables). But I'm having some performance problems when loading those variables.
Basically my code is like this:
// Builds the process engine
ProcessEngine processEngine = new Configuration().buildProcessEngine();
// Creates the services
TaskService taskService = processEngine.getTaskService();
ExecutionService executionService = processEngine.getExecutionService();
// Loads all the pending tasks
List < Task > tasks = taskService.createTaskQuery().list();
// Loads the variables for each task
for (Task t : tasks) {
// Variable names
Set < String > variableNames = new TreeSet < String >();
variableNames.add("var1");
variableNames.add("var2");
variableNames.add("var3");
variableNames.add("var4");
variableNames.add("var5");
// Loads the variables
Map < String, Object > variables = executionService.getVariables(t.getExecutionId(), variableNames);
// Shows variables information
System.out.println(variables);
}
The "taskService.createTaskQuery().list()" method is very fast, but the processing time to load the variables is very high.
My question is:
Am I going in the right direction or there is another way to implement this use case with better performance?
PS: I've seen the JIRA request to include searching for process instances by variables ( https://jira.jboss.org/jira/browse/JBPM-2505 https://jira.jboss.org/jira/browse/JBPM-2505) and there are some comments about variable performance, but I'm not sure that in my use case I should have this kind of problem.
Thanks!
--------------------------------------------------------------
Reply to this message by going to Community
[http://community.jboss.org/message/534048#534048]
Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&cont...]
16 years, 1 month