Context initialization failed

72 views
Skip to first unread message

Marks Andre

unread,
Aug 21, 2009, 2:24:50 PM8/21/09
to webical-developers
Good day all,

I'm in the process of integrating Webical in a project and among
making it fully compatible with oracle10g there will be certanly
specific changes and modifications. I hope to publish these ventures
as it further unfolds but I seem to be having a problem initializing
the development environment.

The following exception occurs when starting the development
environment according to the developers guide:

ERROR ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'databaseBootStrapDao' defined in
ServletContext resource [/WEB-INF/applicationContext-bootstrap.xml]:
Invocation of init method failed; nested exception is
org.hibernate.AssertionFailure: null id in
org.webical.ApplicationSettings entry (don't flush the Session after
an exception occurs)
Caused by:
org.hibernate.AssertionFailure: null id in
org.webical.ApplicationSettings entry (don't flush the Session after
an exception occurs)
at org.hibernate.event.def.DefaultFlushEntityEventListener.checkId
(DefaultFlushEntityEventListener.java:48)

I'm using the Eclipse setup as detailed in the
DevelopmentEnvironmentSetup Guide.

Thanks,

Ivo van Dongen

unread,
Aug 24, 2009, 6:11:36 AM8/24/09
to webical-d...@googlegroups.com
Hi,

Good to hear that the project can be of use to you. If you have
something that can be of use to more users it would certainly be
appreciated.

Concerning your troubles in setting up a developing environment. I'm
sorry to say that I don't have any spare time atm to help you out and
won't for the coming month. I'm still planning to renew the development
efforts on webical (hopefully supported by some more interested
developers), but right now I have other priorities.
What I can tell you is that the the application context file concerned
defines a bootstrap bean that tries to insert some data in the database
on startup so that the application works in a basic form without further
configuration. The error you get is not really helpful, but it can
indicate any number of issues. I would advise you to check the database
connection, are you sure it is writable and hibernate creates the
correct tables for you?

If you have any progress or other issues, just post to this list and
I'll try to help you along the best I can.

Regards,
Ivo

Marks Andre

unread,
Aug 24, 2009, 10:49:03 AM8/24/09
to webical-developers
Good day,

Thanks for your response. As you pointed out I checked the database
connection and the SCHEMA name which the database was created with was
incorrect. This error would also show up if the MySQL service was down
for some reason. I was able to get the environment up and running. The
main objective as of right now is implementing interoperability with
Oracle with the project functioning as is right now. At the very least
I will come up for a guide of the process depending of how complicated
the roadblocks I find are. I hope to continue posting more information
as it unfolds.

Regards,

Marks Andre

unread,
Aug 24, 2009, 1:00:27 PM8/24/09
to webical-developers
First interesting roadblock. I'm trying to configure the jetty
instance in the development environment to use the Oracle jdbc driver
to connect to the Oracle database and use it as datasource. The
information I gathered points out that the ojdbc14.jar has the
necesary classes for this to work. So I configure the jetty.xml as
follows:
<New id="calendarDataBase"
class="org.mortbay.jetty.plus.naming.Resource">
<Arg>jdbc/SAICWQC</Arg>
<New class="oracle.jdbc.pool.OracleDataSource">
<Set name="user">dbUsr</Set>
<Set name="password">dbPass</Set>
<Set name="URL">jdbc:oracle:thin:@myhostname.com:
1521:INSTANCE</Set>
</New>
</Arg>
</New>

While starting the jetty server I get the following exception:

2009-08-24 12:25:30,394 ERROR StartWebApplication -
java.lang.NoSuchMethodException: class
oracle.jdbc.pool.OracleDataSource.setUrl(class java.lang.String)
java.lang.NoSuchMethodException: class
oracle.jdbc.pool.OracleDataSource.setUrl(class java.lang.String)
at org.mortbay.xml.XmlConfiguration.set(XmlConfiguration.java:411)

Interestingly, the setUrl you can clearly see that is implemented in
the class in question. So far I'm unable to figure out why is not able
to see the method.

I'll have more as it continues.

Ivo van Dongen

unread,
Aug 25, 2009, 2:34:02 AM8/25/09
to webical-d...@googlegroups.com
Hi,

