Wednesday, November 21, 2018

ORA-01031: insufficient privileges in Oracle DB on Linux


If you get
ERROR: ORA-01031: insufficient privileges.
while trying to connect as sysdba in sqlplus:
SQL> connect / as sysdba
after installation of Oracle 11g on CentOS.
One reason might be that you should be connecting as oracle OS user which has the privileges.

That user didn't have a default password so I had to create one:
$ sudo passwd oracle
then
$ su - oracle

$ sqlplus '/ as sysdba'

and create a regular non sysdba user:
SQL> CREATE USER admin IDENTIFIED BY passwd;

Then you might want to open TCP port in the firewall on your CentOS box for remote connect:

Main Oracle Net service port:
$ sudo firewall-cmd --zone=public --add-port=1521/tcp --permanent

This is the default port for admin GUI:

$ sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent

$ sudo firewall-cmd --reload

The GUI is enabled by running this function:
EXEC DBMS_XDB.SETLISTENERLOCALACCESS(FALSE);
The GUI URL will be:
http://<CentOS box IP address>:8080/apex/f?p=4950:1

Friday, September 14, 2018

Jasper server errors on evaluating parameters that are commented out

Jasper server might return error like this

org.postgresql.util.PSQLException: The column index is out of range: 15, number of columns: 14. at 
...
org.apache.commons.dbcp.DelegatingPreparedStatement.setNull(DelegatingPreparedStatement.java:104) at net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.setStatementParameter(JRJdbcQueryExecuter.java:604) at

...
if there's a parameter in the comments of the report's query ($P{param} expression) as the server seems to try to evaluate those expression. The actual error might be different but watch out for parameter, field and variable expressions in the comments. 

Wednesday, June 20, 2018

could not initialize lazy properties error in Jasper Server

Sometimes after uploading or importing a modified version of a report Jasper server returns an error like this:

could not initialize lazy properties: [com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoFileResource#9370]
org.hibernate.exception.GenericJDBCException : could not initialize lazy properties: [ com.jaspersoft.jasperserver.api.metadata.common.service.impl.hibernate.persistent.RepoFileResource #9370] at ...

This is most likely due to caching of internal server references and could be resolved by restarting the server:

$ jasperreports-server-cp-6.1.0/ctlscript.sh restart

Thursday, March 15, 2018

If OpenVPN client breaks DNS configuration



Sometimes, Linux OpenVPN client changes DNS configuration and then <VPN server domain> becomes unreachable so you get error messages like:

RESOLVE: Cannot resolve host address: <VPN server domain here> (Name or service not known)

On initial connection you see this output in the console:

dhcp-option DNS <IP here>
dhcp-option DOMAIN <VPN server domain here>
/sbin/ip route add <IP here>/32 via <IP here>


systemd-resolve --status command shows this:

Global
         DNS Servers: <IP from above here>
          DNS Domain: <domain here>
...


cat /etc/resolv.conf command shows new DNS configuration by OpenVPN:
...
search <domain here>


To resolve this issue, just remove this new line from /etc/resolv.conf with an editor, e.g.

sudo nano /etc/resolv.conf

or delete the line with sed:


sudo sed -i.bak '/<domain>/d' /etc/resolv.conf

or restore from a backup but be aware that the file could really be a link, e.g. 
resolv.conf -> /run/resolvconf/resolv.conf

UPDATE: resolv.conf is most likely dynamically generated instead of a static file.

E.g. in Ubuntu check your NetworkManager configuration:
sudo NetworkManager --print-config
if there's
dns=systemd-resolved
then edit settings in
/run/resolvconf/interface/systemd-resolved
and update
sudo resolvconf -u
In my case there was also
/run/resolvconf/interface/tun0.openvpn
file (created by OpenVPN) which can be safely deleted to avoid interference:
sudo rm /run/resolvconf/interface/tun0.openvpn

The DNS settings should be back to normal now, if not, you may need to run

service networking restart

I have this function defined in .bash_aliases which fixes DNS configuration before connecting via OpenVPN:

vpn_fixed_dns() {
    echo "Fixing resolv.conf"
    echo "nameserver 127.0.0.53" | sudo tee /run/resolvconf/interface/systemd-resolved >/dev/null
    sudo rm /run/resolvconf/interface/tun0.openvpn
    echo "Running sudo resolvconf -u"
    sudo resolvconf -u
    cat /etc/resolv.conf
    echo "Running sudo openvpn"
    sudo openvpn --script-security 2 --config /etc/openvpn/config/config.ovpn

}

Wednesday, February 28, 2018

Apply button in Jasper reports doesn't work

You may encounter a weird problem when "Apply" button to run a report in Jasper server doesn't do anything and there's no error in the Jasper log.
In my case the reason for that was missing user attribute which was referenced in the report, e.g. for report parameter LoggedInUserAttribute_regionId, the corresponding user attribute regionId was not set.

Tuesday, October 4, 2016

How to get to the correct position of a syntax error in postgresql

Sometimes position of a syntax returned by PostgreSQL is not correct. You try to go to the specified position in a query (in any text editor) and it shows something totally unrelated. Probably this is due to comments or new lines or something else. And with large queries it can be frustrating to look through it all for some really simple mistake.

In order to get the correct position you will need to execute the query in PostgreSQL's own pgAdmin III tool. The position number will still be incorrectly reported but the cursor will be automatically moved to the position of an error cause. Handy!

Thursday, July 14, 2016

"Error:null" when clicking the "Read Fields" button in the Query Editor

Sometimes the "Error:null" error  appears after clicking the "Read Fields" button in the Query Editor or after autorefresh. One of the causes for this can be usage of literal parameters like $P!{param} in the query which the editor cannot calculate at the time. Just delete the parameter temporarily and restore it after "read fields" completes.