[opencms-dev] Generate CmsObject

Mario Jäger m.jaeger at alkacon.com
Fri Jun 11 16:01:11 CEST 2010


Hi,

Please, try that:

CmsObject cms = OpenCms.initCmsObject(OpenCms.getDefaultUsers().getUserGuest()); 

-- 
Kind Regards,
Mario.
 
-------------------
Mario Jäger
 
Alkacon Software GmbH  - The OpenCms Experts                    
http://www.alkacon.com - http://www.opencms.org


Ángel C. Lázaro schrieb:
> Hi Mario,
>
> What I really need is to obtain the CmsObject from a Maven Plugin, so 
> your solution doesn´t work for me. Is there another way?
>
> Thanks.
>
> Ángel C. Lázaro
>
> El 11/06/10 12:00, opencms-dev-request at opencms.org escribió:
>   
>> Send opencms-dev mailing list submissions to
>>          opencms-dev at opencms.org
>>
>> To subscribe or unsubscribe via the World Wide Web, visit
>>          http://lists.opencms.org/mailman/listinfo/opencms-dev
>> or, via email, send a message with subject or body 'help' to
>>          opencms-dev-request at opencms.org
>>
>> You can reach the person managing the list at
>>          opencms-dev-owner at opencms.org
>>
>> When replying, please edit your Subject line so it is more specific
>> than "Re: Contents of opencms-dev digest..."
>>
>>
>> Today's Topics:
>>
>>     1. Re: CmsDbSqlException (Konstantin Ott)
>>     2. Re: Generate CmsObject (Mario J?ger)
>>
>>
>> ----------------------------------------------------------------------
>>
>> Message: 1
>> Date: Thu, 10 Jun 2010 15:17:06 +0200
>> From: Konstantin Ott<konstantin.ott at albertbauer.com>
>> Subject: Re: [opencms-dev] CmsDbSqlException
>> To: opencms-dev at opencms.org
>> Message-ID:<4C10E5D2.6060309 at albertbauer.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>>
>> we're using the OCEE Modul, which enables Transactions with InnoDB.
>> But the problem started as we updated Mysql and not only happens with
>> OCEE classes.  I guess the problem appears in Connectionpool.
>> Has anybody experienced such problems with mysql  5.1.45? How about
>> configuration params of pool and my.cnf?
>>
>> Am 10.06.2010 10:01, schrieb Claus Priisholm:
>>    
>>     
>>> I am using a different test SQL statement, but it should no matter as
>>> long as the connection gets tested.
>>>
>>> I am not sure about the cause "Lock wait timeout exceeded; try
>>> restarting transaction" - this would suggest that something is messed up
>>> in relation to a transaction - perhaps a connection with an unfinished
>>> transaction has been returned to the pool. But in a default installation
>>> on MySQL there is not much going on as far as transactions goes, The
>>> MyISAM backend considers a single statement as a transaction (kind of
>>> having autocommit on all the time) so maybe in case of a freaky timing
>>> issue or likewise you could run into to it, but I would not think it
>>> would be easy to reproduce.
>>>
>>> The Prepared Statemnt looks a bit weird as well "DELEM" is not a valid
>>> SQL command as far as I know, but it could just be your cut'n'pase that
>>> caused it.
>>>
>>> /Claus
>>>
>>>
>>>
>>> Konstantin Ott wrote:
>>>
>>>      
>>>       
>>>> these params were set:
>>>> db.pool.default.testOnBorrow=true
>>>> db.pool.default.testQuery=/* ping */ SELECT 1
>>>>
>>>> and I've got another CmsDbSqlException:
>>>>
>>>> Caused by: org.opencms.db.CmsDbSqlException: An SQL error occurred when
>>>> executing the following query:
>>>> com.mysql.jdbc.PreparedStatement at 45bc00e4: DELEM CMS_ONLINE_PROPERTIES
>>>> WHERE (PROPERTY_MAPPING_ID='be622085-3d89-11df-af26-68bdd7447ccc' AND
>>>> PROPERTY_MAPPING_TYPE=2) OR
>>>> (PROPERTY_MAPPING_ID='be62209-11df-af26-68bdd7447ccc' AND
>>>> PROPERTY_MAPPING_TYPE=1).
>>>>            at
>>>> org.opencms.db.generic.CmsVfsDriver.deletePropertyObjects(CmsVfsDriver.java:939)
>>>>
>>>>            at
>>>> org.opencms.ocee.cache.CmsVfsCache.deletePropertyObjects(CmsVfsCache.java:247)
>>>>
>>>>            at
>>>> org.opencms.db.generic.CmsProjectDriver.publishChangedFile(CmsProjectDriver.java:2717)
>>>>
>>>>            at
>>>> org.opencms.db.generic.CmsProjectDriver.publishFile(CmsProjectDriver.java:964)
>>>>
>>>>            ... 5 more
>>>> Caused by: java.sql.SQLException: Lock wait timeout exceeded; try
>>>> restarting transaction
>>>>            at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
>>>>            at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
>>>>            at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
>>>>            at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
>>>>            at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
>>>>            at
>>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
>>>>
>>>>            at
>>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1585)
>>>>            at
>>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1500)
>>>>            at
>>>> com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1485)
>>>>            at
>>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
>>>>
>>>>            at
>>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:102)
>>>>
>>>>            at
>>>> org.opencms.db.generic.CmsVfsDriver.deletePropertyObjects(CmsVfsDriver.java:937)
>>>>
>>>>
>>>>
>>>>
>>>> Am 09.06.2010 09:55, schrieb Claus Priisholm:
>>>>
>>>>        
>>>>         
>>>>> I am not sure where the problem occurs, but when upgrading involved
>>>>> products to fairly new ones (like MySQL 5.1, Java 6 and  OpenCms 7.x) I
>>>>> find it necessary to enable testOnBorrow and the related testQuery in
>>>>> opencms.properties to avoid unexpected problems.
>>>>>
>>>>> Konstantin Ott wrote:
>>>>>
>>>>>
>>>>>          
>>>>>           
>>>>>> Hello list,
>>>>>>
>>>>>> since a few days we find in the opencms log file SQL Exceptions. It
>>>>>> seems to happen when publishing a file.
>>>>>> It is not reproducable and the SELECT is ok. There is a lot of load on
>>>>>> the system and there is a lot of changing content. But the problem only
>>>>>> appeared 2 times last week.
>>>>>> OpenCMS seems to loose a connection every now and then. Some time ago we
>>>>>> switched the system from Suse-Mysql5.0.51 to Debian-Mysql 5.1.45.
>>>>>> I don't know if its the reason.
>>>>>> Has anybody got an idea?
>>>>>>
>>>>>> greetings
>>>>>> Konstantin Ott
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.opencms.db.CmsDbSqlException: An SQL error occurred when executing
>>>>>> the following query: com.mysql.jdbc.PreparedStatement at f22345d: SELECT
>>>>>> CMS_OFFLINE_CONTENTS.FILE_CONTENT FROM CMS_OFFLINE_CONTENTS WHERE
>>>>>> CMS_OFFLINE_CONTENTS.RESOURCE_ID='99a69fba-bd41-11dc-9d14-69bdd7447ccc'.
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsVfsDriver.readContent(CmsVfsDriver.java:1468)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsVfsCache.readContent(CmsVfsCache.java:469)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishFileContent(CmsProjectDriver.java:1068)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsProjectCache.publishFileContent(CmsProjectCache.java:385)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishChangedFile(CmsProjectDriver.java:2760)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishFile(CmsProjectDriver.java:964)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsProjectCache.publishFile(CmsProjectCache.java:361)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishProject(CmsProjectDriver.java:1455)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsProjectCache.publishProject(CmsProjectCache.java:421)
>>>>>>             at
>>>>>> org.opencms.db.CmsDriverManager.publishJob(CmsDriverManager.java:5221)
>>>>>>             at
>>>>>> org.opencms.publish.CmsPublishThread.run(CmsPublishThread.java:199)
>>>>>> Caused by: com.mysql.jdbc.CommunicationsException: Communications link
>>>>>> failure due to underlying exception:
>>>>>>
>>>>>> ** BEGIN NESTED EXCEPTION **
>>>>>>
>>>>>> java.lang.ArrayIndexOutOfBoundsException
>>>>>>
>>>>>> STACKTRACE:
>>>>>>
>>>>>> java.lang.ArrayIndexOutOfBoundsException
>>>>>>             at java.lang.System.arraycopy(Native Method)
>>>>>>             at
>>>>>> com.mysql.jdbc.CompressedInputStream.read(CompressedInputStream.java:281)
>>>>>>             at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1994)
>>>>>>             at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2464)
>>>>>>             at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2916)
>>>>>>             at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
>>>>>>             at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1360)
>>>>>>             at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2358)
>>>>>>             at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:451)
>>>>>>             at
>>>>>> com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2076)
>>>>>>             at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1451)
>>>>>>             at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1787)
>>>>>>             at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
>>>>>>             at
>>>>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
>>>>>>             at
>>>>>> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1448)
>>>>>>             at
>>>>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
>>>>>>             at
>>>>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsVfsDriver.readContent(CmsVfsDriver.java:1453)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsVfsCache.readContent(CmsVfsCache.java:469)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishFileContent(CmsProjectDriver.java:1068)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsProjectCache.publishFileContent(CmsProjectCache.java:385)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishChangedFile(CmsProjectDriver.java:2760)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishFile(CmsProjectDriver.java:964)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsProjectCache.publishFile(CmsProjectCache.java:361)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsProjectDriver.publishProject(CmsProjectDriver.java:1455)
>>>>>>             at
>>>>>> org.opencms.ocee.cache.CmsProjectCache.publishProject(CmsProjectCache.java:421)
>>>>>>             at
>>>>>> org.opencms.db.CmsDriverManager.publishJob(CmsDriverManager.java:5221)
>>>>>>             at
>>>>>> org.opencms.publish.CmsPublishThread.run(CmsPublishThread.java:199)
>>>>>>
>>>>>>
>>>>>> ** END NESTED EXCEPTION **
>>>>>>
>>>>>>
>>>>>>
>>>>>> Last packet sent to the server was 2 ms ago.
>>>>>>             at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2922)
>>>>>>             at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:885)
>>>>>>             at com.mysql.jdbc.MysqlIO.nextRow(MysqlIO.java:1360)
>>>>>>             at com.mysql.jdbc.MysqlIO.readSingleRowSet(MysqlIO.java:2358)
>>>>>>             at com.mysql.jdbc.MysqlIO.getResultSet(MysqlIO.java:451)
>>>>>>             at
>>>>>> com.mysql.jdbc.MysqlIO.readResultsForQueryOrUpdate(MysqlIO.java:2076)
>>>>>>             at com.mysql.jdbc.MysqlIO.readAllResults(MysqlIO.java:1451)
>>>>>>             at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1787)
>>>>>>             at com.mysql.jdbc.Connection.execSQL(Connection.java:3256)
>>>>>>             at
>>>>>> com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1313)
>>>>>>             at
>>>>>> com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1448)
>>>>>>             at
>>>>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
>>>>>>             at
>>>>>> org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:93)
>>>>>>             at
>>>>>> org.opencms.db.generic.CmsVfsDriver.readContent(CmsVfsDriver.java:1453)
>>>>>>
>>>>>>
>>>>>>
>>>>>>            
>>>>>>             
>>>>>          
>>>>>           
>>>>        
>>>>         
>>>      
>>>       
>> --
>> . . . . . . . . . . . . . . . . . . . . . . . .
>>
>>
>> Konstantin Ott
>> Albert Bauer Digital | Systementwicklung
>>
>> Albert Bauer Companies GmbH&   Co. KG
>> Conventstra?e 1 - 3
>> 22089 Hamburg
>> Fon: +49 40 25109-224
>> Fax: +49 40 25109-121
>> mailto:konstantin.ott at albertbauer.com
>> http://albertbauer.com
>>
>>
>> Albert Bauer Companies GmbH&   Co. KG
>> P.H.G. Reproduktionsgesellschaft Conventhaus mbH
>> Sitz der Gesellschaft: Hamburg
>> Handelsregister: Amtsgericht Hamburg HRB 11120
>> Gesch?ftsf?hrer: Harald Dau, Carsten Dau, Rolf Gehrke, Marcus M?ller
>>
>>
>>
>> ------------------------------
>>
>> Message: 2
>> Date: Thu, 10 Jun 2010 18:02:52 +0200
>> From: Mario J?ger<m.jaeger at alkacon.com>
>> Subject: Re: [opencms-dev] Generate CmsObject
>> To: The OpenCms mailing list<opencms-dev at opencms.org>
>> Message-ID:<4C110CAC.2080300 at alkacon.com>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Hi,
>>
>> I am not sure what you exactly mean. But this code snippet shows, how you can get a CmsObject, for example in a Jsp:
>>
>> <%@ page import="org.opencms.jsp.*, org.opencms.file.*" %><%
>>
>> // Create a JSP action element
>> CmsJspActionElement action = new CmsJspActionElement(pageContext, request, response);
>>
>> // get the CmsObject
>> CmsObject cms = action.getCmsObject();
>>
>> %>
>>
>> --
>> Kind Regards,
>> Mario.
>>
>> -------------------
>> Mario J?ger
>>
>> Alkacon Software GmbH  - The OpenCms Experts
>> http://www.alkacon.com - http://www.opencms.org
>>
>>
>> ?ngel Crist?bal L?zaro R?os schrieb:
>>    
>>     
>>> Hi all,
>>>
>>> There is any way to generate a CmsObject out of the context of the web application? I have tried the way said in OpenCms 7.5.2 api.
>>>
>>> Thanks a lot
>>> ______________________
>>> This message including any attachments may contain confidential
>>> information, according to our Information Security Management System,
>>>   and intended solely for a specific individual to whom they are addressed.
>>>   Any unauthorised copy, disclosure or distribution of this message
>>>   is strictly forbidden. If you have received this transmission in error,
>>>   please notify the sender immediately and delete it.
>>>
>>> ______________________
>>> Este mensaje, y en su caso, cualquier fichero anexo al mismo,
>>>   puede contener informacion clasificada por su emisor como confidencial
>>>   en el marco de su Sistema de Gestion de Seguridad de la
>>> Informacion siendo para uso exclusivo del destinatario, quedando
>>> prohibida su divulgacion copia o distribucion a terceros sin la
>>> autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
>>>   erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
>>> Gracias por su colaboracion.
>>>
>>> ______________________
>>>
>>>
>>> _______________________________________________
>>> This mail is sent to you from the opencms-dev mailing list
>>> To change your list options, or to unsubscribe from the list, please visit
>>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>>>
>>>      
>>>       
>> ------------------------------
>>
>> _______________________________________________
>> This mail is send to you from the opencms-dev mailing list
>> To change your list options, or to unsubscribe from the list, please visit
>> http://mail.opencms.org/mailman/listinfo/opencms-dev
>>
>> End of opencms-dev Digest, Vol 296, Issue 5
>> *******************************************
>>    
>>     
>
>
> ______________________
> This message including any attachments may contain confidential 
> information, according to our Information Security Management System,
>  and intended solely for a specific individual to whom they are addressed.
>  Any unauthorised copy, disclosure or distribution of this message
>  is strictly forbidden. If you have received this transmission in error,
>  please notify the sender immediately and delete it.
>
> ______________________
> Este mensaje, y en su caso, cualquier fichero anexo al mismo,
>  puede contener informacion clasificada por su emisor como confidencial
>  en el marco de su Sistema de Gestion de Seguridad de la 
> Informacion siendo para uso exclusivo del destinatario, quedando 
> prohibida su divulgacion copia o distribucion a terceros sin la 
> autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
>  erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
> Gracias por su colaboracion.
>
> ______________________
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>   



More information about the opencms-dev mailing list