The Wierd thing is that the class seems to hace a setURL method, but no setUrl as seen in the stackstrace. Somehow jetty is calling the setter in the wrong case.

Also are you sure you are using the correct datasource class? I found this example:

<New id="DSTest" class="org.mortbay.jetty.plus.naming.Resource">
    <Arg></Arg>
    <Arg>jdbc/DSTest</Arg>
    <Arg>
     <New class="oracle.jdbc.pool.OracleConnectionPoolDataSource">
                 <Set name="URL">jdbc:oracle:thin:@localhost:1521:orcl</Set>
                 <Set name="User">user</Set>
                 <Set name="Password">pass</Set>

     </New>
    </Arg>
</New>

Regards,
Ivo

Marks Andre

unread,
Aug 26, 2009, 11:17:21 AM8/26/09
to webical-developers
Hello,

I tried many examples including the one you mention but keeps dumping
the NoSuchMethod error. Of all the classes that I inspected,
oracle.jdbc.pool.OracleDataSource is the only one that implements this
method. While tracing the error I can see in the source for the
XmlConfigurator class that it fails to find the set method of the
object. It tries various ways of finding it but fails in each of them.
I will have to trace them and maybe I'll be able to find the specific
point of failure.

While in that roadblock I decided to let it cool off and try to modify
the configuration files in the release version of Webical to se if I
can get it to just run as is and connect to Oracle. Interestingly,
when Tomcats starts the application context, webical audits the
schema. We ran in to an Oracle limitation of 30 characters per table
name and because of it we modified the database scripts (perhaps I
could post them somewhere) to cope with oracle's expectations. Tables
such as "application_settings_plugin_paths" had to be changed to
"appl_settings_plugin_paths" and several other tables that used oracle
reserved table names had to be renamed. We also created triggers for
the autoincrement functions and such. Then while the context starts
the audit, it fails to start due to not finding the
application_settings_plugin_paths table.

I conclude that to make further progress I need to get the dev
environment up and running. I may not be able to run the test
environment but maybe with the ability to make changes to the
hibernate various xmls and compiling the application I will be able to
continue.

I may need some assistance in how to go about compiling a version that
I can deploy in a local Tomcat with the changes I make. I have all the
tools set up (Maven, Eclipse, Databases etc) but I'm not too
familiarized with Maven yet. I'm thankful if anyone can spare a few
minutes of their time to shine a light on this.

Ivo van Dongen

unread,
Aug 26, 2009, 1:27:24 PM8/26/09
to webical-d...@googlegroups.com
Hi,

Thanks for the detailed description. I only ogt a minute as I was just about to go out. But compiling a version to run on a local tomcat should be as easy as invoking maven with #> mvn package on the parent level. It will create a war file for you in the webical-war module under the target directory.

Concerning the changes you make. You can send them over so we can evaluate if it are changes that others can benefit from as well. If that's the case I'll add them to the code base. Perhaps you can create a patch with all the needed changes?

Good luck,
Ivo
--
Ivo van Dongen
Func. Internet Integration
W http://www.func.nl
T +31 20 4230000
F +31 20 4223500

Marks Andre

unread,
Aug 27, 2009, 2:25:27 PM8/27/09
to webical-developers
Hello,

Thanks for the tip. It seems what you mention is the right track but I
face a problem when the tests are run. Since I'm making changes to the
DAO when the post compilation automatic tests are run they will fail
(due to the fact that I'm merely just starting to test this
integration) hence the war file does not get created. I think that I
merely need to acomplish right now is a repackage of the webical-core
jar with the changes I make to hibernate and the java classes. I guess
I could manually edit the files in the jar archive and recompile the
classes individually but as this may grow I may need to streamline
development early to avoid any scaling issues. Is there a way to
disable the tests and just do the repack of the recompiled changes?

On Aug 26, 1:27 pm, Ivo van Dongen <ivovandon...@gmail.com> wrote:
> Hi,
>
> > > >           <Set name="URL">jdbc:oracle:thin:@myhostname.com<jdbc%3Aoracle%3Athin...@myhostname.com>
> > :
> Whttp://www.func.nl

Ivo van Dongen

unread,
Aug 27, 2009, 4:22:34 PM8/27/09
to webical-d...@googlegroups.com
Hi,

