[JBoss JIRA] Created: (JBSER-117) Problem with JBoss serializing of dynamic proxies
by Maksym Ivanchenko (JIRA)
Problem with JBoss serializing of dynamic proxies
-------------------------------------------------
Key: JBSER-117
URL: https://jira.jboss.org/jira/browse/JBSER-117
Project: JBoss Serialization
Issue Type: Bug
Affects Versions: 1.0.3 GA
Reporter: Maksym Ivanchenko
Assignee: Clebert Suconic
When we try to serialize a proxy that contains some child entity which points to proxy itself the following exception occurs:
org.jboss.serial.exception.SerializationException: Object reference 1 was not found
Simple test case for problem reproducing:
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.jboss.serial.io.JBossObjectOutputStream;
import org.junit.Test;
public class StandaloneProxySerializationTest {
@Test
public void testSerialization() throws Exception {
ISampleEntity entity = new SampleEntityImpl();
Class<?>[] interfaces = new Class<?>[] {ISampleEntity.class};
SampleEntityInvocationHandler handler = new SampleEntityInvocationHandler(entity);
ISampleEntity proxy = (ISampleEntity) Proxy.newProxyInstance(Thread.currentThread()
.getContextClassLoader(), interfaces, handler);
ISampleEntity childEntity = new SampleEntityImpl();
proxy.setChild(childEntity);
childEntity.setParent(proxy);
JBossObjectOutputStream jbossSerializer = new JBossObjectOutputStream(null);
jbossSerializer.smartClone(proxy);
}
private static interface ISampleEntity {
public ISampleEntity getParent();
public void setParent(ISampleEntity parent);
public ISampleEntity getChild();
public void setChild(ISampleEntity child);
}
private static class SampleEntityImpl implements ISampleEntity, Serializable {
private static final long serialVersionUID = 1L;
private ISampleEntity parent;
private ISampleEntity child;
@Override
public ISampleEntity getParent() {
return parent;
}
@Override
public void setParent(ISampleEntity parent) {
this.parent = parent;
}
@Override
public ISampleEntity getChild() {
return child;
}
@Override
public void setChild(ISampleEntity child) {
this.child = child;
}
}
private static class SampleEntityInvocationHandler implements InvocationHandler, Serializable {
private static final long serialVersionUID = 1L;
private ISampleEntity entity;
public SampleEntityInvocationHandler(ISampleEntity entity) {
this.entity = entity;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return method.invoke(entity, args);
}
}
}
Upon ivestigating this issue we found that the problem is in ProxyPersister.readData() method. It reads the handler, the proxy class, constructs a proxy and only then puts it to cache. But if a proxy data contains proxy itself then it tries to find it by reference (which is not in cache yet, because the handler is still being read). So it throws "Object reference not found" exception.
We worked around this problem by introducing an InvocationHandler wrapper in ProxyPersister:
Patched ProxyPersister.java:
/*
* JBoss, Home of Professional Open Source
* Copyright 2005, JBoss Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.serial.persister;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import org.jboss.serial.classmetamodel.ClassMetaData;
import org.jboss.serial.classmetamodel.StreamingClass;
import org.jboss.serial.exception.SerializationException;
import org.jboss.serial.objectmetamodel.ObjectSubstitutionInterface;
import org.jboss.serial.objectmetamodel.ObjectsCache;
/**
* $Id: ProxyPersister.java,v 1.11 2006/04/24 23:49:40 csuconic Exp $
*
* @author <a href="mailto:clebert.suconic@jboss.com">Clebert Suconic</a>
*/
public class ProxyPersister implements Persister {
private byte id;
public byte getId() {
return id;
}
public void setId(byte id) {
this.id = id;
}
public void writeData(ClassMetaData metaData, ObjectOutput output, Object obj, ObjectSubstitutionInterface substitution) throws IOException{
Object handler = Proxy.getInvocationHandler(obj);
output.writeObject(obj.getClass());
output.writeObject(handler);
}
static class InvocationHandlerWrapper implements InvocationHandler {
private InvocationHandler wrappedHandler;
public void setWrappedHandler(InvocationHandler wrappedHandler) {
this.wrappedHandler = wrappedHandler;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return wrappedHandler.invoke(proxy, method, args);
}
}
public Object readData (ClassLoader loader, StreamingClass streaming, ClassMetaData metaData, int referenceId, ObjectsCache cache, ObjectInput input, ObjectSubstitutionInterface substitution) throws IOException{
try
{
Class proxy = (Class)input.readObject();
Constructor constructor = proxy.getConstructor(new Class[] { InvocationHandler.class });
InvocationHandlerWrapper wrapper = new InvocationHandlerWrapper();
Object obj = constructor.newInstance(new Object[]{wrapper});
cache.putObjectInCacheRead(referenceId,obj);
Object handler = input.readObject();
wrapper.setWrappedHandler((InvocationHandler) handler);
return obj;
}
catch (ClassNotFoundException e)
{
throw new SerializationException(e);
}
catch (NoSuchMethodException e)
{
throw new SerializationException(e);
}
catch (IllegalAccessException e)
{
throw new SerializationException(e);
}
catch (InstantiationException e)
{
throw new SerializationException(e);
}
catch (InvocationTargetException e)
{
throw new SerializationException(e);
}
}
public boolean canPersist(Object obj)
{
// not implemented
return false;
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months
[JBoss JIRA] Created: (AS7-1425) Cannot obtain SchemaFactory when TCCL points to ARQ module
by Thomas Diesler (JIRA)
Cannot obtain SchemaFactory when TCCL points to ARQ module
----------------------------------------------------------
Key: AS7-1425
URL: https://issues.jboss.org/browse/AS7-1425
Project: Application Server 7
Issue Type: Bug
Components: OSGi
Reporter: Thomas Diesler
Assignee: Thomas Diesler
Fix For: 7.1.0.Alpha1
{code}
10:46:41,387 ERROR [org.apache.aries.blueprint.container.BlueprintContainerImpl] (pool-7-thread-1) Unable to start blueprint container for bundle example-blueprint: java.lang.IllegalArgumentException: No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema could be loaded
at javax.xml.validation.SchemaFactory.newInstance(SchemaFactory.java:207) [:1.6.0_26]
at org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl.getSchemaFactory(NamespaceHandlerRegistryImpl.java:266) [NamespaceHandlerRegistryImpl.class:]
at org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl.getSchema(NamespaceHandlerRegistryImpl.java:236) [NamespaceHandlerRegistryImpl.class:]
at org.apache.aries.blueprint.namespace.NamespaceHandlerRegistryImpl$NamespaceHandlerSetImpl.getSchema(NamespaceHandlerRegistryImpl.java:306) [NamespaceHandlerRegistryImpl$NamespaceHandlerSetImpl.class:]
{code}
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months
[JBoss JIRA] Created: (AS7-940) javax.xml.xpath.XPathFactory.newInstance() fails when invoked from a user bundle
by David Bosschaert (JIRA)
javax.xml.xpath.XPathFactory.newInstance() fails when invoked from a user bundle
--------------------------------------------------------------------------------
Key: AS7-940
URL: https://issues.jboss.org/browse/AS7-940
Project: Application Server 7
Issue Type: Bug
Components: OSGi
Reporter: David Bosschaert
When deploying the simple greeter impl bundle (CXF-DOSGi demo) the following exception appears. Note that this does work fine with other OSGi frameworks like Equinox and Felix.
Creating Service {http://greeter.samples.dosgi.cxf.apache.org/}GreeterService from class org.apache.cxf.dosgi.samples.greeter.GreeterService
Exception in thread "pool-3-thread-1" java.lang.ExceptionInInitializerError
at org.apache.cxf.aegis.type.XMLTypeCreator.<init>(XMLTypeCreator.java:134)
at org.apache.cxf.aegis.AegisContext.createRootTypeCreator(AegisContext.java:119)
at org.apache.cxf.aegis.AegisContext.createTypeCreator(AegisContext.java:108)
at org.apache.cxf.aegis.AegisContext.initialize(AegisContext.java:150)
at org.apache.cxf.aegis.databinding.AegisDatabinding.initialize(AegisDatabinding.java:262)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:467)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:530)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:278)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:99)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:105)
at org.apache.cxf.dosgi.dsw.handlers.PojoConfigurationTypeHandler.createServer(PojoConfigurationTypeHandler.java:125)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminCore.exportService(RemoteServiceAdminCore.java:244)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:78)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance$1.run(RemoteServiceAdminInstance.java:71)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:71)
at org.apache.cxf.dosgi.dsw.service.RemoteServiceAdminInstance.exportService(RemoteServiceAdminInstance.java:40)
at org.apache.cxf.dosgi.topologymanager.TopologyManager$2.run(TopologyManager.java:254)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.RuntimeException: XPathFactory#newInstance() failed to create an XPathFactory for the default object model: http://java.sun.com/jaxp/xpath/dom with the XPathFactoryConfigurationException: javax.xml.xpath.XPathFactoryConfigurationException: No XPathFactory implementation found for the object model: http://java.sun.com/jaxp/xpath/dom
at javax.xml.xpath.XPathFactory.newInstance(XPathFactory.java:101)
at org.apache.cxf.helpers.XPathUtils.<clinit>(XPathUtils.java:34)
... 21 more
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months
[JBoss JIRA] Created: (JBAS-8827) Deal with expression values in all operation handlers
by Brian Stansberry (JIRA)
Deal with expression values in all operation handlers
-----------------------------------------------------
Key: JBAS-8827
URL: https://issues.jboss.org/browse/JBAS-8827
Project: JBoss Application Server
Issue Type: Task
Security Level: Public (Everyone can see)
Components: Domain Management
Reporter: Brian Stansberry
Priority: Critical
Fix For: 7.0.0.Beta1
Pretty much any simple value in a detyped operation can be of type ModelType.EXPRESSION instead something an OperationHandler might expect, like ModelType.STRING or ModelType.INT. All handlers need to deal with this fact.
There are two main aspects to this:
1) Any parameter validation that goes on needs to account for the presence of expression values. Basically that means
a) accept the expression for storage in the model
b) call resolve() on the operation and use the resolved version for application to the runtime.
c) re-validation of the resolved value may be necessary
--
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
12 years, 11 months