Here is the code for DefaultAdhocObjectFactory that is the cluprit:
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader == null) {
classLoader = DefaultAdhocObjectFactory.class.getClassLoader();
}
try {
// fails here
return Class.forName(className, true, classLoader);
}
Looks like the PasswordReset.class is coming from some unexpected ClassLoader.
I don't have firsthand experience with Atmosphere deployments (on Tomcat or
otherwise), so not sure what happens there ClassLoader-wise. So a random
question - do you keep Cayenne jar in the same war as your PasswordReset.class?
Or if you are not using a .war, how is your deployed app structured?
Andrus
On Jul 31, 2013, at 5:58 PM, Andrew Willerding <[email protected]> wrote:
> Hi Markus,
>
> I have recompiled so many times I've lost count ;-) The way I figure it, the
> PasswordReset.class file must be in my classpath or else the code couldn't be
> executed in the first place and it is clearly being executed in order to
> generate the error. It's just that Cayenne can't instantiate an object
> because it can't find the class. Could something obsure it somehow?
>
> Andrew
>
>
>
> On 07/31/2013 10:52 AM, Markus Reich wrote:
>> Does the PasswordReset.class File really exists in your classpath? Maybe
>> try to recompile?
>>
>> Markus
>>
>>
>> 2013/7/31 Andrew Willerding <[email protected]>
>>
>>> I'm still having problems with this one Netbeans 7.3.1 project ( jdk
>>> 1.7.0.17 with Tomcat 7.0.27) involving Vaadin and Cayenne. I have now
>>> upgraded Cayenne to 3.1B2 and made all the project modifications I needed
>>> to in order to use Cayenne 3.1 (thanks Andrus!). I'm hoping the error
>>> message is more meaningful to someone on this list. I don't understand how
>>> the error message indicates it can't find the class PasswordReset and yet
>>> the code is being executed from within PasswordReset. To me it looks like
>>> it can't load the class because of some security restriction but what is
>>> creating the security restriction?
>>>
>>> Any help or guidance would be greatly appreciated.
>>>
>>> Here is the offending code:
>>>
>>> public class PasswordReset extends _PasswordReset {
>>> private static final long serialVersionUID = 5548297136969252200L;
>>>
>>>
>>> private static PasswordReset newPasswordReset(User user) {
>>> ObjectContext oc = MyApplication.**getObjectContext();
>>> PasswordReset pr = null;
>>> String token = null;
>>>
>>> System.out.println("oc=" + oc);
>>>
>>> pr = oc.newObject(PasswordReset.**class);
>>> pr.setExpireDT(DateTime.now().**plusMinutes(15).toDate());
>>> token = Password.getEncryptPW(user.**getUsername() +
>>> DateTime.now().toString(), Password.generateNewSalt());
>>> pr.setToken(token);
>>> // pr.setUserId(user.getUser_id()**);
>>> user.setToPasswordReset(pr);
>>> oc.commitChanges();
>>> return pr;
>>>
>>> }
>>> }
>>>
>>> Here is the output
>>>
>>>
>>> oc=org.apache.cayenne.access.**DataContext@59d8afee
>>>
>>> org.apache.cayenne.**CayenneRuntimeException: [v.3.1B2 Feb 05 2013 20:43:40]
>>> Error instantiating object.
>>> at org.apache.cayenne.access.**DataContext.newObject(**
>>> DataContext.java:554)
>>> at org.apache.cayenne.access.**DataContext.newObject(**
>>> DataContext.java:531)
>>> at com.callistacti.callwatch.**database.PasswordReset.**
>>> newPasswordReset(**PasswordReset.java:76)
>>> at com.callistacti.callwatch.**database.PasswordReset.**
>>> getPasswordResetToken(**PasswordReset.java:44)
>>> at com.callistacti.callwatch.**Windows.WindowLogin$3.**
>>> buttonClick(WindowLogin.java:**174)
>>> at sun.reflect.**NativeMethodAccessorImpl.**invoke0(Native Method)
>>> at sun.reflect.**NativeMethodAccessorImpl.**invoke(**
>>> NativeMethodAccessorImpl.java:**57)
>>> at sun.reflect.**DelegatingMethodAccessorImpl.**invoke(**
>>> DelegatingMethodAccessorImpl.**java:43)
>>> at java.lang.reflect.Method.**invoke(Method.java:601)
>>> at com.vaadin.event.**ListenerMethod.receiveEvent(**
>>> ListenerMethod.java:508)
>>> at com.vaadin.event.EventRouter.**fireEvent(EventRouter.java:**167)
>>> at com.vaadin.server.**AbstractClientConnector.**fireEvent(**
>>> AbstractClientConnector.java:**968)
>>> at com.vaadin.ui.Button.**fireClick(Button.java:368)
>>> at com.vaadin.ui.Button$1.click(**Button.java:57)
>>> at sun.reflect.**NativeMethodAccessorImpl.**invoke0(Native Method)
>>> at sun.reflect.**NativeMethodAccessorImpl.**invoke(**
>>> NativeMethodAccessorImpl.java:**57)
>>> at sun.reflect.**DelegatingMethodAccessorImpl.**invoke(**
>>> DelegatingMethodAccessorImpl.**java:43)
>>> at java.lang.reflect.Method.**invoke(Method.java:601)
>>> at com.vaadin.server.**ServerRpcManager.**applyInvocation(**
>>> ServerRpcManager.java:168)
>>> at com.vaadin.server.**ServerRpcManager.**applyInvocation(**
>>> ServerRpcManager.java:118)
>>> at com.vaadin.server.**communication.**ServerRpcHandler.handleBurst(**
>>> ServerRpcHandler.java:214)
>>> at com.vaadin.server.**communication.**ServerRpcHandler.handleRpc(**
>>> ServerRpcHandler.java:111)
>>> at com.vaadin.server.**communication.PushHandler$2.**
>>> run(PushHandler.java:158)
>>> at com.vaadin.server.**communication.PushHandler.**
>>> callWithUi(PushHandler.java:**289)
>>> at com.vaadin.server.**communication.PushHandler.**
>>> onRequest(PushHandler.java:**308)
>>> at org.atmosphere.cpr.**AsynchronousProcessor.action(**
>>> AsynchronousProcessor.java:**259)
>>> at org.atmosphere.cpr.**AsynchronousProcessor.**suspended(**
>>> AsynchronousProcessor.java:**166)
>>> at org.atmosphere.container.**TomcatWebSocketUtil.doService(**
>>> TomcatWebSocketUtil.java:137)
>>> at org.atmosphere.container.**Tomcat7AsyncSupportWithWebSock**
>>> et.service(**Tomcat7AsyncSupportWithWebSock**et.java:59)
>>> at org.atmosphere.cpr.**AtmosphereFramework.**doCometSupport(**
>>> AtmosphereFramework.java:1448)
>>> at org.atmosphere.websocket.**DefaultWebSocketProcessor.**dispatch(**
>>> DefaultWebSocketProcessor.**java:219)
>>> at org.atmosphere.websocket.**DefaultWebSocketProcessor$2.**
>>> run(DefaultWebSocketProcessor.**java:183)
>>> at org.atmosphere.util.**VoidExecutorService.execute(**
>>> VoidExecutorService.java:101)
>>> at org.atmosphere.websocket.**DefaultWebSocketProcessor.**dispatch(**
>>> DefaultWebSocketProcessor.**java:178)
>>> at org.atmosphere.websocket.**DefaultWebSocketProcessor.**
>>> invokeWebSocketProtocol(**DefaultWebSocketProcessor.**java:167)
>>> at org.atmosphere.container.**TomcatWebSocketHandler.**onTextMessage(*
>>> *TomcatWebSocketHandler.java:**92)
>>> at org.apache.catalina.websocket.**MessageInbound.onTextData(**
>>> MessageInbound.java:74)
>>> at org.apache.catalina.websocket.**StreamInbound.onData(**
>>> StreamInbound.java:129)
>>> at org.apache.coyote.http11.**upgrade.UpgradeProcessor.**
>>> upgradeDispatch(**UpgradeProcessor.java:83)
>>> at org.apache.coyote.**AbstractProtocol$**AbstractConnectionHandler.**
>>> process(AbstractProtocol.java:**563)
>>> at org.apache.tomcat.util.net.**JIoEndpoint$SocketProcessor.**
>>> run(JIoEndpoint.java:307)
>>> at java.util.concurrent.**ThreadPoolExecutor.runWorker(**
>>> ThreadPoolExecutor.java:1145)
>>> at java.util.concurrent.**ThreadPoolExecutor$Worker.run(**
>>> ThreadPoolExecutor.java:615)
>>> at java.lang.Thread.run(Thread.**java:722)
>>> Caused by: org.apache.cayenne.**CayenneRuntimeException: [v.3.1B2 Feb 05
>>> 2013 20:43:40] Failed to load class
>>> com.callistacti.callwatch.**database.PasswordReset:
>>> com.callistacti.callwatch.**database.PasswordReset
>>> at org.apache.cayenne.map.**ObjEntity.getJavaClass(**
>>> ObjEntity.java:302)
>>> at org.apache.cayenne.reflect.**PersistentDescriptorFactory.**
>>> getDescriptor(**PersistentDescriptorFactory.**java:57)
>>> at org.apache.cayenne.reflect.**ClassDescriptorMap.**createDescriptor(
>>> **ClassDescriptorMap.java:128)
>>> at org.apache.cayenne.reflect.**LazyClassDescriptorDecorator.**
>>> checkDescriptorInitialized(**LazyClassDescriptorDecorator.**java:58)
>>> at org.apache.cayenne.reflect.**LazyClassDescriptorDecorator.**
>>> createObject(**LazyClassDescriptorDecorator.**java:72)
>>> at org.apache.cayenne.access.**DataContext.newObject(**
>>> DataContext.java:551)
>>> ... 43 more
>>> Caused by: java.lang.**ClassNotFoundException: com.callistacti.callwatch.*
>>> *database.PasswordReset
>>> at java.net.URLClassLoader$1.run(**URLClassLoader.java:366)
>>> at java.net.URLClassLoader$1.run(**URLClassLoader.java:355)
>>> at java.security.**AccessController.doPrivileged(**Native Method)
>>> at java.net.URLClassLoader.**findClass(URLClassLoader.java:**354)
>>> at java.lang.ClassLoader.**loadClass(ClassLoader.java:**423)
>>> at java.lang.ClassLoader.**loadClass(ClassLoader.java:**356)
>>> at java.lang.Class.forName0(**Native Method)
>>> at java.lang.Class.forName(Class.**java:266)
>>> at org.apache.cayenne.di.spi.**DefaultAdhocObjectFactory.**
>>> getJavaClass(**DefaultAdhocObjectFactory.**java:102)
>>> at org.apache.cayenne.util.Util.**getJavaClass(Util.java:658)
>>> at org.apache.cayenne.map.**ObjEntity.getJavaClass(**
>>> ObjEntity.java:299)
>>>
>>
>>
>
>