Skipping the tests is quite easy actually. Just run maven with an extra option like so: #> mvn -Dmaven.test.skip=true package.

Ivo

Marks Andre

unread,
Sep 1, 2009, 10:27:07 AM9/1/09
to webical-developers
Hello,

Thanks for the assistance. I managed to package the war and do
continuous testing. I believe its progressing quite nicely. At first I
was a little confused by the command typos so for future reference to
anyone reading, the command I used was:

mvn -D maven.test.skip=true package

Now, I've been getting a grasp of hibernate and learning a lot about
the configurations and I came across an interesting hurdle that I
would like to share. Since I wasn't able to get the development mode
running with the Oracle jdbc driver I've been chaging the application
little by little and deploying on a local tomcat and pointing to an
Oracle development database. Since the Webical project has various
configuration files depending for if you're testing or development or
production I would like to have a better understanding of how should I
configure Webical for the different scenarios (eg. which files to
remove or change and maybe the different maven tasks available). The
thing is that since I'm sort of treating development testing as
production I came across a hibernate configuration that drops certain
tables every time the context starts (<prop
key="hibernate.hbm2ddl.auto">create</prop>). I found the solution to
this which was change the property to "update" but because my
development methodology is different perhaps I would need a production-
like configuration. I know that my development methodology is not what
Webical intends but changing the database type doesn't seem to be as
seamless.

Perhaps someone could point me in the right direction as to what I
would need to change depending on the scenarios (test, QA, Dev, Prod)
and maybe what maven tasks to run etc. Thanks for any help and
invested time.

On Aug 27, 4:22 pm, Ivo van Dongen <ivovandon...@gmail.com> wrote:
> Hi,
>
> Skipping the tests is quite easy actually. Just run maven with an extra
> option like so: #> mvn -Dmaven/.test.skip///=true package.
> ...
>
> read more »

Ivo van Dongen

unread,
Sep 1, 2009, 10:56:07 AM9/1/09
to webical-d...@googlegroups.com
Hi,

Good to hear you're making progress. Hope you'll get there.


> At first I
> was a little confused by the command typos so for future reference to
> anyone reading, the command I used was:
>
> mvn -D maven.test.skip=true package
>

Strange. They weren't really typos. Don't know what went wrong there.
Thanks for the correction.


> I know that my development methodology is not what
> Webical intends but changing the database type doesn't seem to be as
> seamless.
>

I thought it would be less involved indeed. I've changed around the
settings a bit in the past (postgress, derby and hsqldb) and that went
without any effort beside changing the configuration a bit. I didn't
think that oracle had so much quirks. But I haven't really made use of
it since version 8 or so.


> Perhaps someone could point me in the right direction as to what I
> would need to change depending on the scenarios (test, QA, Dev, Prod)
> and maybe what maven tasks to run etc. Thanks for any help and
> invested time.
>

Well, there is a standard way of doing this indeed. I suggest you read
up a bit on maven as the problems you are encountering so far are really
basic maven stuff. But on the other hand, you can always ask here, it's
no problem to help out.
They way we go about managing the different configurations is through
the use of maven profiles. The configurations can be found under /etc.
These are copied over the exploded war before packaging depending on
which profile is selected (default none I think). Activation of a
profile is done through the use of an extra parameter: -Denv=... You can
find out what to use by checking out the profiles section of the pom.xml
file.

If I need to be more specific, just let me know.

Regards,
Ivo van Dongen

Marks Andre

unread,
Sep 2, 2009, 10:37:35 AM9/2/09
to webical-developers
Hello,

I believe I have managed to configure the application to successfully
validate start-up of the context with the Oracle database. As you
mention Oracle has too many quirks to what otherwise should have been
a transparent process. I have encountered another roadblock in which
the application presents the following exception when trying to access
the login page:

Unexpected RuntimeException
Root cause:org.webical.web.app.WebicalWebAplicationException: Could
not retrieve application settings for user: jag at
org.webical.web.app.WebicalSession.getUserSettings(WebicalSession.java:
158) at org.webical.web.app.WebicalSession.getUserSettings
(WebicalSession.java:232) at
org.webical.web.component.calendar.CalendarPanel.<init>
(CalendarPanel.java:142) at org.webical.web.pages.BasePage$8.<init>
(BasePage.java:343)

...

