You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/03/03 17:05:43 UTC
svn commit: r633150 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/java/org/apache/tapestry/internal/services/
main/java/org/apache/tapestry/services/ site/apt/ test/app1/
test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry...
Author: hlship
Date: Mon Mar 3 08:05:41 2008
New Revision: 633150
URL: http://svn.apache.org/viewvc?rev=633150&view=rev
Log:
TAPESTRY-2078: More understandable error messages needed when incorrect classes found in component/page packages
Added:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobals.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobalsImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Datum.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DatumEditor.java
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt
tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImpl.java?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImpl.java Mon Mar 3 08:05:41 2008
@@ -47,6 +47,8 @@
private final ClassLoader _parent;
+ private final InternalRequestGlobals _internalRequestGlobals;
+
private Loader _loader;
private final ComponentClassTransformer _transformer;
@@ -79,11 +81,13 @@
}
- public ComponentInstantiatorSourceImpl(ClassLoader parent, ComponentClassTransformer transformer, Logger logger)
+ public ComponentInstantiatorSourceImpl(Logger logger, ClassLoader parent, ComponentClassTransformer transformer,
+ InternalRequestGlobals internalRequestGlobals)
{
_parent = parent;
_transformer = transformer;
_logger = logger;
+ _internalRequestGlobals = internalRequestGlobals;
initializeService();
}
@@ -164,6 +168,12 @@
writeClassToFileSystemForHardCoreDebuggingPurposesOnly(ctClass);
diag = "END";
+ }
+ catch (RuntimeException classLoaderException)
+ {
+ _internalRequestGlobals.storeClassLoaderException(classLoaderException);
+
+ throw classLoaderException;
}
finally
{
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalClassTransformationImpl.java Mon Mar 3 08:05:41 2008
@@ -260,7 +260,8 @@
names.add(name);
}
- if (!names.isEmpty()) throw new RuntimeException(ServicesMessages.nonPrivateFields(getClassName(), names));
+ if (!names.isEmpty())
+ throw new RuntimeException(ServicesMessages.nonPrivateFields(getClassName(), names));
}
private void addMemberNames(CtMember[] members)
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobals.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobals.java?rev=633150&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobals.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobals.java Mon Mar 3 08:05:41 2008
@@ -0,0 +1,25 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+/**
+ * Stores global per-request data internal to the framework.
+ */
+public interface InternalRequestGlobals
+{
+ void storeClassLoaderException(Throwable classLoaderException);
+
+ Throwable getClassLoaderException();
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobalsImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobalsImpl.java?rev=633150&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobalsImpl.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/InternalRequestGlobalsImpl.java Mon Mar 3 08:05:41 2008
@@ -0,0 +1,35 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.internal.services;
+
+import static org.apache.tapestry.ioc.IOCConstants.PERTHREAD_SCOPE;
+import org.apache.tapestry.ioc.annotations.Scope;
+
+
+@Scope(PERTHREAD_SCOPE)
+public class InternalRequestGlobalsImpl implements InternalRequestGlobals
+{
+ private Throwable _classLoaderException;
+
+ public Throwable getClassLoaderException()
+ {
+ return _classLoaderException;
+ }
+
+ public void storeClassLoaderException(Throwable classLoaderException)
+ {
+ _classLoaderException = classLoaderException;
+ }
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java Mon Mar 3 08:05:41 2008
@@ -120,6 +120,7 @@
binder.bind(BaseURLSource.class, BaseURLSourceImpl.class);
binder.bind(RequestSecurityManager.class, RequestSecurityManagerImpl.class);
binder.bind(BeanBlockOverrideSource.class, BeanBlockOverrideSourceImpl.class);
+ binder.bind(InternalRequestGlobals.class, InternalRequestGlobalsImpl.class);
}
public static Alias build(Logger logger,
@@ -501,6 +502,8 @@
@IntermediateType(TimeInterval.class)
long updateTimeout,
+ final InternalRequestGlobals requestGlobals,
+
LocalizationSetter localizationSetter)
{
RequestFilter staticFilesFilter = new StaticFilesFilter(context);
@@ -520,6 +523,14 @@
}
catch (Throwable ex)
{
+ // Most of the time, we've got exception linked up the kazoo ... but when ClassLoaders
+ // get involved, things go screwy. Exceptions when transforming classes can cause
+ // a NoClassDefFoundError with no cause; here we're trying to link the cause back in.
+ // TAPESTRY-2078
+
+ if (ex.getCause() == null)
+ ex.initCause(requestGlobals.getClassLoaderException());
+
exceptionHandler.handleRequestException(ex);
// We assume a reponse has been sent and there's no need to handle the request
@@ -1730,10 +1741,12 @@
ComponentClassTransformer transformer,
- Logger logger)
+ Logger logger,
+
+ InternalRequestGlobals internalRequestGlobals)
{
- ComponentInstantiatorSourceImpl source = new ComponentInstantiatorSourceImpl(classFactory
- .getClassLoader(), transformer, logger);
+ ComponentInstantiatorSourceImpl source = new ComponentInstantiatorSourceImpl(logger, classFactory
+ .getClassLoader(), transformer, internalRequestGlobals);
_updateListenerHub.addUpdateListener(source);
@@ -2071,12 +2084,11 @@
}
/**
- * Contributes filters: <dl> <dt>Ajax</dt>
- * <dd>Determines if the request is Ajax oriented, and redirects to an alternative handler if so</dd>
- * <dt>ImmediateRender</dt> <dd>When {@linkplain org.apache.tapestry.TapestryConstants#SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS_SYMBOL
- * immediate action response rendering} is enabled, generates the markup response (instead of a page redirect
- * response, which is the normal behavior) </dd> <dt>Secure</dt> <dd>Sends a redirect if an non-secure request
- * accesses a secure page</dd></dl>
+ * Contributes filters: <dl> <dt>Ajax</dt> <dd>Determines if the request is Ajax oriented, and redirects to an
+ * alternative handler if so</dd> <dt>ImmediateRender</dt> <dd>When {@linkplain
+ * org.apache.tapestry.TapestryConstants#SUPPRESS_REDIRECT_FROM_ACTION_REQUESTS_SYMBOL immediate action response
+ * rendering} is enabled, generates the markup response (instead of a page redirect response, which is the normal
+ * behavior) </dd> <dt>Secure</dt> <dd>Sends a redirect if an non-secure request accesses a secure page</dd></dl>
*/
public void contributeComponentEventRequestHandler(OrderedConfiguration<ComponentEventRequestFilter> configuration,
final RequestSecurityManager requestSecurityManager,
Modified: tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/site/apt/upgrade.apt Mon Mar 3 08:05:41 2008
@@ -68,4 +68,4 @@
The return type for <<<getStackTrace()>>> on
{{{../apidocs/org/apache/tapestry/services/ExceptionInfo.html}ExceptionInfo}}
- changes from List\<String\> to List\<StackTraceElement\>.
\ No newline at end of file
+ changed from List\<String\> to List\<StackTraceElement\>.
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/Start.tml Mon Mar 3 08:05:41 2008
@@ -51,6 +51,11 @@
-- using a List for catch-all event context parameters
</li>
+ <li>
+ <a href="datumeditor">Class Transformation Exception Demo</a>
+ -- demo proper reporting of exceptions during class transformation
+ </li>
+
</ul>
</html>
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/IntegrationTests.java Mon Mar 3 08:05:41 2008
@@ -1843,6 +1843,20 @@
"Class org.apache.tapestry.integration.app1.pages.ProtectedFields contains field(s) (_field) that are not private. You should change these fields to private, and add accessor methods if needed.");
}
+
+ /**
+ * TAPESTRY-2078
+ */
+ @Test
+ public void noclassdeffound_exception_is_linked_to_underlying_cause()
+ {
+ start("Class Transformation Exception Demo");
+
+ assertTextPresent(
+ "Class org.apache.tapestry.integration.app1.pages.Datum contains field(s) (_value) that are not private. You should change these fields to private, and add accessor methods if needed.");
+ }
+
+
private void sleep(long timeout)
{
try
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Datum.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Datum.java?rev=633150&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Datum.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/Datum.java Mon Mar 3 08:05:41 2008
@@ -0,0 +1,33 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.app1.pages;
+
+/**
+ * This isn't a page class and doesn't belong here.
+ */
+public class Datum
+{
+ protected int _value;
+
+ public int getValue()
+ {
+ return _value;
+ }
+
+ public void setValue(int value)
+ {
+ _value = value;
+ }
+}
Added: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DatumEditor.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DatumEditor.java?rev=633150&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DatumEditor.java (added)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/app1/pages/DatumEditor.java Mon Mar 3 08:05:41 2008
@@ -0,0 +1,27 @@
+// Copyright 2008 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.integration.app1.pages;
+
+import org.apache.tapestry.annotations.GenerateAccessors;
+import org.apache.tapestry.annotations.Retain;
+
+public class DatumEditor
+{
+ @Retain
+ @GenerateAccessors(write = false)
+ private Datum _datum = new Datum();
+
+
+}
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java?rev=633150&r1=633149&r2=633150&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentInstantiatorSourceImplTest.java Mon Mar 3 08:05:41 2008
@@ -70,7 +70,8 @@
replay();
- ComponentInstantiatorSourceImpl e = new ComponentInstantiatorSourceImpl(_contextLoader, transformer, logger);
+ ComponentInstantiatorSourceImpl e = new ComponentInstantiatorSourceImpl(logger, _contextLoader, transformer,
+ null);
assertEquals(e.inControlledPackage("foo.bar.Baz"), false);
@@ -259,7 +260,7 @@
URL url = _extraClasspath.toURL();
- _extraLoader = new URLClassLoader(new URL[]{url}, _contextLoader);
+ _extraLoader = new URLClassLoader(new URL[] { url }, _contextLoader);
RegistryBuilder builder = new RegistryBuilder(_extraLoader);
builder.add(TapestryModule.class);