cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Gentry <mgen...@masslight.net>
Subject Re: Can't instantiate class but it exists
Date Thu, 20 Jun 2013 16:43:31 GMT
Hi Andrew,

I'm not sure how you are running (Maven, Eclipse, etc, etc), but I would
guess PasswordReset exists at compile-time, but isn't available at
run-time, therefore it can't be found on the CLASSPATH while you are
running (in a .jar or .class).

mrg


On Thu, Jun 20, 2013 at 12:14 PM, Andrew Willerding <
awillerding@itsurcom.com> wrote:

> I'm going nuts over trying to figure out what I'm doing wrong.  I am
> getting the error
>
> java.lang.**ClassNotFoundException: com.callistacti.callwatch.**
> database.PasswordReset
>
> (see full log trace below) when I'm simply trying to retrieve the
> associated PasswordReset object - which I don't always expect to exist.
>
> Here's the offending line of code:
>
>             PasswordReset pr = user.getPasswordReset();
>
> from
>
>         try {
>             //Find the User
>             User user = User.findUser(username);
>             if (user == null){
>                 return token;
>             }
>             PasswordReset pr = user.getPasswordReset();
>             try {
>                 if (pr == null ) {
>                     pr = newPasswordReset(username);
>                 } else {
>                     if (pr.getExpireDT().before(**DateTime.now().toDate()))
> {
>                         DataContext dc = DataContext.createDataContext(**
> );
>                         token = Password.getEncryptPW(username +
> DateTime.now().toString());
>                         pr.setToken(token);
>                         dc.commitChanges();
>                     } else {
>                         token = pr.getToken();
>                     }
>                 }
>             } catch (CayenneRuntimeException e) {
> CCommon.getInstance().logInfo(**"PasswordReset::**getPasswordResetToken::"
> + e.getMessage(),e);
>             }
>         } finally {
> CCommon.getInstance().logInfo(**"PasswordReset::**getPasswordResetToken::*
> *Complete for " + username + "Result=" + token);
>         }
>
>
>
> I don't understand why is the classnotfound happening?  Both the source
> code and the class is generated as far as I can tell.  Are some of my
> dependencies out-of-whack?
>
> Here is the extraction from my map.xml file
>
>        <db-entity name="Password" catalog="BlueCrane">
>         <db-attribute name="EmailPassword" type="VARCHAR" length="32"/>
>         <db-attribute name="Password" type="VARCHAR" isMandatory="true"
> length="128"/>
>         <db-attribute name="UserID" type="INTEGER" isMandatory="true"
> length="10"/>
>         <db-attribute name="password_id" type="INTEGER"
> isPrimaryKey="true" isMandatory="true" length="10"/>
>         <db-attribute name="salt" type="VARBINARY" isMandatory="true"
> length="8"/>
>     </db-entity>
>     <db-entity name="PasswordReset" catalog="BlueCrane">
>         <db-attribute name="UserID" type="INTEGER" isMandatory="true"/>
>         <db-attribute name="expireDT" type="TIMESTAMP" isMandatory="true"/>
>         <db-attribute name="passwordreset_id" type="INTEGER"
> isPrimaryKey="true" isMandatory="true"/>
>         <db-attribute name="token" type="VARCHAR" isMandatory="true"
> length="128"/>
>     </db-entity>
> <db-entity name="User" catalog="BlueCrane">
>         <db-attribute name="AccessLevel" type="SMALLINT"
> isMandatory="true" length="5"/>
>         <db-attribute name="ExpireDate" type="DATE"/>
>         <db-attribute name="Status" type="SMALLINT" isMandatory="true"
> length="5"/>
>         <db-attribute name="company_id" type="INTEGER" isMandatory="true"
> length="10"/>
>         <db-attribute name="contact_id" type="INTEGER" isMandatory="true"
> length="10"/>
>         <db-attribute name="user_id" type="INTEGER" isPrimaryKey="true"
> isMandatory="true"/>
>         <db-attribute name="username" type="VARCHAR" length="128"/>
>     </db-entity>
>
>     <obj-entity name="Password" className="com.callistacti.**callwatch.database.Password"
> dbEntityName="Password">
>         <obj-attribute name="emailPassword" type="java.lang.String"
> db-attribute-path="**EmailPassword"/>
>         <obj-attribute name="id" type="java.lang.Integer"
> db-attribute-path="password_**id"/>
>         <obj-attribute name="password" type="java.lang.String"
> db-attribute-path="Password"/>
>         <obj-attribute name="salt" type="byte[]" db-attribute-path="salt"/>
>     </obj-entity>
>     <obj-entity name="PasswordReset" className="com.callistacti.**
> callwatch.database.**PasswordReset" dbEntityName="PasswordReset">
>         <obj-attribute name="expireDT" type="java.util.Date"
> db-attribute-path="expireDT"/>
>         <obj-attribute name="token" type="java.lang.String"
> db-attribute-path="token"/>
>     </obj-entity>
>     <obj-entity name="User" className="com.callistacti.**callwatch.database.User"
> dbEntityName="User">
>         <obj-attribute name="accessLevel" type="java.lang.Short"
> db-attribute-path="**AccessLevel"/>
>         <obj-attribute name="expireDate" type="java.util.Date"
> db-attribute-path="ExpireDate"**/>
>         <obj-attribute name="status" type="java.lang.Short"
> db-attribute-path="Status"/>
>         <obj-attribute name="userID" type="java.lang.Integer"
> db-attribute-path="user_id"/>
>         <obj-attribute name="username" type="java.lang.String"
> db-attribute-path="username"/>
>         <pre-persist method-name="onPrePersist"/>
>     </obj-entity>
>
>     <db-relationship name="User" source="Password" target="User"
> toMany="false">
>         <db-attribute-pair source="UserID" target="user_id"/>
>     </db-relationship>
>     <db-relationship name="User" source="PasswordReset" target="User"
> toMany="false">
>         <db-attribute-pair source="UserID" target="user_id"/>
>     </db-relationship>
> <db-relationship name="Password" source="User" target="Password"
> toMany="false">
>         <db-attribute-pair source="user_id" target="UserID"/>
>     </db-relationship>
>     <db-relationship name="PasswordReset" source="User"
> target="PasswordReset" toMany="false">
>         <db-attribute-pair source="user_id" target="UserID"/>
>     </db-relationship>
>
>     <obj-relationship name="user" source="Password" target="User"
> deleteRule="Nullify" db-relationship-path="User"/>
>     <obj-relationship name="user" source="PasswordReset" target="User"
> deleteRule="Nullify" db-relationship-path="User"/>
>
>     <obj-relationship name="password" source="User" target="Password"
> deleteRule="Nullify" db-relationship-path="**Password"/>
>     <obj-relationship name="passwordReset" source="User"
> target="PasswordReset" deleteRule="Nullify" db-relationship-path="**
> PasswordReset"/>
>
> And here is the log trace:
>
> 2013-06-20 12:06:37,025 [http-bio-8080-exec-16] INFO  CallWatch -
> 0F1E2D->PasswordReset::**getPasswordResetToken::Start for callista
> 2013-06-20 12:06:37,041 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - --- will run 1 query.
> 2013-06-20 12:06:37,043 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - --- transaction started.
> 2013-06-20 12:06:37,045 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - SELECT t0.user_id, t0.Status,
> t0.AccessLevel, t0.contact_id, t0.username, t0.ExpireDate, t0.company_id
> FROM User t0 WHERE t0.username = ? [bind: 1->username:'callista']
> 2013-06-20 12:06:37,047 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - === returned 1 row. - took 2 ms.
> 2013-06-20 12:06:37,049 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - +++ transaction committed.
> 2013-06-20 12:06:37,052 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - --- will run 1 query.
> 2013-06-20 12:06:37,053 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - --- transaction started.
> 2013-06-20 12:06:37,055 [http-bio-8080-exec-16] INFO
> org.apache.cayenne.access.**QueryLogger - *** error.
> 2013-06-20 12:06:37,087 [http-bio-8080-exec-16] INFO  CallWatch -
> 0F1E2D->PasswordReset::**getPasswordResetToken::**Complete for
> callistaResult=null
> Jun 20, 2013 12:06:37 PM com.vaadin.server.**DefaultErrorHandler doDefault
> SEVERE:
> Caused by: org.apache.cayenne.**CayenneRuntimeException: [v.3.0.2 Jun 11
> 2011 09:26:09] Query exception.
>     at org.apache.cayenne.access.**DataDomainQueryAction.**
> nextQueryException(**DataDomainQueryAction.java:**549)
>     at org.apache.cayenne.access.**DataNode.performQueries(**
> DataNode.java:276)
>     at org.apache.cayenne.access.**DataDomainQueryAction.**runQuery(**
> DataDomainQueryAction.java:**422)
>     at org.apache.cayenne.access.**DataDomainQueryAction.access$**
> 000(DataDomainQueryAction.**java:69)
>     at org.apache.cayenne.access.**DataDomainQueryAction$2.**transform(**
> DataDomainQueryAction.java:**395)
>     at org.apache.cayenne.access.**DataDomain.runInTransaction(**
> DataDomain.java:850)
>     at org.apache.cayenne.access.**DataDomainQueryAction.**
> runQueryInTransaction(**DataDomainQueryAction.java:**392)
>     at org.apache.cayenne.access.**DataDomainQueryAction.execute(**
> DataDomainQueryAction.java:**121)
>     at org.apache.cayenne.access.**DataDomain.onQuery(DataDomain.**
> java:743)
>     at org.apache.cayenne.util.**ObjectContextQueryAction.**runQuery(**
> ObjectContextQueryAction.java:**334)
>     at org.apache.cayenne.util.**ObjectContextQueryAction.**
> executePostCache(**ObjectContextQueryAction.java:**104)
>     at org.apache.cayenne.util.**ObjectContextQueryAction.**execute(**
> ObjectContextQueryAction.java:**91)
>     at org.apache.cayenne.access.**DataContext.onQuery(**
> DataContext.java:1293)
>     at org.apache.cayenne.access.**DataContext.performQuery(**
> DataContext.java:1282)
>     at org.apache.cayenne.access.**ToOneFault.doResolveFault(**
> ToOneFault.java:81)
>     at org.apache.cayenne.access.**ToOneFault.resolveFault(**
> ToOneFault.java:54)
>     at org.apache.cayenne.**CayenneDataObject.**readProperty(**
> CayenneDataObject.java:225)
>     at com.callistacti.callwatch.**database.auto._User.**
> getPasswordReset(_User.java:**153)
>     at com.callistacti.callwatch.**database.PasswordReset.**
> getPasswordResetToken(**PasswordReset.java:30)
>     at com.callistacti.callwatch.**Windows.WindowLogin$2.**
> buttonClick(WindowLogin.java:**135)
>     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)
>     ... 34 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.util.Util.**getJavaClass(Util.java:588)
>     at org.apache.cayenne.map.**ObjEntity.getJavaClass(**
> ObjEntity.java:286)
>     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:59)
>     at org.apache.cayenne.reflect.**LazyClassDescriptorDecorator.**
> getEntity(**LazyClassDescriptorDecorator.**java:83)
>     at org.apache.cayenne.access.**trans.SelectTranslator.**
> appendQueryColumns(**SelectTranslator.java:327)
>     at org.apache.cayenne.access.**trans.SelectTranslator.**
> buildResultColumns(**SelectTranslator.java:290)
>     at org.apache.cayenne.access.**trans.SelectTranslator.**
> createSqlString(**SelectTranslator.java:126)
>     at org.apache.cayenne.access.**trans.QueryAssembler.**createStatement(
> **QueryAssembler.java:194)
>     at org.apache.cayenne.access.**jdbc.SelectAction.**
> performAction(SelectAction.**java:70)
>     at org.apache.cayenne.access.**DataNodeQueryAction.runQuery(**
> DataNodeQueryAction.java:87)
>     at org.apache.cayenne.access.**DataNode.performQueries(**
> DataNode.java:269)
>     ... 57 more
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message