I believe this is due to the fact that the application is still
compiling in development mode (hence is performing the bootstrap of
the development configuration). I read the pom.xml profiles and tried
to utilize the -Denv=build switch but it then will complain that the
"maven.test.skip=true" switch is not a valid profile or task. I wonder
why if I just specify the -D switch it will let me disable the tests
just fine but with the -Devn=build switch it will not.

Marks Andre

unread,
Sep 4, 2009, 5:50:47 PM9/4/09
to webical-developers
Well somehow I managed to mannualy set the correct configurations and
I'm able to attempt loging in to the application. I have the database
setup with the same schema model as the mysql example (with its oracle
variations). I'm trying to log in as the user webical but the login
attempt fails and redirects me back to the login page. What I hope to
find is where to look in terms of trying to debbug a loging attempt. I
know that it makes a http post to j_security_check but i havent able
to find my way from there. Thanks for any help in the matter.

Ivo van Dongen

unread,
Sep 5, 2009, 3:25:11 AM9/5/09
to webical-d...@googlegroups.com
 Hi,

Congratulations, seems like you're getting there. Debugging the log-in procedure is quite a pain I am sad to say. We choose to leave the login mechanism external, so it is managed by the container and can be easily swapped out. For tomcat it is managed in the context.xml file (either in src/main/webapp/META-INF or in the profile you choose to build the war). It looks like this:

<Context path="/webical-refactoring" docBase="webical" debug="5" reloadable="true" crossContext="true">

        <!-- The database resource for hibernate -->
        <Resource 
                name="jdbc/calendarDataBase" 
                auth="Container" 
                type="javax.sql.DataSource" 
                factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" 
                username="webical" 
                password="webical" 
                driverClassName="com.mysql.jdbc.Driver" 
                url="jdbc:mysql://localhost:3306/webical?autoReconnect=true" />
        
</Context>
You need to substitute the driver, url, username and password with your own values depending on your setup. Now for debugging it you have to place debug="99" either on the context or resource element, forgot witch one. Then the logging to catalina.out will be more verbose.

Good luck again,
Ivo

Marks Andre

unread,
Sep 9, 2009, 12:39:14 PM9/9/09
to webical-developers
Hello,

Thanks for the tip. I managed to debug the login by activating the
debug flag you mention. Indeed is quite a pain but the fact that it
delegates authentication to Tomcat worked out perfect for my purpose.
Interestingly, I had to explicitly configure the realm in the
server.xml file for the Tomcat configuration (this is unfortunate as
is preferable that the application can be deployed without modifying
the server configuration). For some reason the aplication server is
ignoring the context.xml realm on META-INF.

Now, it seems that the application its having problems initializing. I
manage to login to the aplication with the default webical user. It
will ofcourse, take me to the administrator page. I then have to login
with un: admin, pw: admin (I dont know why, I merely guessed it). I
then go on to configure the application wide settings.When I click the
save button, the application tries to take me to the user calendar
(Acording to the URL in the browser http://localhost:8080/webical/app/calendar)
and displays the friendly error page with the following information:

The application returned the following error message:

Could not retrieve application settings for user: webical

Also I get the following stack trace:

org.webical.web.app.WebicalWebAplicationException: Could not retrieve
application settings for user: webical
at org.webical.web.app.WebicalSession.getUserSettings
(WebicalSession.java:158)
at org.webical.web.app.WebicalSession.getUserSettings
(WebicalSession.java:232)
at
org.webical.web.component.settings.UserSettingsPanel.setupCommonComponents
(UserSettingsPanel.java:73)
at org.webical.web.component.AbstractBasePanel.setupComponents
(AbstractBasePanel.java:113)
at org.webical.web.component.AbstractBasePanel.onBeforeRender
(AbstractBasePanel.java:223)
.
.
.

I have to restart Tomcat to kill the session and be able to try to
login again, but the same cycle occurs. Upon further investigation I
get the following entry in the log:

2009-09-09 10:57:04,927 ERROR SettingsDaoHibernateImpl - Could not
retreive settings for user: org.webical.User@10651eb
org.hibernate.QueryException: could not resolve property: user of:
org.webical.UserSettings
at
org.hibernate.persister.entity.AbstractPropertyMapping.throwPropertyException
(AbstractPropertyMapping.java:43)
at org.hibernate.persister.entity.AbstractPropertyMapping.toType
(AbstractPropertyMapping.java:37)...

This is clearly due to the fact that somewhere in the code the
application is trying to make a reference to a "user" colum. Since
"user" is a reserved world in oracle, the whole hibernate
configuration and its mappings in the classes had to be refactored.
All the "user" references were replaced with "user_settings". I would
have to scour the source to find this outdated reference. Perhaps the
Eclipse refactoring tool didn't catch it.

Marks Andre

unread,
Sep 9, 2009, 1:03:07 PM9/9/09
to webical-developers
Update,

I managed to find the offending line of code. In pacakge
org.webical.dao.hibernateImpl the class SettingsDaoHibernateImpl has
the following method:

public UserSettings getUserSettings(User user) throws DaoException
...

try {
Criteria criteria = getSession().createCriteria
(UserSettings.class);
criteria.add(Restrictions.eq("user_settings", user)); //had to
change the string "user" to "user_settings".
return (UserSettings) criteria.uniqueResult();

As you can see the Restrictions.eq method passed "user" as an explicit
string and was not refactored. By changing this to the correct
property, it prevents the exception.

The application seems to be in a working state now with the Oracle 10g
database. I'm sure that we will find further quirks as it now we enter
in to full testing. My testing team will be hard at work and I will
hope to continue posting in separate threads from now on.

On Sep 9, 12:39 pm, Marks Andre <andreus...@gmail.com> wrote:
> Hello,
>
> Thanks for the tip. I managed to debug the login by activating the
> debug flag you mention. Indeed is quite a pain but the fact that it
> delegates authentication to Tomcat worked out perfect for my purpose.
> Interestingly, I had to explicitly configure the realm in the
> server.xml file for the Tomcat configuration (this is unfortunate as
> is preferable that the application can be deployed without modifying
> the server configuration). For some reason the aplication server is
> ignoring the context.xml realm on META-INF.
>
> Now, it seems that the application its having problems initializing. I
> manage to login to the aplication with the default webical user. It
> will ofcourse, take me to the administrator page. I then have to login
> with un: admin, pw: admin (I dont know why, I merely guessed it). I
> then go on to configure the application wide settings.When I click the
> save button, the application tries to take me to the user calendar
> (Acording to the URL in the browserhttp://localhost:8080/webical/app/calendar)

Ivo van Dongen

unread,
Sep 14, 2009, 8:59:53 AM9/14/09
to webical-d...@googlegroups.com
Hi,

Great that you've worked out all the kinks. Sorry to see that the code isn't as refactorable as I hoped. Love the Criteria api of Hibernate, but using strings remains an evil thing. I hope that the current incarnation of webical fits your purposes after your alterations. Activity on the project has been low for a long time, but I'm still hoping to get the time soon to put some more effort into it.

In the meantime, let us know how if you need anything else.

Regards,
Ivo
--
Ivo van Dongen
Func. Internet Integration
W http://www.func.nl

Marks Andre

unread,
Sep 15, 2009, 10:06:58 AM9/15/09
to webical-developers
Thanks for the asistance. I want to make my changes available
somewhere if its possible. Like the SQL Script and triggers I used for
oracle database. Let me know when you have time if and how I'll be
able to set this up. Thanks.

On Sep 14, 8:59 am, Ivo van Dongen <ivovandon...@gmail.com> wrote:
> Hi,
>
> Great that you've worked out all the kinks. Sorry to see that the code isn't
> as refactorable as I hoped. Love the Criteria api of Hibernate, but using
> strings remains an evil thing. I hope that the current incarnation of
> webical fits your purposes after your alterations. Activity on the project
> has been low for a long time, but I'm still hoping to get the time soon to
> put some more effort into it.
>
> In the meantime, let us know how if you need anything else.
>
> Regards,
> Ivo
>
> ...
>
> read more »

Ivo van Dongen

unread,
Sep 16, 2009, 3:53:11 AM9/16/09
to webical-d...@googlegroups.com
Hi,

That would be great. Perhaps the easiest way to get going is to create a new review request on the google code issue tracker and add a patch to it. That way I can apply it locally and review it as soon as I find the time.

Thanks so far,
Ivo
Reply all
Reply to author
Forward
0 new messages